/* app.css — VibeCount styles */

/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
    --pi-sidebar-width: 220px;
    --pi-sidebar-bg: #1a1f2e;
    --pi-sidebar-accent: #3b82f6;
    --pi-sidebar-text: #94a3b8;
    --pi-sidebar-text-hover: #f1f5f9;
    --pi-sidebar-section: #475569;
    --pi-sidebar-active-bg: rgba(59,130,246,0.15);
    --pi-sidebar-active-text: #93c5fd;

    /* Semantic palette */
    --pi-text-muted: #64748b;
    --pi-border: #e2e8f0;
    --pi-card-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --pi-font-sm: 0.8125rem;
    --pi-font-xs: 0.75rem;
    --pi-font-xxs: 0.6875rem;
}

/* ─── Base ─────────────────────────────────────────────────── */
body { font-size: 0.9rem; background: #f8f9fa; }

/* ─── Layout ────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

#sidebar {
    width: var(--pi-sidebar-width);
    min-height: 100vh;
    background: var(--pi-sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.25);
}

#main-content {
    flex: 1;
    min-height: 100vh;
    overflow-x: hidden;
    background: #f0f4f8;
}

/* ─── Sidebar Brand Header ───────────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 0.5rem;
}
.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: #ffffff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    padding: 2px;
    object-fit: contain;
}
.sidebar-brand-name {
    color: #f1f5f9;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
.sidebar-brand-tag {
    color: var(--pi-sidebar-text);
    font-size: var(--pi-font-xxs);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
}

/* ─── Active Event Picker ────────────────────────────────────── */
#event-badge {
    margin: 0 0.75rem 0.5rem;
    padding: 0.45rem 0.6rem;
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 6px;
    font-size: var(--pi-font-xs);
    line-height: 1.3;
    display: block;
}
#event-badge .event-label {
    color: var(--pi-text-muted);
    font-size: var(--pi-font-xxs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.event-picker-select {
    width: 100%;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(59,130,246,0.35);
    color: #e2e8f0;
    border-radius: 4px;
    font-size: var(--pi-font-xs);
    padding: 3px 6px;
    cursor: pointer;
    outline: none;
}
.event-picker-select:focus { border-color: rgba(59,130,246,0.6); }
.event-picker-select option { background: #1a1f2e; color: #e2e8f0; }

/* ─── Nav Links ──────────────────────────────────────────────── */
.nav-section {
    display: block;
    font-size: var(--pi-font-xxs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pi-sidebar-section);
    padding: 0.85rem 1rem 0.3rem;
}

#sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--pi-sidebar-text);
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    font-size: 0.84rem;
    margin: 1px 0.5rem;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}
#sidebar .nav-link .nav-icon {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}
#sidebar .nav-link:hover {
    color: var(--pi-sidebar-text-hover);
    background: rgba(255,255,255,0.07);
}
#sidebar .nav-link:hover .nav-icon { opacity: 1; }
#sidebar .nav-link.active {
    color: var(--pi-sidebar-active-text);
    background: var(--pi-sidebar-active-bg);
    font-weight: 500;
}
#sidebar .nav-link.active .nav-icon { opacity: 1; }

/* ─── Collapsible Sub-menus ───────────────────────────────────── */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.nav-submenu.open {
    max-height: 500px;
}
.nav-submenu .nav-link {
    padding-left: 2.2rem !important;
    font-size: 0.8rem;
}
.nav-chevron {
    font-size: 0.65rem;
    transition: transform 0.25s ease;
    color: var(--pi-sidebar-active-text);
    opacity: 0.85;
    padding: 4px;
    line-height: 1;
}
.nav-chevron.rotated {
    transform: rotate(180deg);
}
.nav-section-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.nav-section-toggle .nav-chevron {
    font-size: 0.55rem;
}

