/* ═══════════════════════════════════════════════════════════════
   Locke Prime — Theme Token System
   public/css/theme.css  v1.0
   ───────────────────────────────────────────────────────────────
   Usage:
     1. Link this file in <head> BEFORE all other stylesheets.
     2. Add anti-flash script in <head> (see locke.html for example).
     3. Toggle dark/light by setting data-theme="dark"|"light" on <html>.
     4. Theme toggle button saves to localStorage key "lp-theme".
   ═══════════════════════════════════════════════════════════════ */

/* ── Shared (both modes) ──────────────────────────────────────── */
:root {
  /* Sidebar always dark in both modes */
  --sidebar-bg:      #0d0f14;
  --sidebar-border:  rgba(255,255,255,0.05);

  /* Brand */
  --brand-logo:      #ffffff;
  --brand-prime:     #c9a84c;

  /* Gold accent (primary — used for active nav, CTA borders) */
  --gold:            #c9a84c;
  --gold2:           #d4b560;
  --gold3:           #a8882a;
  --gold-dim:        rgba(201,168,76,0.12);

  /* Teal accent (success, active status chips) */
  --teal:            #3db9a0;
  --teal2:           #2a9d87;
  --teal-dim:        rgba(61,185,160,0.10);

  /* Semantic status */
  --ok:              #3da86e;
  --warn:            #d4774a;
  --bad:             #d44e4e;

  /* AI accent */
  --ai:              #7b6ef6;
  --ai2:             #6358d4;

  /* Deadline / calendar type colors */
  --event-hearing:      #4a8fe0;
  --event-conference:   #3db9a0;
  --event-deadline:     #d44e4e;
  --event-other:        #8a8fa8;

  /* Typography scale */
  --font-sans:    'Times New Roman', Times, serif;
  --font-mono:    'JetBrains Mono','Cascadia Code','Fira Code',
                  'Menlo','Consolas',monospace;
  --font-serif:   'Times New Roman',Times,Georgia,serif;

  /* Sidebar width */
  --sidebar-w:    240px;

  /* Shadows (adjusted per mode below) */
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.08);
  --shadow:       0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.14);
}

/* ── Light mode ───────────────────────────────────────────────── */
:root,
[data-theme="light"] {
  --bg:           #f8f6f1;
  --surface:      #ffffff;
  --surface2:     #f4f1ec;
  --surface3:     #ede9e1;

  --text:         #1a1c24;
  --text-muted:   #6b6860;
  --text-faint:   #a09890;

  --border:       #e2ddd6;
  --border2:      #cec8be;

  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06);
  --shadow:       0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.12);

  /* backward-compat aliases for pages still using old names */
  --navy:         #1a1c24;
  --navy2:        #0d0f14;
  --navy3:        #252a38;
  --muted:        #6b6860;
  --muted2:       #a09890;
}

/* ── Dark mode ────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #111318;
  --surface:      #1a1d24;
  --surface2:     #1f2330;
  --surface3:     #252a38;

  --text:         #e8eaf0;
  --text-muted:   #8a8fa8;
  --text-faint:   #4f5570;

  --border:       #252932;
  --border2:      #2e3445;

  --shadow-sm:    0 2px 8px rgba(0,0,0,0.40);
  --shadow:       0 4px 20px rgba(0,0,0,0.50);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.60);

  /* backward-compat aliases — nav/heading uses of --navy become gold in dark mode */
  --navy:         #c9a84c;
  --navy2:        #0d0f14;
  --navy3:        #252a38;
  --muted:        #8a8fa8;
  --muted2:       #4f5570;
}

/* ── Global reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Sidebar shell ────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Brand */
.brand { padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.brand .l1 { display: flex; align-items: baseline; gap: 6px; }
.brand .locke {
  color: var(--brand-logo);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.5px;
  font-family: var(--font-sans);
}
.brand .prime {
  color: var(--brand-prime);
  font-size: 9px;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  font-weight: 600;
}

/* Nav section label (top page label) */
.label { padding: 12px 20px 8px; }
.label .t {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.30);
  font-weight: 600;
}

