/* ============================================================================
   JOOT DESIGN SYSTEM v1 — standalone stylesheet
   ============================================================================
   Drop-in stylesheet that gives any HTML page the full JOOT design system:
   tokens (spacing/typography/colors/radii/shadows/transitions) plus the
   canonical .joot-* component classes. Loaded by:
     - web/index.html       (admin app — main app)
     - web/employee-portal.html (mechanic/driver portal — self-contained page)

   Pages that already load web/css/style.css (which has its own copy of this
   block) double-link safely — same rules, last wins, no visible effect.

   USAGE EXAMPLES:

   <section class="joot-section">
     <h2 class="joot-section-header">My Section</h2>

     <div class="joot-stats-row">
       <div class="joot-stat-card">
         <div class="joot-stat-card-label">Active mechanics</div>
         <div class="joot-stat-card-value">12</div>
         <div class="joot-stat-card-sub">all clocked in today</div>
       </div>
     </div>

     <div class="joot-card">
       <div class="joot-card-title"><span class="joot-card-title-text">🔧 Mechanic balances</span></div>
       <div class="joot-metric-list">
         <div class="joot-metric"><span>Alejandro</span><span class="joot-metric-value">120 pts</span></div>
       </div>
     </div>

     <div class="joot-tile-strip">
       <button class="joot-tile">Mode A</button>
       <button class="joot-tile joot-tile-active">Mode B</button>
     </div>

     <div class="joot-empty">
       <div class="joot-empty-icon">📭</div>
       <div class="joot-empty-title">Nothing here yet</div>
       <div class="joot-empty-sub">When mechanics earn points, they'll show up here.</div>
     </div>
   </section>
   ============================================================================ */

/* --- Design tokens (extends/overrides whatever the page :root has) ----- */
:root {
    --bg-dark: #111111;
    --bg-card: #1a1a1a;
    --bg-input: #0d0d0d;
    --bg-card-hover: #1f1f1f;
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a0;
    --text-muted: #6a6a6a;
    --accent: #9a7b1a;
    --accent-hover: #b8952e;
    --accent-dim: rgba(154, 123, 26, 0.18);
    --success: #4ecca3;
    --warning: #ffc107;
    --danger: #e94560;
    --info: #4fc3f7;
    --border: #2a2a2a;
    --border-strong: #3a3a3a;
    --border-faint: #1f1f1f;
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
    --text-xs: 0.7rem;  --text-sm: 0.8rem; --text-md: 0.9rem; --text-base: 1rem;
    --text-lg: 1.15rem; --text-xl: 1.4rem; --text-2xl: 1.8rem; --text-3xl: 2.4rem;
    --weight-normal: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;
    --radius-sm: 4px; --radius: 8px; --radius-lg: 12px; --radius-full: 999px;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.25);
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
    --transition: 150ms ease;
    --transition-slow: 280ms ease;
}

/* --- Sections + section headers --------------------------------------- */
.joot-section { padding: var(--space-5); max-width: 1400px; margin: 0 auto; }
.joot-section + .joot-section { padding-top: 0; }
.joot-section-header {
    font-size: var(--text-xl); font-weight: var(--weight-semibold);
    color: var(--text-primary); margin: 0 0 var(--space-4) 0;
    padding: 0 0 var(--space-3) 0; border-bottom: 1px solid var(--border-faint);
    display: flex; align-items: center; gap: var(--space-3); position: relative;
}
.joot-section-header::before {
    content: ""; display: inline-block; width: 4px; height: 18px;
    background: var(--accent); border-radius: 2px; flex-shrink: 0;
}

/* --- Cards ------------------------------------------------------------ */
.joot-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: var(--space-4);
    margin-bottom: var(--space-4); transition: border-color var(--transition);
}
.joot-card:hover { border-color: var(--border-strong); }
.joot-card-elevated { box-shadow: var(--shadow); }
.joot-card-title {
    font-size: var(--text-xs); font-weight: var(--weight-semibold);
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-secondary); margin: 0 0 var(--space-4) 0;
    padding: 0 0 var(--space-2) 0; border-bottom: 1px solid var(--border-faint);
    display: flex; align-items: center; gap: var(--space-2);
}
.joot-card-title::before {
    content: ""; width: 3px; height: 12px; background: var(--accent);
    border-radius: 1px; flex-shrink: 0;
}
.joot-card-title-text { flex: 1; }
.joot-card-title-meta {
    font-size: var(--text-xs); color: var(--text-muted);
    font-weight: var(--weight-normal); text-transform: none; letter-spacing: 0;
}

