/* ============================================================
   Tool Tracker — App Shell (Tool Counter look)
   Loaded LAST. Retheme the existing design tokens from
   maroon-dark → blue-light, and turn the top navbar into a
   navy left sidebar rail on desktop. No per-page markup edits.
   ============================================================ */

/* ---------- 1. Token retheme: base --color-* palette ---------- */
:root {
    /* Brand → blue / navy */
    --color-primary: #1e50a8;
    --color-primary-dark: #0e2748;
    --color-primary-light: #3f74d1;
    --color-primary-hover: #17408a;
    --color-primary-subtle: rgba(30, 80, 168, 0.12);

    --color-accent: #1e50a8;
    --color-accent-light: #3f74d1;
    --color-accent-dark: #17408a;
    --color-accent-subtle: rgba(30, 80, 168, 0.12);

    /* Light backgrounds */
    --color-bg: #f2f5f9;
    --color-bg-secondary: #eef1f6;
    --color-bg-elevated: #ffffff;

    --color-surface: #ffffff;
    --color-surface-light: #f7f9fc;
    --color-surface-hover: #eef1f6;
    --color-surface-active: #e3e8f0;

    /* Dark text on light */
    --color-text: #14202f;
    --color-text-secondary: #3a4658;
    --color-text-muted: #6b7787;
    --color-text-subtle: #9aa5b4;
    --color-text-dark: #14202f;

    /* Borders */
    --color-border: rgba(16, 32, 54, 0.1);
    --color-border-light: rgba(16, 32, 54, 0.07);
    --color-border-strong: rgba(16, 32, 54, 0.16);
    --color-border-accent: rgba(30, 80, 168, 0.35);

    /* Inputs */
    --color-input-bg: #ffffff;
    --color-input-border: rgba(16, 32, 54, 0.16);
    --color-input-focus: var(--color-primary);
    --color-input-text: #14202f;
    --color-input-placeholder: #9aa5b4;

    /* Status (kept vivid, light backdrops) */
    --color-success: #16824a;
    --color-success-bg: rgba(22, 130, 74, 0.12);
    --color-warning: #c9770a;
    --color-warning-bg: rgba(224, 133, 11, 0.14);
    --color-danger: #d24444;
    --color-danger-bg: rgba(210, 68, 68, 0.12);
    --color-info: #1e50a8;
    --color-info-bg: rgba(30, 80, 168, 0.12);

    /* Softer shadows for light UI */
    --shadow-sm: 0 1px 2px rgba(16, 32, 54, 0.06);
    --shadow-md: 0 2px 8px rgba(16, 32, 54, 0.08);
    --shadow-lg: 0 10px 24px rgba(16, 32, 54, 0.12);
    --shadow-card: 0 1px 2px rgba(16, 32, 54, 0.04),
        0 2px 8px rgba(16, 32, 54, 0.05);
    --shadow-card-hover: 0 6px 20px rgba(16, 32, 54, 0.1);
}

/* ---------- 2. Retheme the --ht-* tokens (override .ht-dark/.ht-light) ---------- */
html.ht-dark,
html.ht-light {
    --ht-bg: #f2f5f9;
    --ht-bg-secondary: #eef1f6;
    --ht-primary: #0e2748; /* sidebar / mobile nav */
    --ht-accent: #1e50a8; /* primary buttons */
    --ht-card: #ffffff;
    --ht-tile: #ffffff;
    --ht-tile-hover: #f4f6fa;
    --ht-text: #14202f;
    --ht-text-secondary: #3a4658;
    --ht-text-muted: #6b7787;
    --ht-border: rgba(16, 32, 54, 0.1);
    --ht-border-strong: rgba(16, 32, 54, 0.16);
    --ht-input-bg: #ffffff;
    --ht-input-border: rgba(16, 32, 54, 0.16);
    --ht-shadow-card: 0 2px 8px rgba(16, 32, 54, 0.06),
        0 1px 3px rgba(16, 32, 54, 0.05);
}