/* Nav group headers inside the nav */
.nav-group {
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  font-weight: 600;
  padding: 14px 12px 5px;
  pointer-events: none;
  user-select: none;
}

/* Nav links */
.nav { flex: 1; overflow: auto; padding: 10px 8px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,0.62);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 1px;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav a:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.90);
}
.nav a.active {
  background: rgba(201,168,76,0.10);
  color: #fff;
}
.nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}
.nav .divider {
  height: 1px;
  background: rgba(255,255,255,0.05);
  margin: 6px 10px;
}

/* ── Lucide icons in sidebar nav ──────────────────────────────── */
.nav a i[data-lucide], .nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  display: block;
}
/* Mobile bottom nav icon fallback when lucide hasn't fired */
.mn-icon i[data-lucide]:not(svg) {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: currentColor;
  opacity: 0.35;
  border-radius: 3px;
  vertical-align: middle;
}

/* User footer */
.user {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d3060, #a8882a);
  border: 1.5px solid rgba(201,168,76,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  font-weight: 800;
  font-size: 11px;
  position: relative;
  flex-shrink: 0;
}
.dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--sidebar-bg);
}
.uinfo { min-width: 0; flex: 1; }
.uname {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.urole {
  font-size: 10px;
  color: rgba(255,255,255,0.32);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Theme toggle in sidebar footer */
.theme-toggle {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.11);
  color: rgba(255,255,255,0.85);
}

/* ── Shell layout ─────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  flex-shrink: 0;
}
.title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.title small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 13px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border2); background: var(--surface2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1000;
  font-weight: 700;
}
.btn.primary:hover { background: var(--gold2); border-color: var(--gold2); }

.btn.danger {
  border-color: rgba(212,78,78,0.25);
  color: var(--bad);
  background: rgba(212,78,78,0.04);
}
.btn.danger:hover { border-color: rgba(212,78,78,0.45); background: rgba(212,78,78,0.08); }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.ch {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.h {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

/* ── Tables ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface2); }
th {
  padding: 9px 16px;
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
td { padding: 10px 16px; font-size: 13px; vertical-align: middle; }

/* ── Tags / pills ─────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.tag.ok  { background: rgba(61,168,110,0.13); color: var(--ok); }
.tag.warn{ background: rgba(212,119,74,0.13); color: var(--warn); }
.tag.bad { background: rgba(212,78,78,0.13);  color: var(--bad); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface2);
  font-size: 12px;
  color: var(--text-muted);
}
.pill .b { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }

/* ── KPI cards ────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
}
.kpi-teal::before   { background: var(--teal); }
.kpi-gold::before   { background: var(--gold); }
.kpi-orange::before { background: var(--warn); }
.kpi-red::before    { background: var(--bad); }

.kpi-icon { font-size: 22px; line-height: 1; margin-top: 2px; }
.kpi-lbl {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 5px;
}
.kpi-n {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.kpi-s { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Misc utilities ───────────────────────────────────────────── */
.muted   { color: var(--text-muted); font-size: 12px; }
.mono    { font-family: var(--font-mono); font-size: 12px; }
.err     { color: var(--bad); font-weight: 700; }
.note    { font-size: 12px; color: var(--text-muted); padding: 12px 18px; border-top: 1px solid var(--border); line-height: 1.5; }
.badge   { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; background: var(--bad); border-radius: 999px; font-size: 10px; font-weight: 800; color: #fff; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.bell    { position: relative; }

/* ── Input fields ─────────────────────────────────────────────── */
input, select, textarea {
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
}
input::placeholder, textarea::placeholder {
  color: var(--text-faint);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 980px) {
  .sidebar { display: none; }
  .shell   { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  html, body { overflow: auto; }
  .shell     { height: auto; min-height: 100vh; }
  .topbar    { padding: 0 12px; flex-wrap: wrap; min-height: 52px; height: auto; gap: 8px; }
  .title     { font-size: 15px; }
  .kpi-row   { grid-template-columns: repeat(2, 1fr); }
}
