/* YIELD design system — Mission Control dark theme.
   Replaces the old base.css. CSS custom properties scoped to :root, with
   per-module accent overrides via body[data-module="<module>"].
*/

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  /* Surfaces */
  --bg:          #0a0e1a;
  --surface-1:   #0d1424;
  --surface-2:   #111b2e;
  --border:      #1e293b;
  --border-hi:   #334155;

  /* Typography */
  --text:        #cbd5e1;
  --text-hi:     #fafafa;
  --text-mid:    #94a3b8;
  --text-dim:    #64748b;
  --text-ghost:  #475569;

  /* Status */
  --ok:          #10b981;
  --warn:        #f59e0b;
  --err:         #ef4444;
  --info:        #3b82f6;

  /* Per-module accents */
  --accent-blue:    #3b82f6;
  --accent-pink:    #ec4899;
  --accent-spotify: #1db954;
  --accent-tiktok:  #ff0050;
  --accent-rec8:    #ff3b3b;
  --accent:         var(--accent-blue);

  /* Glow shadows */
  --glow-ok:    0 0 6px rgba(16, 185, 129, 0.5);
  --glow-warn:  0 0 6px rgba(245, 158, 11, 0.5);
  --glow-info:  0 0 6px rgba(59, 130, 246, 0.5);

  /* Fonts */
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", Menlo, Consolas, "Courier New", monospace;

  /* Type scale */
  --text-xs:   0.6875rem;
  --text-sm:   0.8125rem;
  --text-base: 0.875rem;
  --text-md:   1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.5rem;
  --text-2xl:  2rem;
  --text-3xl:  3rem;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
}

/* Per-module accent overrides */
body[data-module="orchestrator"] { --accent: var(--accent-pink); }
body[data-module="spotify"]      { --accent: var(--accent-spotify); }
body[data-module="tiktok"]       { --accent: var(--accent-tiktok); }
body[data-module="rec8"]         { --accent: var(--accent-rec8); }

/* ---------- Reset + base ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--text-hi); margin: 0 0 var(--space-3) 0; font-weight: 600; }
h1 { font-size: var(--text-2xl); letter-spacing: -0.5px; }
h2 { font-size: var(--text-xs); color: var(--text-mid); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 500; }
h3 { font-size: var(--text-lg); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.topbar-brand {
  font-weight: 700; letter-spacing: 1px; color: var(--accent);
  font-size: var(--text-md);
}
.topbar-ops {
  display: flex; gap: var(--space-4); margin-left: var(--space-5);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-mid);
}
.topbar-ops .ops-online { color: var(--ok); }
.topbar-ops .ops-degraded { color: var(--warn); cursor: pointer; }
.topbar-ops .ops-degraded:hover { text-decoration: underline; }
.topbar-user {
  margin-left: auto; display: flex; gap: var(--space-3); align-items: center;
  font-size: var(--text-sm); color: var(--text-mid);
}
.link-button {
  background: none; border: none; color: var(--text); cursor: pointer;
  font-size: var(--text-md); padding: var(--space-1) var(--space-2);
}
.link-button:hover { color: var(--accent); }

/* ---------- Layout / sidebar ---------- */
.layout { display: flex; min-height: calc(100vh - 50px); }

.sidebar {
  width: 200px; background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: var(--space-3) 0;
}
.nav-active, .nav-pending { display: flex; flex-direction: column; }
.nav-section-label {
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-size: var(--text-xs); color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.5px; font-weight: 500;
}
.nav-divider {
  height: 1px; background: var(--border);
  margin: var(--space-2) var(--space-3);
}
.nav-item {
  display: flex; align-items: center;
  padding: var(--space-2) var(--space-4);
  color: var(--text); font-size: var(--text-sm);
  border-left: 2px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.04); text-decoration: none; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59,130,246,0.15) 0%, transparent 100%);
  border-left-color: var(--accent);
  color: var(--text-hi); font-weight: 600;
}
.nav-item.active::before { content: "▸"; color: var(--accent); margin-right: var(--space-2); }
.nav-item.disabled { opacity: 0.45; cursor: help; }
.nav-label { flex: 1; }
.nav-badge {
  font-family: var(--font-mono); font-size: var(--text-xs);
  background: var(--surface-2); color: var(--accent);
  padding: 1px 6px; border-radius: var(--radius-sm); margin-left: var(--space-2);
}
.nav-coming {
  font-family: var(--font-mono); font-size: var(--text-xs);
  background: var(--surface-2); color: var(--text-mid);
  padding: 1px 5px; border-radius: var(--radius-sm); letter-spacing: 0.5px;
}