/* --- Metric rows ------------------------------------------------------ */
.joot-metric-list { display: flex; flex-direction: column; gap: var(--space-1); }
.joot-metric {
    display: flex; align-items: baseline; gap: var(--space-2);
    padding: var(--space-2) 0; font-size: var(--text-md);
    border-bottom: 1px dotted var(--border-faint);
}
.joot-metric:last-child { border-bottom: none; }
.joot-metric > :first-child { color: var(--text-secondary); white-space: nowrap; }
.joot-metric-value {
    color: var(--text-primary); font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums; text-align: right; margin-left: auto;
}
.joot-metric-value-accent  { color: var(--accent); }
.joot-metric-value-success { color: var(--success); }
.joot-metric-value-warning { color: var(--warning); }
.joot-metric-value-danger  { color: var(--danger); }

/* --- COLOR DISCIPLINE (read before adding -success/-warning/-danger/-info) -
   The default .joot-stat-card-value color is brand gold. KEEP IT GOLD unless
   the metric carries a real semantic meaning. Multiple semantic colors in one
   row turn the page into a Christmas tree — the owner flagged this 2026-05-27.

   Use semantic variants ONLY when:
   - success (green) — number you want to GROW: cash position, revenue, won
     deals, pipeline value, accepted estimates, matched receipts, applied
     credit memos. "More = better."
   - warning (yellow) — number that NEEDS ATTENTION soon: today's follow-ups,
     PMs due now, AR (someone owes you), partial / processing / expired states.
   - danger (red) — number that is BAD if non-zero: overdue items, hot leads
     not yet contacted, AP outstanding, critical repairs, errors.
   - info (blue) — rarely. Most "info" cards are really just counts → use gold.

   Pure-count cards ("12 active mechanics", "144 equipment units", "1222 AI
   knowledge items") should ALL be gold. Workflow status cards (Draft / Sent /
   etc) should mostly be gold unless one stage is a clear good/bad outcome.
   --------------------------------------------------------------------- */

/* --- Stats row --------------------------------------------------------- */
.joot-stats-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-3); margin-bottom: var(--space-5);
}
.joot-stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: var(--space-4);
    transition: border-color var(--transition), transform var(--transition);
}
.joot-stat-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.joot-stat-card-label {
    font-size: var(--text-xs); color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--space-2);
    display: flex; align-items: center; gap: 6px;
}
/* Lucide icon embedded in a stat-card label — small, monoline, BRIGHT
   white against the dim gray uppercase label so the icon reads as the
   visual anchor for the metric. See docs/DESIGN_SYSTEM.md "Icon rule". */
.joot-stat-card-label .joot-label-icon,
.joot-stat-card-label svg {
    width: 14px; height: 14px;
    stroke-width: 2;
    color: var(--text-primary);
    flex-shrink: 0;
}
.joot-stat-card-value {
    font-size: var(--text-2xl); font-weight: var(--weight-bold);
    color: var(--accent); line-height: 1.1; font-variant-numeric: tabular-nums;
}
.joot-stat-card-value-success { color: var(--success); }
.joot-stat-card-value-warning { color: var(--warning); }
.joot-stat-card-value-danger  { color: var(--danger); }
.joot-stat-card-value-info    { color: var(--info); }
.joot-stat-card-sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); }

/* --- Empty states ----------------------------------------------------- */
.joot-empty {
    text-align: center; padding: var(--space-7) var(--space-4);
    color: var(--text-secondary); border: 1px dashed var(--border);
    border-radius: var(--radius); background: var(--bg-input);
}
.joot-empty-icon { font-size: 2.4rem; margin-bottom: var(--space-3); }
.joot-empty-title {
    font-size: var(--text-base); color: var(--text-primary);
    font-weight: var(--weight-semibold); margin-bottom: var(--space-2);
}
.joot-empty-sub {
    font-size: var(--text-sm); color: var(--text-secondary);
    max-width: 400px; margin: 0 auto; line-height: 1.5;
}
.joot-empty-cta { margin-top: var(--space-4); }

