/* =====================================================================
   ELECTRICAL ENGINEER PRO — DESIGN TOKENS
   A technical "single-line diagram" identity: graphite/blueprint
   background, amber for actions, circuit-teal for live computed
   values, monospace readouts styled like a digital meter.

   THEME SYSTEM: every color below is a CSS variable. Dark is the
   default (:root). Adding data-theme="light" on <html> (done by
   assets/js/theme-toggle.js) swaps every variable at once — nothing
   else in this file needs to change between themes.
   ===================================================================== */

:root {
  --bg: #0f1720;
  --panel: #16202b;
  --panel-raised: #1b2733;
  --line: #243140;
  --text: #e7ecf0;
  --text-muted: #8fa3b3;
  --amber: #f2a93b;
  --amber-dim: #c98a2c;
  --teal: #3fc7b0;
  --danger: #e15554;
  --focus-ring: rgba(242, 169, 59, 0.15);
  --radius: 6px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-glow-amber: 0 0 0 1px rgba(242, 169, 59, 0.25), 0 4px 14px rgba(242, 169, 59, 0.15);

  /* Always-bright, theme-invariant accent for the "device display"
     elements (meter readout, live circuit lines) whose backing
     surface stays dark in both themes — see those rules below. */
  --accent-glow: #3fc7b0;
}

/* ---------- Light theme overrides ---------- */
[data-theme="light"] {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-raised: #f7f9fb;
  --line: #d7dee4;
  --text: #1b2530;
  --text-muted: #5b6b78;
  --amber: #b9730e;
  --amber-dim: #9c5f0a;
  --teal: #0e8a76;
  --danger: #c0392b;
  --focus-ring: rgba(185, 115, 14, 0.18);
  --shadow-sm: 0 1px 2px rgba(27, 37, 48, 0.06);
  --shadow-md: 0 10px 28px -6px rgba(27, 37, 48, 0.14), 0 2px 8px rgba(27, 37, 48, 0.08);
  --shadow-glow-amber: 0 0 0 1px rgba(185, 115, 14, 0.18), 0 4px 14px rgba(185, 115, 14, 0.12);
}

* { box-sizing: border-box; }

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.6;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

h1, h2, h3, h4, h5, .display-font {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.display-5 { font-size: clamp(1.9rem, 1.4rem + 2vw, 3rem); line-height: 1.12; }

p { line-height: 1.7; }

.font-mono { font-family: 'IBM Plex Mono', monospace; }

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

a { color: var(--teal); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--amber); }

/* ---------- Theme toggle button ---------- */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle-btn:hover { border-color: var(--amber); color: var(--amber); }
.theme-toggle-btn svg { width: 18px; height: 18px; }
[data-theme="dark"] .theme-toggle-btn .icon-moon { display: none; }
[data-theme="light"] .theme-toggle-btn .icon-sun { display: none; }

/* ---------- Busbar navigation ---------- */
.busbar-nav {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.busbar-nav .navbar-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--text) !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.busbar-nav .navbar-brand .node-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}

.busbar-nav .nav-link {
  color: var(--text-muted) !important;
  position: relative;
  padding: 0.6rem 1rem !important;
}

.busbar-nav .nav-link::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--line);
  transform: translateY(-50%);
}

.busbar-nav .nav-link:hover,
.busbar-nav .nav-link.active {
  color: var(--amber) !important;
}

/* ---------- Panels / Cards ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.panel-raised {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.category-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.25s var(--ease);
  height: 100%;
}

.category-card:hover {
  border-color: var(--amber-dim);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.category-card .count {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--teal);
  font-size: 0.85rem;
}

/* ---------- Buttons ---------- */
.btn-amber {
  background: var(--amber);
  border: none;
  color: #1a1206;
  font-weight: 600;
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow-amber);
  transition: background-color 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.btn-amber:hover { background: var(--amber-dim); color: #0d0a04; transform: translateY(-1px); }
.btn-amber:active { transform: translateY(0); }
.btn-amber:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.btn-outline-line {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.btn-outline-line:hover { border-color: var(--amber); color: var(--amber); background: var(--panel-raised); }
.btn-outline-line:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- Forms ---------- */
.form-control, .form-select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.form-control:focus, .form-select:focus {
  background: var(--bg);
  color: var(--text);
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.form-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Meter-style result readout (signature element) ----------
   Deliberately stays a dark "instrument display" in BOTH themes —
   like a calculator's LCD — so it uses the invariant --accent-glow
   rather than the theme-adaptive --teal. */
.meter-readout {
  background: #0a1118;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-glow);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5);
}
.meter-readout .meter-label {
  color: #8fa3b3;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meter-readout .meter-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.9rem;
  color: var(--accent-glow);
  line-height: 1.2;
}
.meter-readout .meter-unit {
  font-family: 'IBM Plex Mono', monospace;
  color: #8fa3b3;
  font-size: 1rem;
  margin-left: 4px;
}

.formula-tag {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--amber);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ---------- Diagnosis wizard ---------- */
.diagnosis-question {
  font-size: 1.3rem;
  font-family: 'Space Grotesk', sans-serif;
}

.alert-leaf {
  border-left: 3px solid var(--danger);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Hero schematic illustration ----------
   The "live current" lines stay the invariant glow color on purpose —
   same reasoning as the meter readout above. */
.hero-schematic {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.hero-schematic .schematic-line {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
}

.hero-schematic .schematic-line-live {
  fill: none;
  stroke: var(--accent-glow);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  animation: dash-flow 3s linear infinite;
}

.hero-schematic .schematic-node {
  fill: var(--bg);
  stroke: var(--amber);
  stroke-width: 2;
}

.hero-schematic .schematic-label {
  fill: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
}

@keyframes dash-flow {
  to { stroke-dashoffset: -48; }
}

/* ---------- Feature cards (icon + title + copy) ---------- */
.feature-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  height: 100%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}
.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--amber-dim);
}

.feature-card .feature-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--amber);
  margin-bottom: 1rem;
}

/* ---------- CTA band ---------- */
.cta-band {
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* =====================================================================
   BOOTSTRAP OVERRIDES — neutralize the handful of Bootstrap utility
   classes used in admin views (table-dark, text-light) that otherwise
   force fixed colors and would break in light mode. Everything else
   in the views uses our own classes/variables above, which already
   adapt automatically.
   ===================================================================== */
.table-dark,
.table-dark > :not(caption) > * > * {
  background-color: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

.text-light {
  color: var(--text) !important;
}

/* ---------- Themed scrollbar (WebKit/Blink) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: var(--amber-dim); }
