/* ── Theme variables ── */
:root,
[data-theme="dark"] {
  --bg: #080b14;
  --surface: #0f1520;
  --surface2: #141c2e;
  --surface3: #192436;
  --border: #1e2d47;
  --border2: #243352;
  --accent: #6366f1;
  --accent-glow: rgba(99,102,241,0.25);
  --accent-hover: #818cf8;
  --accent2: #8b5cf6;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --muted: #64748b;
  --success: #22c55e;
  --success-bg: rgba(34,197,94,0.1);
  --error: #f87171;
  --error-bg: rgba(248,113,113,0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245,158,11,0.1);
  --green: #4ade80;
  --red: #f87171;
  --sidebar-bg: #0a0f1c;
  --sidebar-border: #1e2d47;
  --sidebar-label: #334155;
  --sidebar-link: #64748b;
  --sidebar-link-hover-bg: rgba(99,102,241,0.1);
  --sidebar-link-hover-text: #e2e8f0;
  --sidebar-link-active-text: #a5b4fc;
  --sidebar-link-active-bg: rgba(99,102,241,0.15);
  --sidebar-link-active-icon: #818cf8;
  --toast-bg: #0f1520;
  --overlay-bg: rgba(0,0,0,0.6);
  --input-bg: #0f1520;
  --input-border: #1e2d47;
  --input-focus-border: #6366f1;
  --card-bg: #0f1520;
  --table-row-hover: rgba(99,102,241,0.05);
  --skeleton-from: #0f1520;
  --skeleton-to: #1a2438;
  --scrollbar-thumb: #1e2d47;
  --nav-topbar-bg: rgba(10,15,28,0.95);
  --hamburger-border: #1e2d47;
  --code-bg: #0a0f1c;
  --badge-neutral-bg: rgba(100,116,139,0.15);
  --badge-neutral-text: #94a3b8;
}

[data-theme="light"] {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --surface3: #eef2f7;
  --border: #d1dce8;
  --border2: #bccad8;
  --accent: #4f46e5;
  --accent-glow: rgba(79,70,229,0.18);
  --accent-hover: #6366f1;
  --accent2: #7c3aed;
  --text: #0f172a;
  --text2: #334155;
  --muted: #64748b;
  --success: #16a34a;
  --success-bg: rgba(22,163,74,0.1);
  --error: #dc2626;
  --error-bg: rgba(220,38,38,0.1);
  --warning: #d97706;
  --warning-bg: rgba(217,119,6,0.1);
  --green: #16a34a;
  --red: #dc2626;
  --sidebar-bg: #1e1b4b;
  --sidebar-border: #2d2a6e;
  --sidebar-label: #6d6aaa;
  --sidebar-link: #a5a3d9;
  --sidebar-link-hover-bg: rgba(255,255,255,0.1);
  --sidebar-link-hover-text: #ffffff;
  --sidebar-link-active-text: #ffffff;
  --sidebar-link-active-bg: rgba(255,255,255,0.15);
  --sidebar-link-active-icon: #c4b5fd;
  --toast-bg: #ffffff;
  --overlay-bg: rgba(0,0,0,0.4);
  --input-bg: #ffffff;
  --input-border: #d1dce8;
  --input-focus-border: #4f46e5;
  --card-bg: #ffffff;
  --table-row-hover: rgba(79,70,229,0.04);
  --skeleton-from: #e8edf2;
  --skeleton-to: #d4dce6;
  --scrollbar-thumb: #c1cdd8;
  --nav-topbar-bg: rgba(30,27,75,0.97);
  --hamburger-border: rgba(255,255,255,0.2);
  --code-bg: #1e1b4b;
  --badge-neutral-bg: rgba(100,116,139,0.12);
  --badge-neutral-text: #475569;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s ease, color 0.25s ease;
}

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

/* ── Theme toggle button ── */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--hamburger-border);
  background: none;
  color: var(--sidebar-link);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}
.theme-toggle:hover {
  background: var(--sidebar-link-hover-bg);
  color: var(--sidebar-link-hover-text);
}
.theme-toggle svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}
/* show only relevant icon */
[data-theme="dark"]  .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"]  .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: block; }
.theme-toggle .icon-moon { display: none; }

/* standalone topbar theme toggle (non-sidebar pages: login, register, etc.) */
.topbar-theme-toggle {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.2s;
  padding: 0;
}
.topbar-theme-toggle:hover { border-color: var(--accent); color: var(--text); }
.topbar-theme-toggle svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}
[data-theme="dark"]  .topbar-theme-toggle .icon-sun  { display: block; }
[data-theme="dark"]  .topbar-theme-toggle .icon-moon { display: none; }
[data-theme="light"] .topbar-theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .topbar-theme-toggle .icon-moon { display: block; }
.topbar-theme-toggle .icon-sun  { display: block; }
.topbar-theme-toggle .icon-moon { display: none; }
