/* ═════════════════════════════════════════════════════════════
   FRANK — shared design tokens
   One palette, one type scale, one spacing/radius/shadow system,
   reused by every Frank surface (control center, studios, PWA, site).
   Precision-instrument aesthetic: dark, dense, professional.
   Accent (green) is reserved for primary actions + live/success state.
   ═════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces — cool near-black, not pure black, not warm */
  --bg: #0a0b0e;
  --surface: #121317;
  --surface-2: #1a1c22;
  --surface-3: #22252c;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);

  /* Text — high contrast */
  --text: #e8e9ed;
  --text-2: #a8aab2;
  --text-3: #8a8c94;
  --text-4: #6b6d76;

  /* Accent — green, ONLY for primary actions + live state */
  --accent: #00d97e;
  --accent-dim: rgba(0, 217, 126, 0.12);
  --accent-glow: rgba(0, 217, 126, 0.25);
  --accent-fg: #04140d; /* text color on top of solid accent fills */

  /* Semantic — standardized state vocabulary */
  --success: #00d97e;
  --warning: #f5a623;
  --error: #ff5252;
  --info: #448aff;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;

  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --leading-tight: 1.25;
  --leading-normal: 1.5;

  /* Spacing — 4px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 0 3px var(--accent-glow);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration: 200ms;
  --duration-slow: 320ms;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-backdrop: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;
}

/* ═════════════════════════════════════════════════════════════
   BASE RESET — shared across surfaces
   ═════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-sm); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Focus ring — always visible, never suppressed ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ═════════════════════════════════════════════════════════════
   PRIMITIVES — buttons, inputs, cards, badges, nav items
   Each surface's own CSS should compose these instead of
   redefining button/input chrome from scratch.
   ═════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration-fast) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { background: var(--accent); box-shadow: var(--shadow-glow); }

.btn-danger { border-color: var(--error); color: var(--error); background: transparent; }
.btn-danger:hover { background: rgba(255, 82, 82, 0.1); }

.input, textarea.input, select.input {
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  transition: border-color var(--duration) var(--ease);
}
.input:focus { border-color: var(--accent); }
textarea.input { height: auto; padding: var(--space-3); resize: vertical; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-success { background: var(--accent-dim); color: var(--accent); }
.badge-warning { background: rgba(245, 166, 35, 0.12); color: var(--warning); }
.badge-error   { background: rgba(255, 82, 82, 0.12); color: var(--error); }
.badge-info    { background: rgba(68, 138, 255, 0.12); color: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--text-3); }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

/* ── States ── */
.state-empty, .state-loading, .state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  color: var(--text-3);
  text-align: center;
}
.state-error { color: var(--error); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
