﻿/* ==========================================================================
   PHASE 2C — PANEL LAYOUT POLISH
   --------------------------------------------------------------------------
   Builds on the Phase 2B Day.cshtml structure:

     section.sa-divisions-card
       div.sa-divisions-toolbar
       div.sa-divisions-legend
       div.sa-accordions
         div.sa-panel.sa-panel-unclassified
         div.sa-panel.sa-panel-retail
         div.sa-panel.sa-panel-meal
       details.sa-excluded-footer

   Owns:
     - .sa-panel container (vertical breathing room between panels)
     - .sa-panel-header (flex layout + per-kind left-border accent)
     - .sa-panel-meta / .sa-panel-cta (Unclassified header — text + button)
     - .sa-panel-kpis / .sa-panel-kpi-label (Retail/Meal header — KPI strip)
     - .sa-panel-divisions wrapper (documentation only; no rules)
     - .sa-panel-movers (spacing between movers row and adjacent panels)
     - .sa-excluded-footer (collapsed strip + expanded flat item list)
     - Responsive: panel header wrap + condensed excluded list under 720px

   Load order: after sa-shared.css and sales-analytics-phase1.css.
   Reuses tokens from sa-shared (--text-main, --text-muted, --accent, etc.).
   ========================================================================== */


/* ── Panel container ──────────────────────────────────────────────────────
   Top margin separates panels visually inside the shared divisions-card.
   First-child override keeps the first panel flush with the legend. */
.sa-panel {
    margin-top: 1.75rem;
}

    .sa-panel:first-child {
        margin-top: 0.5rem;
    }


/* ── Panel header ─────────────────────────────────────────────────────────
   Flex row: name on the left, meta/KPIs/CTA on the right.
   The colored left border is the kind-specific accent — very subtle, no
   filled backgrounds (those would compete with the accordion rows below).

   Order on the right:
     - Unclassified: meta text + CTA button (header has Classify items →)
     - Retail:       KPI strip (Units, Rev, $/unit, Items, Divs)
     - Meal:         KPI strip (Portions, Rev, $/portion, Dishes, Divs)

   margin-left: auto on the right-side element pushes it to the far right;
   gap on the parent flex handles spacing within. */
.sa-panel-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.55rem 0.9rem 0.55rem 0.9rem;
    border-bottom: 1px solid #e8eaee;
    background: transparent;
    margin-bottom: 0.25rem;
    border-left: 3px solid transparent; /* placeholder; per-kind below */
}

.sa-panel-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}

/* Per-kind accent — single left border, ~3px, calm tones */
.sa-panel-unclassified .sa-panel-header {
    border-left-color: #f59e0b; /* amber */
}

.sa-panel-retail .sa-panel-header {
    border-left-color: #3b82f6; /* blue */
}

.sa-panel-meal .sa-panel-header {
    border-left-color: #10b981; /* emerald */
}


/* ── Unclassified panel — meta line + CTA button ──────────────────────────
   "X items pending classification across Y divisions" + a primary action
   button that activates classify mode. Visual weight: meta text quiet,
   CTA prominent. */
.sa-panel-meta {
    color: #6b7280;
    font-size: 0.84rem;
    line-height: 1.4;
}

    .sa-panel-meta strong {
        color: #374151;
        font-weight: 600;
    }