/* ─── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-footer .user-info {
    font-size: var(--pi-font-xs);
    color: var(--pi-sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.5rem;
}
.sidebar-footer .user-email { color: #e2e8f0; font-weight: 500; }

/* ─── Heatmap ─────────────────────────────────────────────────── */
.heatmap-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.heatmap-cell {
    width: 80px; height: 60px;
    border-radius: 8px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    font-size: var(--pi-font-xs); font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.08);
    transition: transform 0.12s, box-shadow 0.12s;
}
.heatmap-cell:hover { transform: scale(1.06); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
/* Active scanning state — pulsing green border */
.heatmap-cell.cell-scanning {
    outline: 3px solid #16a34a;
    outline-offset: -1px;
    box-shadow: 0 0 12px rgba(22,163,74,0.5);
    animation: scan-pulse 1.5s ease-in-out infinite;
    z-index: 5;
    position: relative;
}
@keyframes scan-pulse {
    0%, 100% { outline-color: #16a34a; box-shadow: 0 0 12px rgba(22,163,74,0.5); }
    50%      { outline-color: #16a34a; box-shadow: 0 0 24px rgba(22,163,74,0.8); }
}
.heatmap-cell.cell-scanning:hover {
    transform: scale(1.06);
    box-shadow: 0 0 0 2px #22c55e, 0 4px 16px rgba(34,197,94,0.4);
}
.cell-team-badge {
    font-size: .5rem;
    font-weight: 700;
    color: #fff;
    background: #3b82f6;
    border-radius: 2px;
    padding: 0 3px;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}
.status-scanning { background: #bbf7d0; color: #065f46; }

/* Supervisor call indicators on heatmap cells — true blink, all 4 sides */
.heatmap-cell.cell-call-pending {
    animation: call-blink-red 0.8s ease-in-out infinite;
    z-index: 10;
    position: relative;
}
.heatmap-cell.cell-call-accepted {
    animation: call-blink-yellow 1s ease-in-out infinite;
    z-index: 10;
    position: relative;
}
@keyframes call-blink-red {
    0%, 100% { outline: 4px solid #dc3545; outline-offset: -2px; box-shadow: 0 0 16px rgba(220,53,69,0.6); }
    50%      { outline: 4px solid transparent; outline-offset: -2px; box-shadow: none; }
}
@keyframes call-blink-yellow {
    0%, 100% { outline: 4px solid #f59e0b; outline-offset: -2px; box-shadow: 0 0 14px rgba(245,158,11,0.5); }
    50%      { outline: 4px solid transparent; outline-offset: -2px; box-shadow: none; }
}
/* High-contrast cell status colors */
.heatmap-cell.status-not-started { background: #c8cdd3; color: #2d3748; }
.heatmap-cell.status-blind-only  { background: #93c5fd; color: #1e3a5f; }
.heatmap-cell.status-scan-only   { background: #fcd34d; color: #713f12; }
.heatmap-cell.status-in-progress { background: #c4b5fd; color: #3b1f8e; }
.heatmap-cell.status-complete    { background: #6ee7b7; color: #064e3b; }
.heatmap-cell.status-variance    { background: #fca5a5; color: #7f1d1d; }
/* SKU search typeahead dropdown */
.sku-dd-item:hover { background: #eff6ff !important; }
#sku-dropdown-fs .sku-dd-item:hover { background: #2d3748 !important; }

/* Legend swatches */
.heatmap-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: var(--pi-font-xs); width: 100%; }
.heatmap-legend-item { display: flex; align-items: center; gap: 5px; }
.heatmap-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); flex-shrink: 0; }

/* ─── Scan UI ─────────────────────────────────────────────────── */
.scan-input-wrapper { position: relative; }
.scan-input-wrapper input { font-size: 1.1rem; padding: 0.6rem 1rem; }
.scan-feedback { min-height: 2rem; font-size: 0.9rem; }

/* ─── Facilities ──────────────────────────────────────────────── */
.fac-physical td:first-child { font-weight: 600; }
.fac-virtual  td:first-child { padding-left: 2.2rem; color: #555; }
.fac-virtual  td:first-child::before { content: '↳ '; color: #aaa; }
.badge-physical { background: #0d6efd22; color: #0d6efd; border: 1px solid #0d6efd55; }
.badge-virtual  { background: #6f42c122; color: #6f42c1; border: 1px solid #6f42c155; }
tr.inactive td  { opacity: .5; }

/* ─── Count Sheets ────────────────────────────────────────────── */
.sheet-row        { background: #fff; }
.sheet-row td     { vertical-align: middle; }
.loc-row td       { font-size: var(--pi-font-sm); color: #555; background: #f8f9fa; }
.sheet-toggle     { cursor: pointer; user-select: none; }
.loc-indent       { padding-left: 2.5rem !important; }
.section-header td {
    font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .05em; color: #6c757d; background: #e9ecef;
    padding: .25rem .75rem !important;
}

/* ─── Sort Panels (products, before-count) ────────────────────── */
.sort-level { display: flex; gap: .4rem; align-items: center; }
.sort-level select { flex: 1; }
.sort-level .dir-sel { max-width: 120px; flex: none; }

/* ─── Location Builder ────────────────────────────────────────── */
.fw-width-input { width: 64px !important; }
#loc-preview-table table { font-size: var(--pi-font-sm); }
#loc-flat-table  { font-size: 0.84rem; }
#loc-flat-table td, #loc-flat-table th { vertical-align: middle; }

/* ─── Blind Count ─────────────────────────────────────────────── */
input.bc-count::-webkit-outer-spin-button,
input.bc-count::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.bc-count { -moz-appearance: textfield; }

/* ─── Inventory by Location ───────────────────────────────────── */
.loc-header td { background: #f0f4ff; font-weight: 600; font-size: .8rem; letter-spacing: .04em; }

/* ─── Event Setup (drag & drop) ───────────────────────────────── */
tr.drag-over { outline: 2px dashed #0d6efd; background: #e8f0fe; }

/* ─── Barcode Rules ───────────────────────────────────────────── */
.rule-row { cursor: grab; }
.rule-row.drag-over { outline: 2px dashed #0d6efd; background: #e8f0fe; }
.rule-row.dragging  { opacity: 0.4; }
.priority-badge     { min-width: 2rem; text-align: center; }
.strategy-badge     { font-size: var(--pi-font-xs); }
#mapping-editor tr td:first-child { width: 7rem; }
.test-result-card { border-left: 4px solid #dee2e6; }
.test-result-card.matched  { border-left-color: #0d6efd; }
.test-result-card.resolved { border-left-color: #198754; }
.test-result-card.alert    { border-left-color: #ffc107; }
.test-result-card.danger   { border-left-color: #dc3545; }
.test-catalog-item { cursor: pointer; transition: background .1s; }
.test-catalog-item:hover { background: #f0f4ff; }
.barcode-mono { font-family: monospace; font-size: var(--pi-font-sm); word-break: break-all; }

/* ─── Variance Review ─────────────────────────────────────────── */
.row-below-threshold { opacity: .55; }
.note-collapse { display: none; }
.note-collapse.open { display: block; }

/* ─── Location Claims ─────────────────────────────────────────── */
tr.unlocked td { opacity: 0.5; }
.status-locked   { color: #dc3545; font-weight: 600; }
.status-unlocked { color: #6c757d; }

/* ─── Flagged Items ───────────────────────────────────────────── */
.flag-type-lot    { background: #fff3cd; color: #664d03; }
.flag-type-serial { background: #cfe2ff; color: #084298; }
.flag-type-gtin   { background: #f8d7da; color: #842029; }

/* ─── Test Products ───────────────────────────────────────────── */
.industry-badge { font-size: var(--pi-font-xs); }
.system-badge   { font-size: 0.7rem; }

/* ─── Before-Count Records Modal ──────────────────────────────── */
#fac-dropdown-menu { min-width: 300px; max-height: 300px; overflow-y: auto; }

/* ─── Dashboard Fullscreen Overlay ────────────────────────────── */
/* Only the sheet-detail modal needs elevated z-index (above the fullscreen layout at z-index 2000).
   The backdrop is elevated via JS only when that specific modal is shown — see dashboard.html. */
#sheetDetailModal { z-index: 2100 !important; }

/* ─── Print ───────────────────────────────────────────────────── */
@media print {
    #sidebar, .no-print { display: none !important; }
    #main-content { padding: 0 !important; background: white; }
    body { background: #fff !important; }
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar {
        width: 0; overflow: hidden;
        position: fixed; z-index: 1040; height: 100%;
    }
    #sidebar.show { width: var(--pi-sidebar-width); }
    .heatmap-cell { width: 64px; height: 48px; }
}