.content {
  flex: 1; padding: var(--space-5);
  max-width: 100%; overflow-x: auto;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.panel-tight { padding: var(--space-3); }
.panel h2 { margin-bottom: var(--space-3); }

/* Key-value display */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: var(--space-1) var(--space-4); font-size: var(--text-sm); }
.kv dt { color: var(--text-mid); }
.kv dd { margin: 0; color: var(--text-hi); }

/* KPI numerals */
.kpi-num {
  font-family: var(--font-mono); font-size: var(--text-2xl);
  color: var(--text-hi); line-height: 1; font-weight: 700;
}

/* Status dots */
.dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: var(--space-2);
  vertical-align: middle;
}
.dot-ok   { background: var(--ok);   box-shadow: var(--glow-ok); }
.dot-warn { background: var(--warn); box-shadow: var(--glow-warn); }
.dot-err  { background: var(--err); }
.dot-off  { background: var(--text-ghost); }

/* Tags / chips */
.tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: var(--text-xs);
  background: var(--surface-2); color: var(--text-mid);
  font-weight: 500; letter-spacing: 0.3px;
}
.tag-active { background: var(--accent); color: #0a0e1a; }
.tag-warn { background: var(--warn); color: #0a0e1a; }
.tag-err  { background: var(--err); color: #fff; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm); font-weight: 600;
  border: none; border-radius: var(--radius-md);
  cursor: pointer; font-family: var(--font-body);
  text-decoration: none;
  transition: filter 0.1s;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn-primary { background: var(--accent); color: #0a0e1a; }
.btn-ghost   { background: transparent; color: var(--text); border: 1px solid var(--border-hi); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger  { background: var(--err); color: #fff; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Forms */
input[type="text"], input[type="password"], input[type="number"], input[type="search"], textarea, select {
  background: #0b0f13; border: 1px solid var(--border);
  color: var(--text); padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); width: 100%;
  font-size: var(--text-sm); font-family: var(--font-body);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--glow-info);
}
label { display: block; margin-bottom: var(--space-3); font-size: var(--text-xs); color: var(--text-mid); }
label input, label select, label textarea { margin-top: var(--space-1); }

/* Flash */
.flash {
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3);
  border-radius: var(--radius-md); border: 1px solid var(--border);
}
.flash-info  { border-color: var(--info); color: var(--info); }
.flash-error { border-color: var(--err);  color: var(--err); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border); font-size: var(--text-sm);
}
th {
  color: var(--text-mid); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.5px; font-size: var(--text-xs);
}
tbody tr:hover td { background: var(--surface-2); }

/* Utility classes */
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.muted { color: var(--text-dim); }
.text-hi { color: var(--text-hi); }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.panel-footer { margin-top: var(--space-3); display: flex; gap: var(--space-3); align-items: center; }
.text-muted { color: var(--text-dim); }
.mt-3 { margin-top: var(--space-3); }

/* Login screen */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: var(--space-5); }
.login-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: var(--space-6);
  width: 100%; max-width: 380px;
  position: relative; overflow: hidden;
}
.login-card::after {
  content: ""; position: absolute; right: -40%; bottom: -40%;
  width: 80%; height: 80%; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(59,130,246,0.12) 0%, transparent 60%);
}
.login-hero { font-size: var(--text-3xl); font-weight: 900; letter-spacing: -2px; color: var(--text-hi); margin: 0 0 var(--space-1); }
.login-tag  { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; margin-bottom: var(--space-5); }
.login-card .btn { width: 100%; margin-top: var(--space-3); }

/* Error / 404 pages */
.panel-center { text-align: center; padding: var(--space-7) var(--space-4); }
.error-heading { font-size: var(--text-3xl); font-weight: 900; letter-spacing: -2px; }

/* Mobile */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; padding: var(--space-2); }
  .nav-active, .nav-pending { flex-direction: row; flex-wrap: wrap; gap: var(--space-1); }
  .nav-item { padding: var(--space-1) var(--space-3); border-left: none; border-bottom: 2px solid transparent; }
  .nav-item.active { border-left: none; border-bottom-color: var(--accent); }
  .nav-divider, .nav-section-label { display: none; }
  .topbar-ops { display: none; }
  .content { padding: var(--space-3); }
  .kv { grid-template-columns: 1fr; }
}