/* ---------- 3. Fix forced maroon/gold rules from header-theme.css ---------- */
html.ht-dark .btn-primary,
html.ht-light .btn-primary {
    color: #fff !important;
}
html.ht-dark .btn-primary:hover:not(:disabled),
html.ht-light .btn-primary:hover:not(:disabled) {
    filter: brightness(1.06);
}
.badge-primary {
    color: #fff !important;
}
/* Blue logo mark + avatar text legibility */
.nav-brand,
.navbar .nav-brand {
    color: #fff !important;
}
.nav-brand-logo {
    color: #fff !important;
    background: linear-gradient(135deg, #3f74d1, #1a48a0) !important;
}
.nav-avatar {
    color: #fff !important;
    background: linear-gradient(135deg, #3f74d1, #21519f) !important;
}

/* ---------- 4. Card / panel polish for light UI ---------- */
.card,
html.ht-dark .card,
html.ht-light .card {
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-lg);
}
.card:hover {
    box-shadow: var(--shadow-card-hover);
}
body {
    background: var(--color-bg);
    color: var(--color-text);
}

/* ============================================================
   5. LEFT SIDEBAR RAIL — desktop only (>=1025px)
   Below that, the original fixed top navbar + mobile nav
   behavior is left untouched.
   ============================================================ */
@media (min-width: 1025px) {
    .app-container {
        flex-direction: row !important;
        align-items: stretch !important;
    }

    .navbar {
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        height: 100vh;
        width: 224px;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 18px 12px;
        gap: 4px;
        background: linear-gradient(180deg, #0e2748, #0a1e39) !important;
        box-shadow: 1px 0 0 rgba(16, 32, 54, 0.06), var(--shadow-md);
    }

    .navbar .nav-brand {
        padding: 4px 8px 14px;
        font-size: var(--text-md);
    }

    .nav-toggle {
        display: none !important;
    }

    .nav-menu {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 3px;
        margin-top: 6px;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        justify-content: flex-start;
        width: 100%;
        border-radius: 10px;
        padding: 10px 12px;
        color: rgba(255, 255, 255, 0.74);
        font-size: var(--text-sm);
    }
    .nav-link:hover {
        background: rgba(255, 255, 255, 0.08);
        color: #fff;
    }
    .nav-link.active {
        background: rgba(63, 116, 209, 0.28) !important;
        color: #fff !important;
        box-shadow: none !important;
    }
    .nav-icon {
        width: 20px;
        text-align: center;
    }

    .nav-actions {
        margin-top: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-top: 12px;
    }
    #ht-theme-toggle {
        margin-right: 0 !important;
        justify-content: center;
        width: 100%;
    }
    .nav-user {
        justify-content: flex-start;
        width: 100%;
    }
    /* User dropdown opens upward from the bottom-anchored avatar */
    .navbar .dropdown-menu {
        bottom: calc(100% + 8px);
        top: auto;
    }

    /* Push page content to the right of the rail */
    main.main-content {
        margin-left: 224px !important;
        max-width: none !important;
        width: auto !important;
        padding: 24px 28px 48px !important;
    }
}

/* ---------- 6. Login / auth pages (index.html, reset-password.html) ---------- */
/* The navy header gradient needs white text (was relying on dark-theme白). */
.login-title {
    color: #fff !important;
}
.login-logo {
    color: #fff !important;
    background: linear-gradient(135deg, #3f74d1, #1a48a0) !important;
}
.login-links a {
    color: var(--color-primary) !important;
}

/* ============================================================
   8. COMPONENT POLISH — make the inner pages match the
   dashboard: rounded panels, soft shadows, clean tables.
   ============================================================ */

/* Page title sizing to match dashboard */
.page-title {
    font-size: 24px !important;
    letter-spacing: -0.4px;
}

/* Cards / panels */
.card,
html.ht-dark .card,
html.ht-light .card {
    background: #fff !important;
    border: 1px solid var(--color-border) !important;
    border-radius: 14px !important;
    box-shadow: var(--shadow-card);
}
.card-header {
    border-bottom: 1px solid var(--color-border-light) !important;
    padding-bottom: 12px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
}

/* Stat tiles (inventory, etc.) — dashboard tile look */
.stat-card,
html.ht-dark .stat-card,
html.ht-light .stat-card {
    background: #fff !important;
    border: 1px solid var(--color-border) !important;
    border-radius: 14px !important;
    padding: 16px 18px !important;
    box-shadow: var(--shadow-card) !important;
    position: relative;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover,
html.ht-dark .stat-card:hover,
html.ht-light .stat-card:hover {
    background: #fff !important;
    box-shadow: var(--shadow-card-hover) !important;
    transform: translateY(-1px);
}
.stat-card-icon {
    position: absolute !important;
    top: 14px;
    right: 16px;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    background: none !important;
    box-shadow: none !important;
    font-size: 19px !important;
    line-height: 1 !important;
}
.stat-card-value {
    font-size: 30px !important;
    font-weight: 800 !important;
    letter-spacing: -1px;
    color: var(--color-text) !important;
    margin: 0 !important;
}
.stat-card-label {
    font-size: 12px !important;
    color: var(--color-text-muted) !important;
    font-weight: 500 !important;
}

/* Tables — clean, light, dashboard-like */
.table {
    width: 100%;
    border-collapse: collapse;
}
.table thead th {
    text-align: left;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-subtle) !important;
    padding: 10px 14px !important;
    border-bottom: 1px solid var(--color-border) !important;
    background: transparent !important;
}
.table tbody td {
    padding: 12px 14px !important;
    border-bottom: 1px solid var(--color-border-light) !important;
    font-size: 13.5px;
    color: var(--color-text);
}
.table tbody tr {
    transition: background 0.12s ease;
}
.table tbody tr:hover {
    background: var(--color-surface-hover) !important;
}
.table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Filter bars */
.filter-bar,
.filter-bar-compact {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    padding: 10px 12px;
}

/* Buttons: slightly rounder to match dashboard */
.btn {
    border-radius: 10px;
}

/* Empty states */
.empty-state {
    color: var(--color-text-muted);
}

/* ============================================================
   9. MODALS vs. the mobile bottom nav
   Page modals and .mobile-bottom-nav both sat at z-index 200,
   and the nav (later in the DOM) painted over the modal's footer,
   hiding the Save button. Lift modals above the nav, hide the nav
   while a modal is open, and keep sheet footers clear of the iOS
   home indicator.
   ============================================================ */
.modal-backdrop.active,
.modal.active,
.modal-backdrop[style*="display: flex"],
.modal[style*="display: flex"] {
    z-index: 5000 !important;
}
body:has(.modal-backdrop.active) .mobile-bottom-nav,
body:has(.modal.active) .mobile-bottom-nav,
body:has(.modal-backdrop[style*="display: flex"]) .mobile-bottom-nav,
body:has(.modal[style*="display: flex"]) .mobile-bottom-nav {
    display: none !important;
}
.modal-sheet-footer,
.modal-footer {
    padding-bottom: calc(env(safe-area-inset-bottom) + 14px) !important;
}

/* ---------- 7. Scanner page (picklist.html) — no navbar, just color ---------- */
/* handled purely by the token retheme above */