/* --- Tile strip ------------------------------------------------------- */
.joot-tile-strip {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-2); padding: var(--space-3) 0;
    background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
}
.joot-tile {
    background: transparent; border: 1px solid transparent; color: var(--text-secondary);
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
    cursor: pointer; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
    transition: all var(--transition); font-size: var(--text-md); min-height: 64px;
}
.joot-tile:hover { background: var(--accent-dim); color: var(--text-primary); }
.joot-tile-active, .joot-tile.active {
    background: var(--accent); color: #111; font-weight: var(--weight-semibold);
}
.joot-tile-icon  { font-size: 1.4rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
/* Tile icons read as the visual anchor for each tile — gold by default,
   inherit (= #111 black) when the tile is active so they sit on gold bg. */
.joot-tile-icon svg {
    width: 22px; height: 22px;
    stroke-width: 2;
    color: var(--accent);
}
.joot-tile:hover .joot-tile-icon svg { color: var(--accent-hover); }
.joot-tile-active .joot-tile-icon svg,
.joot-tile.active .joot-tile-icon svg { color: inherit; }
.joot-tile-label { font-size: var(--text-xs); }

/* Empty-state icon — Lucide icon sized large + slightly dimmed so the
   icon feels intentional (not loud) on otherwise empty space. */
.joot-empty-icon svg {
    width: 38px; height: 38px;
    stroke-width: 1.5;
    color: var(--text-primary);
    opacity: 0.55;
}

/* Heading icons (h2/h3/h4 with leading emoji replaced by Lucide).
   Sized to match the heading font, inherits text color so it tonally
   matches the heading. The .joot-h-accent gold bar pseudo still leads. */
.joot-heading-icon,
h2 .joot-heading-icon, h3 .joot-heading-icon, h4 .joot-heading-icon {
    display: inline-flex; align-items: center; justify-content: center;
    vertical-align: -2px;
}
h2 .joot-heading-icon svg { width: 22px; height: 22px; stroke-width: 2; color: var(--accent); }
h3 .joot-heading-icon svg { width: 18px; height: 18px; stroke-width: 2; color: var(--accent); }
h4 .joot-heading-icon svg { width: 16px; height: 16px; stroke-width: 2; color: var(--accent); }

/* Card-title icons (inside .joot-card-title-text). The card-title bar
   already has a 3x12 accent stripe via ::before; the icon sits beside it. */
.joot-title-icon {
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 4px; vertical-align: -2px;
}
.joot-title-icon svg {
    width: 14px; height: 14px;
    stroke-width: 2; color: var(--accent);
}

/* Button icons — sized to match button text, inherits button color. */
.joot-btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    vertical-align: -2px;
}
.joot-btn-icon svg {
    width: 14px; height: 14px;
    stroke-width: 2; color: inherit;
}

/* --- Buttons (canonical) --------------------------------------------- */
.joot-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--space-2); padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm); font-size: var(--text-md);
    font-weight: var(--weight-semibold); cursor: pointer;
    border: 1px solid transparent; transition: all var(--transition);
    min-height: 36px; text-decoration: none; font-family: inherit;
}
.joot-btn-primary   { background: var(--accent); color: #111; }
.joot-btn-primary:hover { background: var(--accent-hover); }
.joot-btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border); }
.joot-btn-secondary:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.joot-btn-danger    { background: transparent; color: var(--danger); border-color: var(--danger); }
.joot-btn-danger:hover { background: rgba(233, 69, 96, 0.1); }
.joot-btn-success   { background: var(--success); color: #111; }
.joot-btn-success:hover { filter: brightness(1.1); }
.joot-btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); min-height: 28px; }

/* --- Badges (small status chips) -------------------------------------- */
.joot-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px var(--space-2); border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: var(--weight-semibold);
    background: var(--border); color: var(--text-secondary);
}
.joot-badge-accent  { background: var(--accent-dim); color: var(--accent); }
.joot-badge-success { background: rgba(78, 204, 163, 0.15); color: var(--success); }
.joot-badge-warning { background: rgba(255, 193, 7, 0.15); color: var(--warning); }
.joot-badge-danger  { background: rgba(233, 69, 96, 0.15); color: var(--danger); }
.joot-badge-info    { background: rgba(79, 195, 247, 0.15); color: var(--info); }

/* --- Tables (canonical) ---------------------------------------------- */
.joot-table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.joot-table thead th {
    text-align: left; padding: var(--space-2) var(--space-3);
    background: var(--bg-input); color: var(--text-secondary);
    font-size: var(--text-xs); font-weight: var(--weight-semibold);
    text-transform: uppercase; letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}
.joot-table tbody td { padding: var(--space-3); border-bottom: 1px solid var(--border-faint); }
.joot-table tbody tr:hover td { background: var(--bg-card-hover); }
.joot-table tbody tr:last-child td { border-bottom: none; }
.joot-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Pagination (numbered page controls: 1 2 3 … Prev/Next) --------- */
.joot-pagination {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: var(--space-3);
    padding: var(--space-3) var(--space-1); margin-top: var(--space-2);
}
.joot-pagination-info { color: var(--text-secondary); font-size: var(--text-sm); }
.joot-pagination-btns { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.joot-page-btn {
    min-width: 34px; padding: 6px 10px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text-primary);
    border-radius: var(--radius-sm, 6px); font-size: var(--text-sm); cursor: pointer;
}
.joot-page-btn:hover:not(:disabled):not(.active) { background: var(--bg-card-hover); }
.joot-page-btn.active {
    background: var(--primary); border-color: var(--primary);
    color: #1a1a1a; font-weight: var(--weight-semibold);
}
.joot-page-btn:disabled { opacity: 0.4; cursor: default; }
.joot-page-ellipsis { padding: 0 4px; color: var(--text-secondary); }

