/* ============================================================================
   sf-theme.css — Salesforce Lightning-style reskin for tools.donttouch.in
   Loaded AFTER style.css. PURE OVERRIDE LAYER: no DOM, no IDs, no JS hooks
   touched — removing this one file fully reverts the app to the old look.
   Strategy:
   1. Retheme the CSS variables style.css is built on (colors, radii, shadows).
   2. Component polish (buttons, cards, tables, badges, toasts, forms, login).
   3. Desktop (≥1024px): the mobile bottom-nav becomes a Salesforce-style
      top tab bar under the header — position/layout only, handlers untouched.
   Dark mode: overrides use variables wherever colors matter, so the existing
   [data-theme] dark palette keeps working; only brand hues are re-pointed.
   ========================================================================== */

/* ---------- 1. TOKENS ---------- */
/* Shape tokens apply in BOTH light and dark mode */
:root {
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
}
/* Color tokens are LIGHT-MODE ONLY — :root:not([data-theme="dark"]) doesn't match
   while dark mode is active, so style.css's dark palette stays fully intact.
   (Plain :root here would out-cascade the dark palette and break dark mode.) */
:root:not([data-theme="dark"]) {
  --primary: #0176d3;            /* Salesforce brand blue */
  --primary-dark: #014486;
  --primary-light: #eef4ff;
  --bg: #f3f3f3;                 /* SLDS app background */
  --surface: #ffffff;
  --surface2: #fafaf9;
  --border: #e5e5e5;
  --border2: #c9c9c9;
  --text1: #181818;
  --text2: #444444;
  --text3: #706e6b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow: 0 2px 4px rgba(0, 0, 0, .08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .14);
}
[data-theme="dark"] {
  --primary: #1b96ff;            /* SLDS dark-mode brand */
  --primary-dark: #0176d3;
}

/* ---------- 2. GLOBAL ---------- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  letter-spacing: 0.01em;
}

/* App header: white bar with a Salesforce brand strip on top */
.app-header {
  border-top: 3px solid var(--primary);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  background: var(--surface);
}
.header-title { font-weight: 700; letter-spacing: -0.01em; }
.logo-icon, .header-logo { color: var(--primary); }
.icon-btn { border-radius: var(--radius-sm); }
.icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.search-input {
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface);
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(1, 118, 211, .18); outline: none; }

/* ---------- 3. BUTTONS (SLDS style) ---------- */
.btn { border-radius: 6px; }
/* size changes must not clobber the compact variants used in dense rows */
.btn:not(.btn-xs):not(.btn-sm) { font-size: 0.875rem; font-weight: 600; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--primary);
}
.btn-ghost:hover { background: var(--primary-light); }
.btn-danger { border-radius: 6px; }
.btn-xs, .btn-sm { border-radius: 5px; }

/* ---------- 4. CARDS & STATS ---------- */
.card, .stat-card, .device-card, .dispatch-card, .team-card, .quick-action-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card:hover, .device-card:hover, .dispatch-card:hover { box-shadow: var(--shadow); }
.stat-card { transition: box-shadow .12s, border-color .12s; }
.stat-card:hover { box-shadow: var(--shadow); }
.stat-value { font-weight: 700; letter-spacing: -0.02em; }
.stat-label { text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; color: var(--text3); }
.section-header { text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; color: var(--text2); font-weight: 700; }
.quick-action-btn:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.qa-icon { color: var(--primary); }

/* ---------- 5. TABLES / LIST ROWS ---------- */
.table-head {
  background: var(--surface2);
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--text3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.table-row { border-bottom: 1px solid var(--border); transition: background .1s; }
.table-row:hover { background: var(--primary-light); }
.audit-row { border-bottom: 1px solid var(--border); }
.platform-row { border-radius: var(--radius-sm); }

/* ---------- 6. BADGES (SLDS pills) ---------- */
.badge {
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  padding: 2px 10px;
}

/* ---------- 7. FORMS ---------- */
input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="tel"], input[type="date"], select, textarea {
  border-radius: 6px;
  border-color: var(--border2);
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="email"]:focus, input[type="tel"]:focus, input[type="date"]:focus,
select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(1, 118, 211, .18);
  outline: none;
}