.sa-panel-cta {
    margin-left: auto;
    padding: 0.38rem 0.8rem;
    background: #f59e0b;
    color: #fff;
    border: 1px solid #d97706;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

    .sa-panel-cta:hover {
        background: #d97706;
        border-color: #b45309;
    }

    .sa-panel-cta:active {
        background: #b45309;
    }

/* Hide the CTA when classify mode is already active — the toolbar toggle
   covers the same intent and the redundant button just adds noise. */
.sa-classify-mode .sa-panel-cta {
    display: none;
}


/* ── Retail / Meal panels — KPI strip on the header right ─────────────────
   Inline list of per-panel summary numbers. Labels small uppercase to
   match the headline pill style; values inherit normal weight. */
.sa-panel-kpis {
    display: flex;
    gap: 1.1rem;
    margin-left: auto;
    align-items: baseline;
    font-size: 0.85rem;
    color: #4b5563;
}

    .sa-panel-kpis > span {
        white-space: nowrap;
    }

.sa-panel-kpi-label {
    color: #9ca3af;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.25rem;
    font-weight: 600;
}


/* ── Panel divisions wrapper ──────────────────────────────────────────────
   The partial wraps accordion rows in .sa-panel-divisions. Existing
   .sa-accordion CSS (Phase 1) handles the per-row styling — we only need
   to ensure the first accordion sits cleanly under the panel header. */
.sa-panel-divisions {
    /* No padding — accordion rows handle their own spacing.
       Listed for documentation; rule could be omitted. */
}


/* ── Movers row beneath a panel ───────────────────────────────────────────
   _PanelMovers.cshtml renders <div class="sa-movers-row-compact sa-panel-movers">
   containing two .sa-card.sa-mover-card siblings. The existing mover-card
   CSS handles the card itself; we just space the row from the accordions
   above and the next panel below. */
.sa-panel-movers {
    margin-top: 1.1rem;
    margin-bottom: 0.25rem;
}


/* ── Excluded footer ──────────────────────────────────────────────────────
   <details> element — collapsed by default to a single thin strip,
   expanded shows the flat item list. Native disclosure triangle hidden in
   favor of a CSS-rendered chevron that rotates with [open] state.

   The flat list is a CSS grid per row: division | name | code | qty | rev.
   Subtle alternating row background to scan long lists more easily. */
.sa-excluded-footer {
    margin-top: 1.75rem;
    padding: 0.55rem 0.9rem;
    background: #f8f9fa;
    border: 1px solid #e8eaee;
    border-radius: 4px;
    font-size: 0.85rem;
}

    .sa-excluded-footer summary {
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        color: #6b7280;
        list-style: none;
        user-select: none;
        padding: 0.15rem 0;
    }
        /* Hide native triangle (Webkit + Firefox). */
        .sa-excluded-footer summary::-webkit-details-marker {
            display: none;
        }

        .sa-excluded-footer summary::marker {
            content: "";
        }

        /* Custom chevron — rotates 90° when [open]. */
        .sa-excluded-footer summary::before {
            content: '▸';
            font-size: 0.78rem;
            color: #9ca3af;
            transition: transform 0.15s ease;
            display: inline-block;
        }

    .sa-excluded-footer[open] summary::before {
        transform: rotate(90deg);
    }

.sa-excluded-label {
    font-weight: 600;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.74rem;
}

.sa-excluded-meta {
    color: #9ca3af;
    font-size: 0.82rem;
}

    .sa-excluded-meta strong {
        color: #4b5563;
        font-weight: 600;
    }

.sa-excluded-list {
    margin: 0.65rem 0 0 0;
    padding: 0.4rem 0 0 0;
    list-style: none;
    border-top: 1px solid #e8eaee;
}

    .sa-excluded-list li {
        display: grid;
        grid-template-columns: 1.1fr 2.4fr 90px 70px 80px;
        gap: 0.75rem;
        padding: 0.32rem 0.5rem;
        align-items: center;
        color: #4b5563;
        font-size: 0.83rem;
        border-radius: 2px;
    }

        .sa-excluded-list li:nth-child(odd) {
            background: rgba(0, 0, 0, 0.018);
        }

        .sa-excluded-list li:hover {
            background: rgba(59, 130, 246, 0.04);
        }

.sa-excluded-div {
    color: #6b7280;
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sa-excluded-name {
    color: #374151;
}

.sa-excluded-code {
    color: #9ca3af;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.76rem;
}

.sa-excluded-qty {
    text-align: right;
    color: #4b5563;
    font-variant-numeric: tabular-nums;
}

.sa-excluded-rev {
    text-align: right;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}


/* ── Responsive: narrow viewports ─────────────────────────────────────────
   Panel header gets cramped under ~720px. Stack the right-side element
   below the name. KPIs wrap to two rows if needed. */
@media (max-width: 720px) {
    .sa-panel-header {
        flex-wrap: wrap;
        gap: 0.5rem 0.85rem;
    }

    .sa-panel-kpis,
    .sa-panel-cta,
    .sa-panel-meta {
        margin-left: 0;
    }

    .sa-panel-kpis {
        flex-wrap: wrap;
        gap: 0.5rem 0.85rem;
        font-size: 0.8rem;
    }

    .sa-excluded-list li {
        grid-template-columns: 1fr 70px 70px;
        gap: 0.4rem;
    }

        .sa-excluded-list li .sa-excluded-div,
        .sa-excluded-list li .sa-excluded-code {
            display: none;
        }
}
