/* ============================================================
   HD Robotics Portal — shared theme layer
   Dark is the default (each page's authored :root). Light mode
   is applied via html[data-theme="light"], scoped per token
   family so overloaded names resolve correctly.
   ============================================================ */

/* ---------- NAVY family (index, crm, coldmail, selector) ----------
   --w = primary text, --mu = muted text */
html[data-theme="light"][data-theme-family="navy"] {
  --bg:  #EEF2F7;
  --bg2: #FFFFFF;
  --bg3: #F4F7FB;
  --w:   #0E1726;
  --mu:  #55637C;
  --bdr: rgba(15,23,42,0.12);
  --card: rgba(15,23,42,0.035);
  --card-h: rgba(15,23,42,0.075);
  --gdim: rgba(59,180,74,0.10);
  --gglow: rgba(59,180,74,0.18);
}

/* ---------- SLATE family (people, documents) ----------
   --text = primary text, --mu/--sub = muted text */
html[data-theme="light"][data-theme-family="slate"] {
  --bg:   #EEF2F7;
  --bg2:  #FFFFFF;
  --bg3:  #F4F7FB;
  --bg4:  #E9EEF5;
  --bdr:  rgba(15,23,42,0.12);
  --bdr2: rgba(15,23,42,0.18);
  --text: #0E1726;
  --sub:  rgba(15,23,42,0.50);
  --mu:   rgba(15,23,42,0.72);
}

/* ---------- CHARCOAL family (operations, inventory, meetings, todo, insights)
   --mu = ORANGE accent (keep), --text = primary text */
html[data-theme="light"][data-theme-family="charcoal"] {
  --bg:     #F4F5F7;
  --bg2:    #FFFFFF;
  --bg3:    #ECEEF2;
  --bdr:    #DCE0E7;
  --text:   #16181D;
  --sub:    #5A6472;
  --mu:     #EA6A0C;
  --card:   #FFFFFF;
  --border: #DCE0E7;
}

/* ---------- PRICING (authored light) — DARK is default -----------
   Flip authored light tokens to dark-brand for the default state.
   Light mode = original authored :root (no override). */
html[data-theme="dark"][data-theme-family="pricing"] {
  --txt:     #EAF1FF;
  --txt2:    #93A3BD;
  --bdr:     rgba(255,255,255,0.10);
  --surf:    #0B1424;
  --blue-lt: #12233F;
  --gbg:  rgba(34,197,94,0.14);  --gbdr: rgba(34,197,94,0.30);
  --ybg:  rgba(217,119,6,0.16);  --ybdr: rgba(217,119,6,0.34);
  --rbg:  rgba(220,38,38,0.16);  --rbdr: rgba(220,38,38,0.34);
}
html[data-theme="dark"][data-theme-family="pricing"] body { background: var(--brand-bg); }

/* Quote document (#print-view) always renders as light paper, both on
   screen preview and when printed, regardless of the portal theme. */
#print-view {
  --surf:    #FFFFFF;
  --txt:     #111827;
  --txt2:    #6B7280;
  --bdr:     #E5E7EB;
  --blue-lt: #EBF0FA;
  --gbg: #DCFCE7; --gbdr: #86EFAC;
  --ybg: #FEF3C7; --ybdr: #FCD34D;
  --rbg: #FEE2E2; --rbdr: #FCA5A5;
}
@media print { body { background: #FFFFFF !important; } }

/* ================= floating toggle button ================= */
#theme-toggle-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  font: 600 12.5px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: .01em;
  color: #E8EEF8;
  background: rgba(20, 28, 44, 0.82);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.32);
  cursor: pointer;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  transition: transform .14s ease, background .2s, border-color .2s, box-shadow .2s;
  user-select: none;
}
#theme-toggle-btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.30); }
#theme-toggle-btn:active { transform: translateY(0); }
#theme-toggle-btn .tt-icon { font-size: 14px; line-height: 1; }

html[data-theme="light"] #theme-toggle-btn {
  color: #17324F;
  background: rgba(255,255,255,0.92);
  border-color: rgba(15,23,42,0.14);
  box-shadow: 0 6px 22px rgba(15,23,42,0.16);
}

@media (max-width: 640px) {
  #theme-toggle-btn { right: 12px; bottom: 12px; padding: 8px 11px; }
  #theme-toggle-btn .tt-label { display: none; }
}