/* ---------- 8. MODALS & MENUS (cosmetic only — positioning untouched) ---------- */
.modal-sheet { border: 1px solid var(--border); border-bottom: none; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 700; }
.more-menu-panel { border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.more-menu-item { border-radius: var(--radius-sm); }
.more-menu-item:hover { background: var(--primary-light); color: var(--primary); }

/* ---------- 9. TOASTS (SLDS notifications) ---------- */
.toast {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 4px;
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  color: var(--text1);
}
.toast-success { border-left-color: #2e844a; }
.toast-error { border-left-color: #ba0517; }
.toast-warn { border-left-color: #dd7a01; }
.toast-info { border-left-color: var(--primary); }

/* ---------- 10. LOGIN ---------- */
:root:not([data-theme="dark"]) .auth-page { background: linear-gradient(180deg, var(--primary-light) 0%, var(--bg) 45%); }
.auth-card {
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.auth-title { font-weight: 800; letter-spacing: -0.02em; }
.auth-subtitle { color: var(--text3); text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.08em; }

/* ---------- 11. EMPTY / ERROR STATES ---------- */
.empty-icon, .error-icon { opacity: 0.55; }
.empty-msg { color: var(--text3); }

/* ---------- 12. MOBILE BOTTOM NAV (restyle only) ---------- */
.bottom-nav { border-top: 1px solid var(--border); box-shadow: 0 -1px 3px rgba(0,0,0,.05); }
.nav-item.active { color: var(--primary); }

/* Injected module tabs (GPS Master / Customers / Transactions) — plain <a> elements
   appended into the nav by their modules, NOT .nav-item buttons.
   BELOW 1024px they become a slim MODULE-TAB STRIP docked directly above the native
   bottom nav: the 8 native buttons keep their full phone-width bar (nothing crowds),
   and the three module tabs stay visible and tappable on every screen size.
   position:fixed lifts them out of the nav's flex flow, so the native bar lays out
   exactly as if they were not in the DOM. Scoped to <1024px so it can never collide
   with the desktop top-tab treatment below. */
@media (max-width: 1023.98px) {
  .bottom-nav > a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: fixed;
    bottom: var(--nav-h);           /* nav is border-box: safe-area padding is INSIDE --nav-h */
    height: 38px;
    width: 33.334%;
    z-index: 99;                    /* under .bottom-nav (100); over page content */
    background: var(--surface2);
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, .04);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text2);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav > a:active { color: var(--primary); background: var(--primary-light); }
  #nav-gpsmaster    { left: 0; }
  #nav-customers    { left: 33.333%; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  #nav-transactions { left: auto; right: 0; }
  /* content must clear bottom nav + the new 38px module strip */
  .page-content { padding-bottom: calc(var(--nav-h) + 38px + 0.75rem); }
}

/* ---------- 13. DESKTOP ≥1024px: SALESFORCE TOP TAB BAR ---------- */
@media (min-width: 1024px) {
  /* the same nav element, same buttons, same handlers — just docked under the
     header as a horizontal Lightning tab bar */
  .bottom-nav {
    top: var(--header-h);
    bottom: auto;
    z-index: 99;   /* below .app-header (100) so header dropdowns stay clickable */
    height: 44px;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: stretch;
    gap: 2px;
    padding: 0 1rem;
    border-top: none;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    background: var(--surface);
  }
  .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 7px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text2);
    padding: 0 0.875rem;
    height: 100%;
    border-bottom: 3px solid transparent;
    border-radius: 0;
  }
  .nav-item:hover { color: var(--primary); background: var(--surface2); }
  .nav-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
  }
  .nav-icon { width: 15px; height: 15px; }
  /* injected module tabs get the exact same Lightning tab treatment on desktop */
  .bottom-nav > a {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 0 0 auto;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text2);
    padding: 0 0.875rem;
    height: 100%;
    border-bottom: 3px solid transparent;
    border-radius: 0;
  }
  .bottom-nav > a:hover { color: var(--primary); background: var(--surface2); border-bottom-color: var(--primary); }
  /* ---- SUB-TAB ROW: the "More" drawer becomes a permanent second tab bar ---- */
  /* Same buttons, same onclick handlers — the [hidden] attribute is overridden so the
     row is always visible; the backdrop and the "More" trigger are removed on desktop. */
  .nav-item[data-page="more"] { display: none; }
  .more-menu, .more-menu[hidden] {
    display: block !important;
    position: fixed;
    top: calc(var(--header-h) + 44px);
    left: 0; right: 0; bottom: auto;
    height: 40px;
    z-index: 98;
    background: transparent;
    pointer-events: none;          /* container is just a strip; panel re-enables */
  }
  .more-menu-backdrop { display: none !important; }
  .more-menu-panel {
    pointer-events: auto;
    position: static;
    width: 100%;
    height: 40px;
    max-height: none;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 2px;
    padding: 0 1rem;
    background: var(--surface2);
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    transform: none !important;
    opacity: 1 !important;          /* drawer fades to 0 when "closed" — sub-bar is always solid */
    visibility: visible !important;
    transition: none;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .more-menu-header { display: none; }
  .more-menu-item {
    flex: 0 0 auto;
    width: auto;                    /* drawer items are width:100% — kills the "one long button" */
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 0 0.75rem;
    height: 100%;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text2);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    white-space: nowrap;
  }
  .more-menu-item:hover { color: var(--primary); background: var(--surface); border-bottom-color: var(--primary); }
  .more-menu-item svg { width: 13px; height: 13px; flex: 0 0 auto; }

  /* content clears header + main tabs + sub-tabs */
  .page-content {
    padding-top: calc(var(--header-h) + 44px + 40px + 0.75rem);
    padding-bottom: 1.5rem;
  }
  .page-inner { max-width: 1220px; margin: 0 auto; }
}
