/* ═══════════════════════════════════════════════════════════════════
   SHARED DESIGN SYSTEM — styles.css
   All visual decisions live here. Change these to restyle the whole UI.
   Individual pages may override tokens in their own <style> block.
   ═══════════════════════════════════════════════════════════════════ */

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

/* ── Design Tokens ── */
:root {
  /* Colours */
  --bg:        #0f1117;   /* page background */
  --surface:   #1a1d27;   /* card / sidebar background */
  --surface2:  #21253a;   /* elevated card, table row bg */
  --surface3:  #282c40;   /* nested elements, code blocks */
  --border:    #2a2d3e;   /* borders and dividers */

  --accent:    #6c63ff;   /* primary action colour (override per page) */
  --accent2:   #00d4aa;   /* secondary accent (teal) */
  --cyan:      #63b3ed;   /* monospace / source links */
  --success:   #22c55e;
  --warning:   #f59e0b;
  --warn:      #f59e0b;   /* alias */
  --danger:    #ff4d6d;

  --text:           #e2e8f0;   /* primary text */
  --text-secondary: #94a3b8;   /* secondary text, subtitles */
  --muted:          #64748b;   /* labels, placeholders */

  /* Typography */
  --font-family: 'Inter', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --font-xs:  11px;
  --font-sm:  12px;
  --font-md:  13px;   /* base body size */
  --font-lg:  15px;
  --font-xl:  18px;
  --font-2xl: 20px;
  --font-3xl: 24px;

  --font-weight-normal:   400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;

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

  /* Border radius */
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   10px;
  --radius-xl:   12px;
  --radius-2xl:  16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.55);

  /* Motion */
  --transition:      all .15s ease;
  --transition-slow: all .25s ease;
}

/* ═══════════════════════════════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════════════════════════════ */
body { background: var(--bg); color: var(--text); font-family: var(--font-family); font-size: var(--font-md); min-height: 100vh; }

/* ═══════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.row { display: flex; gap: var(--space-3); }
.row > * { flex: 1; }
.fade-up { animation: fadeUp .35s ease both; }

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS
   To add a new variant: define background + color/border in 3 lines.
   ═══════════════════════════════════════════════════════════════════ */
.btn { display: inline-flex; align-items: center; gap: var(--space-1); padding: 8px 16px; border-radius: var(--radius-md); border: none; cursor: pointer; font-size: var(--font-md); font-weight: var(--font-weight-medium); transition: var(--transition); font-family: inherit; text-decoration: none; }
.btn-primary      { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-success      { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger       { background: rgba(255,77,109,.15); color: #ff6b87; border: 1px solid rgba(255,77,109,.3); padding: 5px 10px; font-size: var(--font-sm); }
.btn-danger:hover  { background: rgba(255,77,109,.25); }
.btn-warn         { background: rgba(245,158,11,.15); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); padding: 5px 10px; font-size: var(--font-sm); }
.btn-secondary    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost        { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover  { color: var(--text); border-color: var(--text-secondary); }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid rgba(255,77,109,.3); padding: 6px 12px; font-size: var(--font-sm); }
.btn-danger-ghost:hover { background: rgba(255,77,109,.1); }
.btn-sm { padding: 4px 10px; font-size: var(--font-sm); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: var(--space-6); margin-bottom: var(--space-5); }
.card-title { font-size: 14px; font-weight: var(--font-weight-semibold); margin-bottom: var(--space-4); display: flex; align-items: center; gap: var(--space-2); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════════════════════ */
.table { width: 100%; border-collapse: collapse; font-size: var(--font-md); }
.table th { text-align: left; padding: 9px 12px; color: var(--muted); font-weight: var(--font-weight-medium); font-size: var(--font-xs); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,.015); }

/* ═══════════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════════ */
.badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-full); font-size: var(--font-xs); font-weight: var(--font-weight-medium); }
.badge-blue  { background: rgba(108,99,255,.2);  color: #a89cff; }
.badge-green { background: rgba(34,197,94,.15);  color: #4ade80; }
.badge-red   { background: rgba(255,77,109,.15); color: #ff6b87; }
.badge-amber { background: rgba(245,158,11,.15); color: #fbbf24; }

/* ═══════════════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════════════ */
.alert { padding: 10px 14px; border-radius: var(--radius-md); font-size: var(--font-md); margin-bottom: 14px; }
.alert-success { background: rgba(34,197,94,.08);  border: 1px solid rgba(34,197,94,.25);  color: #4ade80; }
.alert-error   { background: rgba(255,77,109,.08); border: 1px solid rgba(255,77,109,.25); color: #ff6b87; }
.alert-info    { background: rgba(108,99,255,.08); border: 1px solid rgba(108,99,255,.25); color: #a89cff; }

/* ═══════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-2xl); padding: 28px; width: 420px; box-shadow: var(--shadow-lg); }
.modal h3 { font-size: var(--font-lg); font-weight: var(--font-weight-semibold); margin-bottom: var(--space-5); }

/* ═══════════════════════════════════════════════════════════════════
   SPINNER  &  KEYFRAMES
   ═══════════════════════════════════════════════════════════════════ */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.2); border-radius: var(--radius-full); border-top-color: #fff; animation: spin .6s linear infinite; }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes pulse   { 0%,100% { opacity:.3; } 50% { opacity:1; } }
@keyframes toastIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeUp  { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }

/* ═══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 18px; border-radius: var(--radius-lg); font-size: var(--font-md); font-weight: var(--font-weight-medium); max-width: 360px; pointer-events: all; animation: toastIn .25s ease; box-shadow: var(--shadow-md); }
.toast.t-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.35); color: #4ade80; }
.toast.t-error   { background: rgba(255,77,109,.15); border: 1px solid rgba(255,77,109,.35); color: #ff6b87; }
.toast.t-info    { background: rgba(108,99,255,.15); border: 1px solid rgba(108,99,255,.35); color: #a89cff; }

/* ═══════════════════════════════════════════════════════════════════
   CONFIRM DIALOG
   ═══════════════════════════════════════════════════════════════════ */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 200; }
.confirm-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 28px; max-width: 400px; width: 90%; }
.confirm-box p { font-size: 14px; line-height: 1.6; color: var(--text); margin-bottom: 20px; white-space: pre-wrap; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ═══════════════════════════════════════════════════════════════════
   STATUS DOT  (used in both pages)
   ═══════════════════════════════════════════════════════════════════ */
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: var(--radius-full); flex-shrink: 0; }
.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--muted); }

/* ═══════════════════════════════════════════════════════════════════
   COLOR PICKER SWATCH
   ═══════════════════════════════════════════════════════════════════ */
.color-opt { width: 24px; height: 24px; border-radius: var(--radius-full); cursor: pointer; border: 2px solid transparent; transition: border-color .15s; }
.color-opt.selected { border-color: #fff; }
