﻿/* ════════════════════════════════════════════════════════════════════════
   PHASE 4 — INVOICE CLASSIFICATION UI
   ════════════════════════════════════════════════════════════════════════
   Styles for /SalesAnalytics/InvoiceClassification.

   Builds on:
     - sa-shared.css         → tokens (--accent, --text-muted, etc.),
                               primitives (.sa-card, .sa-btn, .sa-pill,
                               .sa-toast), modal shell
     - sales-analytics-phase1.css
                             → .sa-divisions-toolbar (flex row),
                               .sa-classify-toggle, .sa-classify-actionbar,
                               .sa-classify-btn (action bar buttons),
                               .sa-row-checkbox, .sa-bulk-strip-suggest*
                               (suggestion label sub-elements)

   Owns (new selectors):
     - .sa-subline                       headline explainer paragraph
     - .sa-queue-summary                 toolbar count line
     - .sa-vendor-groups / -group        per-vendor <details> shell
     - .sa-vendor-summary / -name /
       -meta / -unclassified-count       header inside each <details>
     - .sa-vendor-group-done /
       .sa-vendor-done-badge             post-classify visual state
     - .sa-bulk-strip-prompt /
       .sa-bulk-strip-kind /
       .sa-bulk-strip-kind-suggested     three new bulk action buttons
     - .sa-invoice-item-list / -row /
       -name / -code / -meta             queue row layout
     - .sa-suggestion-slot /
       .sa-suggestion-pill +
       -retail / -ingredient /
       -operational                      per-row suggestion pills
     - .sa-row-hidden /
       .sa-show-more-btn                 vendor row expander
     - --sa-checkbox-col on
       .sa-invoice-classify-card         own checkbox column variable
                                         (mirrors Phase 1's pattern)

   Color encoding for the three kinds, consistent across pills + hovers:
     Retail       → accent blue   (matches Phase 1 retail panel)
     Ingredient   → emerald green (matches Phase 1 meal panel — invoice
                                   has no Meal kind so no collision)
     Operational  → neutral gray  (consistent with Phase 1 excluded)
   ════════════════════════════════════════════════════════════════════════ */


/* ── Headline subline ──────────────────────────────────────────────────── */

.sa-subline {
    margin: .35rem 0 0;
    font-size: .85rem;
    line-height: 1.55;
    color: var(--text-muted);
    max-width: 920px;
}

    .sa-subline strong {
        color: var(--text-main);
        font-weight: 600;
    }


/* ── Toolbar — queue summary on the left, toggle on the right ──────────
   .sa-divisions-toolbar (Phase 1) is already flex with gap. The toggle
   has margin-left:auto, so the queue summary naturally sits left. */

.sa-queue-summary {
    font-size: .92rem;
    color: var(--text-main);
    line-height: 1.4;
}

    .sa-queue-summary strong {
        color: var(--accent-strong);
        font-weight: 700;
        font-variant-numeric: tabular-nums;
    }


/* ── Card-scoped checkbox column variable ──────────────────────────────
   Mirrors Phase 1's .sa-divisions-card pattern — the row grid uses
   var(--sa-checkbox-col, 0px) so the column collapses when not in
   classify mode. */

.sa-invoice-classify-card {
    --sa-checkbox-col: 0px;
}

    .sa-invoice-classify-card.sa-classify-mode {
        --sa-checkbox-col: 28px;
    }

    .sa-invoice-classify-card:not(.sa-classify-mode) .sa-row-checkbox {
        display: none;
    }


/* ── Vendor groups (the main content area) ─────────────────────────────
   Each vendor is a <details> element. Custom chevron mirrors the Phase 1
   .sa-excluded-footer idiom — same rotate-on-open transition. */

.sa-vendor-groups {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    margin-top: .85rem;
}

.sa-vendor-group {
    border: 1px solid var(--glass-stroke);
    border-radius: var(--r-card);
    background: var(--glass);
    overflow: hidden;
    transition: background var(--t-fast), border-color var(--t-fast);
}

    .sa-vendor-group[open] {
        background: var(--glass-strong);
        border-color: var(--glass-stroke-strong);
    }


/* Summary row — chevron + name + meta */