/* --- Sidebar icons (Armoury Crate-style inlaid, no badge) ------------
   Each leading emoji has been replaced with a Lucide SVG icon via
   <i data-lucide="..."> at build time. Icons sit flush in the row
   (no background tile) — bright white by default with dimmer labels,
   so the icon is the visual anchor and the text is supporting copy.
   Active/hover use the JOOT gold to stay on-brand without a box. */
.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-right: 14px;
    color: var(--text-primary);   /* bright white by default */
    transition: color var(--transition);
    /* Fallback for browsers where Lucide failed to load: render the
       original emoji (kept in data-emoji=) instead of a blank box. */
    font-variant-emoji: text;
    font-size: 1.05em;
    line-height: 1;
}
.sidebar-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
    /* Inherit color from parent so :hover / .active rules cascade. */
    color: inherit;
}
/* Dim the label text so the icon reads as the primary anchor. */
.sidebar li,
.sidebar .nav-parent-header { color: var(--text-secondary); }
.sidebar li:hover,
.sidebar .nav-parent-header:hover { color: var(--text-primary); }
.sidebar li:hover .sidebar-icon,
.sidebar .nav-parent-header:hover .sidebar-icon,
.sidebar .nav-submenu li:hover .sidebar-icon { color: var(--accent-hover); }
/* Active state: gold gradient bg + 3px gold edge carry the brand —
   icon goes bright white to sit on the gold wash. See style.css and
   docs/DESIGN_SYSTEM.md "Active state". */
.sidebar li.active > .sidebar-icon,
.sidebar .nav-submenu li.active > .sidebar-icon { color: var(--text-primary); }
/* When Lucide hasn't loaded (offline / CDN block), show the data-emoji
   fallback so we never end up with empty white squares in the sidebar. */
.sidebar-icon:empty::before { content: attr(data-emoji); }

/* --- Sidebar section header (admin app only — harmless on other pages) -- */
.sidebar li.joot-sidebar-section {
    font-size: 0.62rem; font-weight: var(--weight-bold);
    text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--text-muted); padding: var(--space-4) var(--space-4) var(--space-2);
    cursor: default; border-radius: 0; margin: 0; list-style: none;
}
.sidebar li.joot-sidebar-section:hover { background: transparent; color: var(--text-muted); }
.sidebar li.joot-sidebar-section:first-child { padding-top: var(--space-3); }

/* --- Forms (lightweight inputs that match the dark theme) ------------- */
.joot-input, .joot-select, .joot-textarea {
    background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3); font-size: var(--text-md);
    font-family: inherit; width: 100%; transition: border-color var(--transition);
}
.joot-input:focus, .joot-select:focus, .joot-textarea:focus { outline: none; border-color: var(--accent); }
.joot-label {
    display: block; font-size: var(--text-xs); font-weight: var(--weight-semibold);
    color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: 0.05em; margin-bottom: var(--space-1);
}

/* --- Heading accent (lightweight alternative to .joot-section-header
       when an h2 is already inside a flex-row layout like .view-header
       and we don't want to disturb the layout — just add the accent bar). */
.joot-h-accent {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.joot-h-accent::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 22px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

/* --- Utility helpers used across the system -------------------------- */
.joot-flex         { display: flex; }
.joot-flex-between { display: flex; justify-content: space-between; align-items: center; }
.joot-flex-end     { display: flex; justify-content: flex-end; align-items: center; }
.joot-gap-2 { gap: var(--space-2); }
.joot-gap-3 { gap: var(--space-3); }
.joot-gap-4 { gap: var(--space-4); }
.joot-mt-2 { margin-top: var(--space-2); }
.joot-mt-3 { margin-top: var(--space-3); }
.joot-mt-4 { margin-top: var(--space-4); }
.joot-mb-2 { margin-bottom: var(--space-2); }
.joot-mb-3 { margin-bottom: var(--space-3); }
.joot-mb-4 { margin-bottom: var(--space-4); }
.joot-text-muted     { color: var(--text-muted); }
.joot-text-secondary { color: var(--text-secondary); }
.joot-text-success   { color: var(--success); }
.joot-text-danger    { color: var(--danger); }
.joot-text-accent    { color: var(--accent); }
.joot-text-xs        { font-size: var(--text-xs); }
.joot-text-sm        { font-size: var(--text-sm); }
.joot-truncate       { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
