/* ================================================================
   AutoGlass Tracking — Theme layer v1 (light + dark)
   Loaded by includes/header.php after style.css.
   <html data-theme="light|dark"> is set by the inline script in the header
   before the page paints. Without JS the attribute is missing and the
   original style.css look is used unchanged.
   ================================================================ */

/* ── LIGHT (refined) ─────────────────────────────────────────── */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #f3f5f9;
  --bg2:       #f8fafc;
  --card:      #ffffff;
  --line:      #e3e8ef;
  --line2:     #eef2f6;
  --text:      #0f172a;
  --text2:     #334155;
  --muted:     #64748b;
  --muted2:    #94a3b8;
  --brand:     #2563eb;
  --brand-h:   #1d4ed8;
  --brand-l:   #eff4ff;
  --nav:       #0b1220;
  --nav2:      #151e2e;
  --r:         10px;
  --r2:        14px;
  --r3:        18px;
  --sh:        0 1px 2px rgba(15,23,42,.05);
  --sh2:       0 2px 8px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --sh3:       0 18px 48px rgba(15,23,42,.14), 0 4px 12px rgba(15,23,42,.06);
}

/* ── DARK (matches the homepage dashboard mockup) ───────────── */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0d1320;
  --bg2:       #131b2a;
  --card:      #172031;
  --line:      #263247;
  --line2:     #1d2738;
  --text:      #e6ebf2;
  --text2:     #c4cdd9;
  --muted:     #8d9aae;
  --muted2:    #66748a;
  --brand:     #3b82f6;
  --brand-h:   #2f6fe0;
  --brand-l:   rgba(59,130,246,.14);
  --brand-dark:#0b1220;
  --success:   #34d399;
  --success-l: rgba(52,211,153,.12);
  --warn:      #fbbf24;
  --warn-l:    rgba(251,191,36,.12);
  --danger:    #f87171;
  --danger-l:  rgba(248,113,113,.12);
  --purple:    #a78bfa;
  --purple-l:  rgba(167,139,250,.13);
  --nav:       #0a0f1a;
  --nav2:      #121a28;
  --sh:        0 1px 2px rgba(0,0,0,.35);
  --sh2:       0 2px 10px rgba(0,0,0,.35);
  --sh3:       0 20px 50px rgba(0,0,0,.55), 0 4px 14px rgba(0,0,0,.35);
}
:root[data-theme="dark"] body { background: var(--bg); color: var(--text); }
:root[data-theme="dark"] ::selection { background: rgba(59,130,246,.35); }
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #66748a !important; opacity: 1; }
:root[data-theme="dark"] img:not([src$=".svg"]) { filter: none; }
:root[data-theme="dark"] .desktop-nav-dropdown { background: #182235; border-color: var(--line); }
:root[data-theme="dark"] .desktop-nav-dropdown a { color: var(--text2); }
:root[data-theme="dark"] .phone-drawer-panel { background: #121a28; }
:root[data-theme="dark"] .phone-drawer-link { color: var(--text2); }
:root[data-theme="dark"] .flash { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.35); color: #a7f3d0; }
:root[data-theme="dark"] .flash.error { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.35); color: #fecaca; }
:root[data-theme="dark"] .flash.warning { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.35); color: #fde68a; }
/* scrollbars */
:root[data-theme="dark"] * { scrollbar-color: #2b3850 transparent; }

/* While the dark re-tint runs, keep page content hidden for a moment (max ~1.2s failsafe). */
:root.agt-repainting main.container { opacity: 0; }
main.container { transition: opacity .12s ease; }

/* ── SHARED POLISH (both themes) ─────────────────────────────── */
:root[data-theme] body { letter-spacing: -.005em; }
:root[data-theme] .topnav {
  background: var(--nav);
  border-bottom: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
}
:root[data-theme] .topnav-brand { border-right-color: rgba(255,255,255,.08); }
:root[data-theme] .desktop-nav-primary > a,
:root[data-theme] .desktop-nav-group > summary { padding: 0 11px; }
:root[data-theme] .desktop-nav-primary > a.active::after { left: 8px; right: 8px; height: 2px; }
:root[data-theme] .desktop-nav-dropdown { border-radius: 12px; padding: 6px; }
:root[data-theme] .desktop-nav-dropdown a { border-radius: 8px; }

/* "+ New" quick-create group in the nav */
:root[data-theme] .desktop-nav-group-new > summary {
  height: 32px; margin: 0 6px 0 2px; padding: 0 12px; border-radius: 9px;
  background: var(--brand); color: #fff !important; font-weight: 700;
}
:root[data-theme] .desktop-nav-group-new > summary:hover { background: var(--brand-h); }
:root[data-theme] .desktop-nav-group-new > summary::after { opacity: .85; }
:root[data-theme] .desktop-nav-group-new .desktop-nav-dropdown { right: auto; left: 0; }

/* Theme switch (nav + phone drawer) */
.agt-theme-toggle {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin: 0 4px; flex-shrink: 0;
  border-radius: 9px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06); color: #e2e8f0;
  font-size: 15px; line-height: 1; cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
:root[data-theme] .agt-theme-toggle { display: inline-flex; }
.agt-theme-toggle:hover { background: rgba(255,255,255,.14); }
.agt-theme-toggle:active { transform: scale(.94); }
.agt-theme-toggle .agt-ico-sun,
:root[data-theme="dark"] .agt-theme-toggle .agt-ico-moon { display: none; }
:root[data-theme="dark"] .agt-theme-toggle .agt-ico-sun { display: inline; }
:root[data-theme] .agt-theme-toggle-mobile { display: none; }
@media (max-width: 900px) {
  :root[data-theme] .agt-theme-toggle-desktop { display: none; }
  :root[data-theme] .agt-theme-toggle-mobile { display: inline-flex; margin-left: auto; margin-right: 8px; }
  :root[data-theme] .topnav .menu-toggle { margin-left: 0; }
}
.phone-drawer-link.agt-theme-row { cursor: pointer; width: 100%; display: flex; justify-content: flex-start; text-align: left; border: 0; background: none; font: inherit; color: inherit; }

/* ── PHONE QUICK BAR (styles were missing from style.css) ───── */
/* Nov 13, 2026: page content and sticky action bars clear the fixed bottom nav.
   Clearance = nav (~62px) + 10px offset + 16px gap + iOS safe area.
   Scoped to pages that actually show .mobile-quickbar so desktop and the
   Super Admin console are unchanged. */
.mobile-quickbar { display: none; }
:root[data-theme] {
  --agt-mobile-quickbar-clear: calc(88px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 900px) {
  :root[data-theme] .mobile-quickbar {
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 900; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
    padding: 6px; border-radius: 16px;
    background: rgba(11,18,32,.94); border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 10px 30px rgba(0,0,0,.28);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  :root[data-theme] .mobile-quickbar-link {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 48px; padding: 4px 2px; border: 0; border-radius: 11px; background: transparent;
    color: rgba(226,232,240,.72); font: 600 10.5px/1.1 var(--font); cursor: pointer;
  }
  :root[data-theme] .mobile-quickbar-icon { font-size: 17px; line-height: 1; }
  :root[data-theme] .mobile-quickbar-link.active { background: rgba(59,130,246,.22); color: #fff; }
  :root[data-theme] body { padding-bottom: var(--agt-mobile-quickbar-clear); }
  :root[data-theme] body:has(.mobile-quickbar) {
    padding-bottom: var(--agt-mobile-quickbar-clear);
    scroll-padding-bottom: var(--agt-mobile-quickbar-clear);
  }
  :root[data-theme] body:not(:has(.mobile-quickbar)) { padding-bottom: 0; scroll-padding-bottom: 0; }
  :root[data-theme] body:has(.mobile-quickbar) .su-actions {
    bottom: var(--agt-mobile-quickbar-clear);
    z-index: 5;
  }
}

/* Top-bar menus must be able to drop out of the bar. This used to live only in
   admin_navbar_v2.css; when that file failed to load (installed PC app opened at a
   different address), every dropdown opened hidden behind the page. */
:root[data-theme] .topnav,
:root[data-theme] #siteNav,
:root[data-theme] .desktop-nav-main,
:root[data-theme] .desktop-nav-sections,
:root[data-theme] .desktop-nav-group { overflow: visible !important; }
:root[data-theme] .topnav { z-index: 1000; }
:root[data-theme] .desktop-nav-dropdown { z-index: 1001; }

/* Hide the old unused fixed "☰" button (it covered the brand on phones) */
.mobile-nav-toggle { display: none !important; }

/* ── PRINT: always light ─────────────────────────────────────── */
@media print {
  :root[data-theme] { color-scheme: light; --bg:#fff; --card:#fff; --text:#0f172a; --text2:#334155; --muted:#64748b; --line:#e2e8f0; }
  :root[data-theme] body { background: #fff !important; color: #0f172a !important; padding-bottom: 0 !important; }
  .mobile-quickbar, .agt-theme-toggle { display: none !important; }
}

/* Embedded invoice "paper" (invoice_renderer .wrap) always looks like the printed PDF */
:root[data-theme="dark"] .wrap.screen-mode,
:root[data-theme="dark"] .wrap.pdf-mode {
  color-scheme: light;
  color: #0f172a;
  --bg: #f1f5f9; --bg2: #f8fafc; --card: #fff; --line: #e2e8f0; --line2: #f1f5f9;
  --text: #0f172a; --text2: #334155; --muted: #64748b; --muted2: #94a3b8; --brand-l: #eff6ff;
}