.sa-vendor-summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .9rem;
    list-style: none;
    user-select: none;
}

    .sa-vendor-summary::-webkit-details-marker {
        display: none;
    }

    .sa-vendor-summary::marker {
        content: "";
    }

    .sa-vendor-summary::before {
        content: '▸';
        font-size: .8rem;
        color: var(--text-muted);
        transition: transform var(--t-fast);
        display: inline-block;
        flex-shrink: 0;
    }

.sa-vendor-group[open] .sa-vendor-summary::before {
    transform: rotate(90deg);
}

.sa-vendor-summary:hover {
    background: rgba(219, 234, 254, .12);
}

.sa-vendor-name {
    font-size: .95rem;
    font-weight: 650;
    color: var(--text-main);
    letter-spacing: .005em;
}

.sa-vendor-meta {
    margin-left: auto;
    font-size: .82rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.sa-vendor-unclassified-count {
    color: var(--warn-strong);
    font-weight: 700;
}


/* Vendor "done" state — applied by JS after bulk-classify clears the
   group. Muted, with a ✓ done badge that JS appends to the summary. */

.sa-vendor-group-done {
    opacity: .58;
}

    .sa-vendor-group-done .sa-vendor-name {
        text-decoration: line-through;
        text-decoration-color: rgba(15, 23, 42, .18);
        text-decoration-thickness: 1px;
    }

    .sa-vendor-group-done .sa-vendor-unclassified-count {
        color: var(--text-muted);
        font-weight: 600;
    }

.sa-vendor-done-badge {
    margin-left: .55rem;
    padding: 1px 9px;
    border-radius: var(--r-pill);
    background: rgba(16, 185, 129, .14);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, .28);
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .02em;
    white-space: nowrap;
}


/* ── Bulk strip override ───────────────────────────────────────────────
   Phase 1 defaults .sa-bulk-strip to display:none and only shows it
   inside .sa-classify-mode when data-unclassified-count is non-zero.
   The Phase 4 view doesn't use that gating — bulk strip is always
   visible inside each open vendor group. Scoped override below. */

.sa-invoice-classify-card .sa-bulk-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .55rem;
    padding: .55rem .9rem;
    background: rgba(248, 250, 252, .55);
    border-top: 1px solid var(--glass-stroke);
    border-bottom: 1px solid var(--glass-stroke);
    font-size: .8rem;
}

.sa-bulk-strip-prompt {
    color: var(--text-muted);
    margin-right: .1rem;
}


/* Three kind buttons. Three matching hover tints; the suggested one
   gets a primary gradient (kind-specific) to draw the eye. */

