/*
  FaceTrack Pro — shared enterprise design system.
  Single source of truth for color, type, spacing, and core components
  across every page (dashboard, cameras, login, register, landing).
  Bright, professional palette — no gradients, no glassmorphism, no neon.
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Surfaces — classic blue & white */
  --bg:          #ffffff;
  --surface:     #ffffff;
  --surface-2:   #f4f7fc;
  --surface-3:   #e8eef7;
  --border:      #dbe4f0;
  --border-strong: #b9c9e0;

  /* Text */
  --text:        #1a2740;
  --text-muted:  #445573;
  --text-faint:  #6b7a94;

  /* Brand / accent */
  --accent:        #1d4ed8;
  --accent-hover:  #1e40af;
  --accent-soft:   #eaf1fd;
  --accent-text:   #1d4ed8;

  /* Sidebar — solid navy, white text (classic enterprise look) */
  --sidebar-bg:          #0f2b5c;
  --sidebar-border:      rgba(255,255,255,0.10);
  --sidebar-text:        #ffffff;
  --sidebar-text-muted:  #a9bde0;
  --sidebar-active-bg:   rgba(255,255,255,0.14);
  --sidebar-active-text: #ffffff;
  --sidebar-brand-dot:   #5b9bf5;

  /* Semantic status */
  --success:       #12805c;
  --success-soft:  #e6f6ef;
  --warning:       #9a6300;
  --warning-soft:  #fdf3dc;
  --danger:        #c02b3c;
  --danger-soft:   #fbe9eb;
  --info:          #2461ac;
  --info-soft:     #e8f1fb;

  /* Type */
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:        'JetBrains Mono', ui-monospace, monospace;

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

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows — soft, not glowing */
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.06);
  --shadow-md: 0 2px 8px rgba(16,24,40,0.08);
  --shadow-lg: 0 8px 24px rgba(16,24,40,0.10);

  --sidebar-width: 244px;
  --topbar-height: 56px;
}

:root[data-theme="dark"] {
  --bg:          #14161a;
  --surface:     #1c1f24;
  --surface-2:   #22262c;
  --surface-3:   #2a2e35;
  --border:      #33383f;
  --border-strong: #3d434b;

  --text:        #e7e9ec;
  --text-muted:  #9aa1ab;
  --text-faint:  #6b7280;

  --accent:        #5b7cf5;
  --accent-hover:  #7996f7;
  --accent-soft:   #232c47;
  --accent-text:   #a9bbfb;

  --success:       #35c990;
  --success-soft:  #16302a;
  --warning:       #e8b03d;
  --warning-soft:  #362c15;
  --danger:        #f0616f;
  --danger-soft:   #3a1e22;
  --info:          #63a4e8;
  --info-soft:     #1b2d3d;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.24);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.28);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.32);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #14161a;
    --surface:     #1c1f24;
    --surface-2:   #22262c;
    --surface-3:   #2a2e35;
    --border:      #33383f;
    --border-strong: #3d434b;

    --text:        #e7e9ec;
    --text-muted:  #9aa1ab;
    --text-faint:  #6b7280;

    --accent:        #5b7cf5;
    --accent-hover:  #7996f7;
    --accent-soft:   #232c47;
    --accent-text:   #a9bbfb;

    --success:       #35c990;
    --success-soft:  #16302a;
    --warning:       #e8b03d;
    --warning-soft:  #362c15;
    --danger:        #f0616f;
    --danger-soft:   #3a1e22;
    --info:          #63a4e8;
    --info-soft:     #1b2d3d;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.28);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.32);
  }
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* ── App shell: persistent left sidebar + slim top bar ───────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.app-sidebar-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  color: var(--sidebar-text);
}
.app-sidebar-brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--sidebar-brand-dot); flex-shrink: 0;
}
.app-sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: var(--sp-2) var(--sp-3);
  display: flex; flex-direction: column; gap: 2px;
}
.app-sidebar-nav a,
.app-sidebar-nav .sidebar-nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 500;
  color: var(--sidebar-text-muted);
  cursor: pointer; border: none; background: transparent;
  width: 100%; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.app-sidebar-nav .sidebar-nav-item svg,
.app-sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; }
.app-sidebar-nav .sidebar-nav-item:hover,
.app-sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--sidebar-text); }
.app-sidebar-nav .sidebar-nav-item.active,
.app-sidebar-nav a.active {
  background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600;
}
.app-sidebar-nav .nav-badge {
  margin-left: auto; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.14); color: var(--sidebar-text-muted);
}
.app-sidebar-nav .sidebar-nav-item.active .nav-badge { background: rgba(255,255,255,0.22); color: var(--sidebar-active-text); }
.app-sidebar-foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--sidebar-border);
  font-size: 11px; color: var(--sidebar-text-muted);
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.app-topbar-title { font-size: 15px; font-weight: 700; }
.app-topbar-actions { display: flex; align-items: center; gap: var(--sp-4); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 8px 14px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; font-family: var(--font);
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }
.btn-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: box-shadow 0.15s, border-color 0.15s; }
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* ── Badges / status pills ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-success .badge-dot { background: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-warning .badge-dot { background: var(--warning); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-danger .badge-dot { background: var(--danger); }
.badge-info    { background: var(--info-soft); color: var(--info); }
.badge-info .badge-dot { background: var(--info); }
.badge-neutral { background: var(--surface-3); color: var(--text-muted); }
.badge-neutral .badge-dot { background: var(--text-faint); }

/* ── Tables ───────────────────────────────────────────────────────────── */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: var(--sp-3) var(--sp-4);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tbody tr:hover { background: var(--surface-2); }

/* ── Forms ────────────────────────────────────────────────────────────── */
.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13.5px; font-family: var(--font);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; line-height: 1.5; }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toast-host {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500; color: var(--text);
  min-width: 220px; max-width: 380px;
  transform: translateY(8px); opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast .toast-icon {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.toast.toast-ok .toast-icon { background: var(--success); }
.toast.toast-err .toast-icon { background: var(--danger); }
.toast.toast-warn .toast-icon { background: var(--warning); }
.toast.toast-info .toast-icon { background: var(--info); }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,22,26,0.42);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  padding: var(--sp-6); width: 420px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px); overflow-y: auto;
  transform: scale(0.98); transition: transform 0.15s ease;
}
.modal-overlay.open .modal { transform: scale(1); }

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