/**
 * nutri-pages.css — the presentation layer shared by the nutrition screens.
 *
 * Three things every one of them needed and none had:
 *
 *  1. Data tables that survive a phone. A horizontally-scrolling table is a
 *     desktop table in a smaller box; below 768px each row becomes a card
 *     with its column header printed beside each value (fed by data-label,
 *     which nutri-ui.js fills in automatically).
 *
 *  2. Empty states that tell you what to do next instead of just saying
 *     "no data" — an empty screen is the first thing a new clinic sees.
 *
 *  3. A consistent visual grammar: the same card, the same header, the same
 *     rating control, the same quick action, on every screen.
 *
 * Loaded after nutri-responsive.css.
 */

/* =====================================================================
   Cards & headers — one grammar everywhere
   ===================================================================== */
.np-card {
    background: #fff;
    border: 1px solid var(--emr-border, #e2e8f0);
    border-radius: 14px;
    box-shadow: var(--emr-shadow-sm, 0 1px 3px rgba(15, 23, 42, .06));
    margin-bottom: 16px;
    overflow: hidden;
}
.np-card-head {
    padding: 13px 16px;
    border-bottom: 1px solid var(--emr-border, #e2e8f0);
    font-weight: 700;
    font-size: .92rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.np-card-head .np-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.np-card-head .np-count {
    background: var(--emr-primary-soft, #ecfdf5);
    color: var(--emr-primary-dark, #0f766e);
    border-radius: 20px; padding: 1px 9px; font-size: .72rem; font-weight: 700;
}
.np-card-body { padding: 14px 16px; }
.np-card-body.np-flush { padding: 0; }

/* =====================================================================
   Empty states — always offer the next action
   ===================================================================== */
.np-empty { text-align: center; padding: 40px 20px; color: #94a3b8; }
.np-empty i.np-empty-icon {
    font-size: 2.2rem; display: block; margin-bottom: 12px; opacity: .45;
}
.np-empty h6 { font-weight: 700; color: #64748b; margin-bottom: 4px; font-size: .95rem; }
.np-empty p { font-size: .84rem; margin-bottom: 14px; }

/* =====================================================================
   Loading skeletons — never a bare spinner on a data screen
   ===================================================================== */
.np-skel { padding: 8px 0; }
.np-skel i {
    display: block; height: 13px; border-radius: 6px; margin: 11px 0;
    background: linear-gradient(90deg, #f1f5f9 25%, #e6ebf2 37%, #f1f5f9 63%);
    background-size: 400% 100%;
    animation: npShimmer 1.3s ease infinite;
}
@keyframes npShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* =====================================================================
   Rating scale — 1..5 as tappable pills, not a number input
   ===================================================================== */
.np-scale { display: inline-flex; gap: 5px; }
.np-scale button {
    width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid var(--emr-border, #e2e8f0);
    background: #fff; color: #64748b;
    font-weight: 700; font-size: .85rem; cursor: pointer;
    transition: all .12s;
}
.np-scale button:hover { border-color: var(--emr-primary, #0f766e); color: var(--emr-primary, #0f766e); }
.np-scale button.on { background: var(--emr-primary, #0f766e); border-color: transparent; color: #fff; }
.np-scale-legend { font-size: .72rem; color: #94a3b8; margin-top: 4px; }

/* Read-only dot scale used in tables. */
.np-dots { display: inline-flex; gap: 3px; }
.np-dots i { width: 13px; height: 13px; border-radius: 50%; background: #e2e8f0; display: inline-block; }
.np-dots i.on { background: var(--emr-primary, #0f766e); }

/* =====================================================================
   Quick actions — reach the client from the row you are looking at
   ===================================================================== */
.np-actions { display: inline-flex; gap: 4px; }
.np-act {
    width: 34px; height: 34px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--emr-border, #e2e8f0); background: #fff;
    color: #64748b; font-size: .85rem; text-decoration: none;
    transition: all .12s;
}
.np-act:hover { color: #fff; border-color: transparent; }
.np-act.np-wa:hover   { background: #25d366; }
.np-act.np-call:hover { background: #0ea5e9; }
.np-act.np-open:hover { background: var(--emr-primary, #0f766e); }
.np-act.np-danger:hover { background: #dc2626; }

/* =====================================================================
   Client chip — the same identity block on every screen
   ===================================================================== */
.np-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.np-avatar {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    background: var(--emr-primary-soft, #ecfdf5); color: var(--emr-primary-dark, #0f766e);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .78rem;
}
.np-who .np-name { font-weight: 600; font-size: .86rem; line-height: 1.25; }
.np-who .np-meta { font-size: .74rem; color: #94a3b8; }

/* =====================================================================
   Segmented filter — replaces stray selects above a list
   ===================================================================== */
.np-seg { display: inline-flex; background: #f1f5f9; border-radius: 10px; padding: 3px; gap: 2px; }
.np-seg button {
    border: none; background: none; border-radius: 8px;
    padding: 6px 14px; font-size: .8rem; font-weight: 600; color: #64748b; cursor: pointer;
    white-space: nowrap; transition: all .12s;
}
.np-seg button.on { background: #fff; color: var(--emr-primary-dark, #0f766e); box-shadow: 0 1px 3px rgba(15,23,42,.1); }

/* =====================================================================
   Sticky save bar — long forms must not hide their save button
   ===================================================================== */
.np-stickybar {
    position: sticky; bottom: 0; z-index: 20;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--emr-border, #e2e8f0);
    padding: 10px 16px; margin: 16px -16px -14px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.np-stickybar .np-dirty { font-size: .78rem; color: #b45309; display: none; }
.np-stickybar.is-dirty .np-dirty { display: inline; }

/* =====================================================================
   Section jump list for very long forms
   ===================================================================== */
.np-jump { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.np-jump a {
    font-size: .78rem; padding: 5px 12px; border-radius: 20px;
    border: 1px solid var(--emr-border, #e2e8f0); color: #64748b; text-decoration: none;
    transition: all .12s;
}
.np-jump a:hover, .np-jump a.on {
    background: var(--emr-primary, #0f766e); border-color: transparent; color: #fff;
}

/* =====================================================================
   Tables → cards below 768px
   ---------------------------------------------------------------------
   Opt-in via .np-cards on the <table>. nutri-ui.js copies each column
   header into the matching cell's data-label so the card can print it.
   ===================================================================== */
@media (max-width: 768px) {
    table.np-cards, table.np-cards tbody, table.np-cards tr, table.np-cards td {
        display: block; width: 100%;
    }
    table.np-cards thead { display: none; }
    table.np-cards tr {
        border: 1px solid var(--emr-border, #e2e8f0);
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 6px 12px;
        background: #fff;
    }
    table.np-cards td {
        border: none !important;
        padding: 7px 0 !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        white-space: normal !important;
        border-bottom: 1px solid #f6f8fb !important;
    }
    table.np-cards td:last-child { border-bottom: none !important; }
    /* The header, printed as the cell's own label. */
    table.np-cards td[data-label]::before {
        content: attr(data-label);
        font-size: .72rem;
        font-weight: 700;
        color: #94a3b8;
        flex-shrink: 0;
    }
    /* A cell with no label (the actions column) spans the full width. */
    table.np-cards td:not([data-label]),
    table.np-cards td[data-label=""] { justify-content: flex-end; }

    /* The first cell reads as the card's title. */
    table.np-cards td:first-child {
        font-weight: 700;
        font-size: .9rem;
        padding-top: 4px !important;
    }
    table.np-cards td:first-child::before { font-weight: 700; }

    .np-seg { width: 100%; overflow-x: auto; }
    .np-stickybar { margin-inline: -12px; }
    .np-scale button { width: 44px; height: 44px; }
}

@media (max-width: 576px) {
    .np-card-head { flex-direction: column; align-items: stretch; }
    .np-card-head > .np-title { justify-content: flex-start; }
    .np-actions { gap: 6px; }
    .np-act { width: 40px; height: 40px; }
}
