/* Quasar themes. Each theme only redefines the variables below; components
   are styled once from the variables. The active theme is set through the
   data-theme attribute on <html>, persisted in a cookie. */

:root,
[data-theme="nebula"] {
  --bg: #09090b;
  --surface: #18181b;
  --surface-2: rgba(24, 24, 27, 0.6);
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --accent: #f4f4f5;
  --accent-hover: #ffffff;
  --accent-text: #09090b;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #38bdf8;
  --chart: #0284c7; /* series color, validated against the dark surface */
  --radius: 4px;
  --radius-badge: 9999px;
  --border-w: 1px;
  --log-bg: #000000;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, monospace;
}

[data-theme="terminal"] {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #071207;
  --border: #1f7a1f;
  --border-strong: #33ff33;
  --text: #33ff33;
  --text-muted: #28cc28;
  --text-faint: #1f7a1f;
  --accent: #33ff33;
  --accent-hover: #66ff66;
  --accent-text: #000000;
  --ok: #33ff33;
  --warn: #ffcc00;
  --err: #ff4040;
  --info: #33ffff;
  --chart: #00a3a3; /* series color, validated against pure black */
  --radius: 0;
  --radius-badge: 0;
  --border-w: 2px;
  --log-bg: #000000;
  --font-body: var(--font-mono);
}

[data-theme="paper"] {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --border: #e7e5e4;
  --border-strong: #a8a29e;
  --text: #1c1917;
  --text-muted: #57534e;
  --text-faint: #a8a29e;
  --accent: #1c1917;
  --accent-hover: #000000;
  --accent-text: #fafaf9;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
  --info: #0284c7;
  --chart: #0284c7; /* series color, validated against white */
  --radius: 6px;
  --radius-badge: 9999px;
  --border-w: 1px;
  --log-bg: #1c1917;
}

/* --- Base ------------------------------------------------------------------ */

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

.h-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.help {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.link { color: var(--text-muted); }
.link:hover { color: var(--text); }

/* --- Chrome ---------------------------------------------------------------- */

.site-header {
  border-bottom: var(--border-w) solid var(--border);
  background: var(--surface-2);
}

.brand {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
}

.nav-link { font-size: 0.875rem; color: var(--text-muted); }
.nav-link:hover { color: var(--text); }

/* --- Components ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
}

.empty {
  border: var(--border-w) dashed var(--border);
  border-radius: var(--radius);
}

.chip {
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.input {
  width: 100%;
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--border-strong); }
.input::placeholder { color: var(--text-faint); }

.input-suffix {
  border: var(--border-w) solid var(--border);
  border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-2);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.input-suffix ~ .input,
.has-suffix .input { border-radius: var(--radius) 0 0 var(--radius); }

.select {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
}
.btn:hover { background: var(--surface-2); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--accent);
  color: var(--accent-text);
  border: var(--border-w) solid var(--accent);
  border-radius: var(--radius);
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: var(--border-w) solid color-mix(in srgb, var(--err) 50%, transparent);
  border-radius: var(--radius);
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--err);
}
.btn-danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); }

/* Inline icon, sized to sit beside text; color follows currentColor. */
.ico {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}
.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.stat-label .ico { color: var(--text-faint); }

.alert-err {
  border: var(--border-w) solid color-mix(in srgb, var(--err) 50%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--err) 10%, transparent);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--err);
}

/* --- Badges & meters ------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: var(--radius-badge);
  border: var(--border-w) solid;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
}
.badge .dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: var(--radius-badge);
  background: currentColor;
}
.badge-ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 45%, transparent);   background: color-mix(in srgb, var(--ok) 8%, transparent); }
.badge-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.badge-err  { color: var(--err);  border-color: color-mix(in srgb, var(--err) 45%, transparent);  background: color-mix(in srgb, var(--err) 8%, transparent); }
.badge-muted { color: var(--text-muted); border-color: var(--border); background: var(--surface); }

.meter {
  height: 0.375rem;
  width: 100%;
  border-radius: var(--radius-badge);
  background: color-mix(in srgb, var(--text) 12%, transparent);
  overflow: hidden;
}
.meter > div { height: 100%; border-radius: var(--radius-badge); }
.fill-ok   { background: var(--ok); }
.fill-warn { background: var(--warn); }
.fill-err  { background: var(--err); }
.fill-info { background: var(--info); }

.env-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
}
.env-row + .env-row { border-top: var(--border-w) solid var(--border); }
.env-icon {
  display: flex;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  color: var(--text-faint);
}
.env-icon svg { width: 100%; height: 100%; }

.reorder-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1rem;
  color: var(--text-faint);
  border-radius: var(--radius);
}
.reorder-btn:hover { color: var(--text); background: var(--surface-2); }

/* --- Tables ---------------------------------------------------------------- */

.table-wrap {
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-wrap table { width: 100%; text-align: left; font-size: 0.875rem; }
.table-wrap thead {
  border-bottom: var(--border-w) solid var(--border);
  background: var(--surface-2);
}
.table-wrap th {
  padding: 0.625rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.table-wrap td { padding: 0.75rem 1rem; }
.table-wrap tbody tr { border-top: var(--border-w) solid color-mix(in srgb, var(--border) 60%, transparent); }
.table-wrap tbody tr:first-child { border-top: 0; }
.table-wrap tbody tr:hover { background: var(--surface-2); }

/* --- Logs ------------------------------------------------------------------ */

.log-pane {
  height: 24rem;
  overflow-y: auto;
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  background: var(--log-bg);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.25rem;
  color: #d4d4d8;
}
[data-theme="terminal"] .log-pane { color: var(--text); }

/* --- Terminal brutalism extras --------------------------------------------- */

[data-theme="terminal"] body {
  text-shadow: 0 0 6px color-mix(in srgb, var(--text) 40%, transparent);
}
[data-theme="terminal"] ::selection {
  background: var(--text);
  color: var(--bg);
  text-shadow: none;
}
[data-theme="terminal"] h1 {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
[data-theme="terminal"] .btn:hover,
[data-theme="terminal"] .btn-danger:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  text-shadow: none;
}
[data-theme="terminal"] .btn-danger:hover { background: var(--err); border-color: var(--err); }
[data-theme="terminal"] input,
[data-theme="terminal"] textarea,
[data-theme="terminal"] select,
[data-theme="terminal"] button {
  text-shadow: inherit;
}
/* Subtle CRT scanlines over the whole page. */
[data-theme="terminal"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.35) 3px,
    transparent 4px
  );
  opacity: 0.25;
}