.sa-bulk-strip-kind {
    padding: .3rem .85rem;
    border: 1px solid var(--glass-stroke-strong);
    background: rgba(255, 255, 255, .85);
    border-radius: var(--r-control);
    font-size: .78rem;
    font-weight: 550;
    color: var(--text-main);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

    .sa-bulk-strip-kind:hover {
        transform: translateY(-1px);
    }

    .sa-bulk-strip-kind[data-kind="Retail"]:hover {
        background: var(--accent-soft);
        border-color: var(--accent);
        color: var(--accent-strong);
    }

    .sa-bulk-strip-kind[data-kind="Ingredient"]:hover {
        background: #d1fae5;
        border-color: #10b981;
        color: #047857;
    }

    .sa-bulk-strip-kind[data-kind="Operational"]:hover {
        background: #f3f4f6;
        border-color: #6b7280;
        color: #1f2937;
    }


/* Suggested-kind primary highlight. Filled with the kind's color so the
   chef sees the recommended action at a glance. Today only fires for
   operational vendors (Ecolab, Diversey, etc.) — the [data-kind] branches
   for Retail/Ingredient are forward-compatible. */

.sa-bulk-strip-kind-suggested {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    border-color: var(--accent-strong);
    box-shadow: 0 4px 10px rgba(37, 99, 235, .22);
}

    .sa-bulk-strip-kind-suggested:hover {
        background: linear-gradient(135deg, var(--accent-strong), #1e40af);
        color: #fff;
        border-color: #1e40af;
    }

    .sa-bulk-strip-kind-suggested[data-kind="Ingredient"] {
        background: linear-gradient(135deg, #10b981, #059669);
        border-color: #059669;
        box-shadow: 0 4px 10px rgba(16, 185, 129, .22);
    }

        .sa-bulk-strip-kind-suggested[data-kind="Ingredient"]:hover {
            background: linear-gradient(135deg, #059669, #047857);
            border-color: #047857;
        }

    .sa-bulk-strip-kind-suggested[data-kind="Operational"] {
        background: linear-gradient(135deg, #4b5563, #374151);
        border-color: #374151;
        box-shadow: 0 4px 10px rgba(15, 23, 42, .18);
    }

        .sa-bulk-strip-kind-suggested[data-kind="Operational"]:hover {
            background: linear-gradient(135deg, #374151, #1f2937);
            border-color: #1f2937;
        }


/* ── Action bar hover variants for new kinds ───────────────────────────
   Phase 1 styles [data-kind="Retail"/"Meal"/"Excluded"]. Phase 4 uses
   Retail (inherited) + Ingredient + Operational (new). */

.sa-classify-btn[data-kind="Ingredient"]:hover:not([disabled]) {
    background: #d1fae5;
    border-color: #10b981;
}

.sa-classify-btn[data-kind="Operational"]:hover:not([disabled]) {
    background: #f3f4f6;
    border-color: #6b7280;
}


/* ── Invoice item list + rows ──────────────────────────────────────────
   Grid layout per row: checkbox | name | code | meta | suggestion-pill.
   Checkbox column collapses to 0px when not in classify mode. */

.sa-invoice-item-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: rgba(255, 255, 255, .55);
    
}

.sa-invoice-item-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .42rem .9rem;
    border-bottom: 1px solid rgba(148, 163, 184, .12);
    font-size: .95rem;
    transition: background var(--t-fast);
    text-transform: capitalize !important;
}

    .sa-invoice-item-row:last-child {
        border-bottom: none;
    }

    .sa-invoice-item-row:hover {
        background: rgba(219, 234, 254, .18);
    }

.sa-invoice-item-name {
    flex: 1 1 auto; /* grow to fill remaining row */
    min-width: 0;
    color: var(--text-main);
    line-height: 1.35;
    overflow-wrap: break-word;
}

.sa-invoice-item-code {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: .86rem;
    white-space: nowrap;
    
}

.sa-invoice-item-meta {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    
}

.sa-suggestion-slot {
    flex: 0 0 auto;
    text-align: right;
}

.sa-suggestion-pill {
    display: inline-block;
    padding: 1px 9px;
    border-radius: var(--r-pill);
    font-size: .66rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
    border: 1px solid transparent;
    line-height: 1.55;
    cursor: help;
    white-space: nowrap;
    vertical-align: middle;
}

.sa-suggestion-pill-retail {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: rgba(37, 99, 235, .28);
}

.sa-suggestion-pill-ingredient {
    background: #d1fae5;
    color: #047857;
    border-color: rgba(16, 185, 129, .32);
}

.sa-suggestion-pill-operational {
    background: #f3f4f6;
    color: #4b5563;
    border-color: rgba(107, 114, 128, .32);
}


/* ── Row expander ──────────────────────────────────────────────────────
   First 10 rows render; the rest get .sa-row-hidden. The "Show N more"
   button at the bottom removes the class and removes itself. */

.sa-invoice-item-row.sa-row-hidden {
    display: none;
}

.sa-show-more-btn {
    display: block;
    width: 100%;
    padding: .5rem .9rem;
    background: rgba(248, 250, 252, .55);
    border: none;
    border-top: 1px solid var(--glass-stroke);
    color: var(--accent);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background var(--t-fast), color var(--t-fast);
}

    .sa-show-more-btn:hover {
        background: rgba(219, 234, 254, .35);
        color: var(--accent-strong);
    }


/* ── Responsive ────────────────────────────────────────────────────────
   Below ~720px the row's 5-column grid wants to collapse. Item code and
   meta drop to a second line under the name; suggestion pill follows. */

@media (max-width: 720px) {
    .sa-invoice-item-row {
        grid-template-columns: var(--sa-checkbox-col, 0px) 1fr;
        gap: .25rem .75rem;
        padding: .55rem .85rem;
    }

    .sa-invoice-item-code,
    .sa-invoice-item-meta,
    .sa-suggestion-slot {
        grid-column: 2;
        text-align: left;
    }

    .sa-vendor-meta {
        font-size: .78rem;
    }

    .sa-bulk-strip-prompt {
        flex-basis: 100%;
        margin-bottom: .15rem;
    }

    .sa-bulk-strip-kind {
        font-size: .76rem;
        padding: .28rem .7rem;
    }
}
