/* ╔══════════════════════════════════════════════════════╗
   ║              DESIGN TOKENS  (edit here!)            ║
   ╚══════════════════════════════════════════════════════╝
   All visual properties live as CSS variables so a
   theme swap is a single class toggle on <html>.        */

/* ── Dark theme (default) ───────────────────────────── */
:root {
  --primary:        #7C3AED;
  --primary-light:  #8B5CF6;
  --primary-dark:   #6D28D9;
  --primary-glow:   rgba(124, 58, 237, 0.25);

  --bg:             #07030f;
  --surface:        rgba(255, 255, 255, 0.04);
  --surface-hover:  rgba(255, 255, 255, 0.07);
  --surface-dark:   rgba(0,   0,   0,   0.22);
  --border:         rgba(255, 255, 255, 0.08);
  --border-strong:  rgba(255, 255, 255, 0.16);

  --text-primary:   rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-muted:     rgba(255, 255, 255, 0.28);

  --input-bg:       rgba(0, 0, 0, 0.22);
  --input-bg-hover: rgba(0, 0, 0, 0.32);

  --nav-bg:         rgba(7,  3,  15, 0.65);
  --sidebar-bg:     rgba(7,  3,  15, 0.88);
  --header-bg:      rgba(7,  3,  15, 0.50);
  --orb-opacity:    0.32;
}

/* ── Light theme ─────────────────────────────────────── */
html.light {
  --bg:             #f0eeff;
  --surface:        rgba(255, 255, 255, 0.68);
  --surface-hover:  rgba(255, 255, 255, 0.90);
  --surface-dark:   rgba(124, 58, 237, 0.05);
  --border:         rgba(0,   0,   0,   0.07);
  --border-strong:  rgba(0,   0,   0,   0.14);

  --text-primary:   rgba(18,  10, 35,  0.92);
  --text-secondary: rgba(18,  10, 35,  0.54);
  --text-muted:     rgba(18,  10, 35,  0.28);

  --input-bg:       rgba(0,   0,   0,   0.04);
  --input-bg-hover: rgba(0,   0,   0,   0.07);

  --nav-bg:         rgba(240, 238, 255, 0.80);
  --sidebar-bg:     rgba(244, 242, 255, 0.95);
  --header-bg:      rgba(244, 242, 255, 0.70);
  --orb-opacity:    0.16;
  color-scheme: light;
}

/* ── Global reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 300ms ease, color 300ms ease;
}

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

/* ── Ambient orbs ───────────────────────────────────────── */
.orb-container {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(90px);
  opacity: var(--orb-opacity, 0.32);
  transition: opacity 400ms ease;
}
.orb-1 {
  width: 640px; height: 640px;
  background: radial-gradient(circle, #7C3AED 0%, transparent 68%);
  top: -220px; right: -180px;
  animation: orb-drift 22s ease-in-out infinite alternate;
}
.orb-2 {
  width: 440px; height: 440px;
  background: radial-gradient(circle, #4338CA 0%, transparent 68%);
  bottom: -120px; left: -120px;
  animation: orb-drift 28s ease-in-out infinite alternate-reverse;
}
.orb-3 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, #0EA5E9 0%, transparent 68%);
  top: 45%; left: 35%;
  opacity: calc(var(--orb-opacity, 0.32) * 0.4);
  animation: orb-drift 34s ease-in-out infinite;
}
@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(28px, 18px) scale(1.06); }
}

/* ── Z-index stacking ───────────────────────────────────── */
#nav, #outlet { position: relative; z-index: 1; }
#nav { position: sticky; top: 0; z-index: 40; }

/* ── Page entrance ──────────────────────────────────────── */
#outlet > * {
  animation: page-in 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ╔══════════════════════════════════════════════════════╗
   ║               COMPONENT CLASSES                     ║
   ╚══════════════════════════════════════════════════════╝ */

/* ── Glass surfaces ─────────────────────────────────────── */
.glass {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: background 200ms ease, border-color 200ms ease;
}
.glass-dark {
  background: var(--surface-dark);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.glass-hover {
  transition: background 200ms ease, border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}
.glass-hover:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--primary) 0%, #4338CA 100%);
  color: white;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 600; font-size: 0.9rem; letter-spacing: 0.01em;
  border-radius: 10px; border: none; cursor: pointer;
  transition: opacity 200ms ease, transform 200ms ease, box-shadow 200ms ease;
  text-decoration: none; white-space: nowrap;
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.88; transform: translateY(-1px);
  box-shadow: 0 8px 28px var(--primary-glow), 0 0 0 1px rgba(124,58,237,0.3);
}
.btn-primary:active  { transform: translateY(0); }
.btn-primary:disabled{ opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px;
  background: var(--surface);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500; font-size: 0.9rem;
  border-radius: 10px; border: 1px solid var(--border); cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, transform 200ms ease;
  text-decoration: none; white-space: nowrap;
}
.btn-ghost:hover {
  background: var(--surface-hover); border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* ── Inputs ─────────────────────────────────────────────── */
.glass-input {
  display: block; width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px;
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, sans-serif; font-size: 0.95rem;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}
.glass-input::placeholder { color: var(--text-muted); }
.glass-input:hover  { background: var(--input-bg-hover); }
.glass-input:focus  {
  border-color: var(--primary);
  background: var(--input-bg-hover);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.18);
}

/* ── Labels & dividers ──────────────────────────────────── */
.glass-label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 7px;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.glass-divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ── Typography ─────────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, #A78BFA 0%, #38BDF8 55%, #A78BFA 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 9s ease infinite;
}
html.light .gradient-text {
  background: linear-gradient(135deg, #6D28D9 0%, #0369A1 55%, #6D28D9 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 9s ease infinite;
}
@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}
.font-display { font-family: 'Syne', system-ui, sans-serif; }

/* ── Nav ────────────────────────────────────────────────── */
nav.main-nav {
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  transition: background 300ms ease, border-color 300ms ease;
}
.nav-link {
  padding: 6px 12px; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none;
  font-size: 0.875rem; font-weight: 500;
  transition: color 150ms ease, background 150ms ease;
}
.nav-link:hover { color: var(--text-primary); background: var(--surface); }

/* ── Badge / Pill ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.badge-green  { background: rgba(16,185,129,0.12); color: #34D399; border: 1px solid rgba(16,185,129,0.22); }
.badge-red    { background: rgba(239,68,68,0.12);  color: #F87171; border: 1px solid rgba(239,68,68,0.22); }
.badge-violet { background: rgba(124,58,237,0.12); color: #A78BFA; border: 1px solid rgba(124,58,237,0.22); }
.badge-blue   { background: rgba(14,165,233,0.12); color: #38BDF8; border: 1px solid rgba(14,165,233,0.22); }

html.light .badge-green  { color: #059669; }
html.light .badge-red    { color: #DC2626; }
html.light .badge-violet { color: #6D28D9; }
html.light .badge-blue   { color: #0284C7; }

/* ── Avatar ─────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #4338CA 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', system-ui, sans-serif;
  font-size: 0.8rem; font-weight: 700; color: white;
  flex-shrink: 0; user-select: none;
}

/* ── Error box ──────────────────────────────────────────── */
.error-box {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px;
  font-size: 0.875rem; color: #F87171;
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2);
}
html.light .error-box { color: #DC2626; }

/* ── Table ──────────────────────────────────────────────── */
.glass-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.glass-table th {
  padding: 10px 14px; text-align: left;
  color: var(--text-muted); font-weight: 600;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.glass-table td {
  padding: 12px 14px; color: var(--text-primary);
  border-bottom: 1px solid rgba(255,255,255,0.035);
  transition: background 120ms ease;
}
html.light .glass-table td { border-bottom: 1px solid rgba(0,0,0,0.04); }
.glass-table tr:last-child td  { border-bottom: none; }
.glass-table tr:hover td       { background: var(--surface); }

/* ╔══════════════════════════════════════════════════════╗
   ║              DASHBOARD LAYOUT                       ║
   ╚══════════════════════════════════════════════════════╝ */

.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 256px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--border); z-index: 50;
  display: flex; flex-direction: column; padding: 24px 14px;
  overflow-y: auto;
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1),
              background 300ms ease, border-color 300ms ease;
}

/* Mobile: sidebar slides in from left */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 40px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 49;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
@media (max-width: 1023px) {
  .sidebar-overlay.open { display: block; }
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-secondary); text-decoration: none;
  font-size: 0.875rem; font-weight: 500;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
  cursor: pointer; border: 1px solid transparent;
  background: none; width: 100%; text-align: left;
  font-family: 'DM Sans', system-ui, sans-serif;
}
.sidebar-link:hover { background: var(--surface-hover); color: var(--text-primary); }
.sidebar-link.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.18) 0%, rgba(67,56,202,0.12) 100%);
  color: #A78BFA; border-color: rgba(124,58,237,0.22);
}
html.light .sidebar-link.active { color: #6D28D9; }

.dashboard-main {
  margin-left: 256px; min-height: 100vh;
  transition: margin-left 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
@media (max-width: 1023px) {
  .dashboard-main { margin-left: 0; }
}

/* ── Stat card accent ───────────────────────────────────── */
.stat-card { position: relative; overflow: hidden; }
.stat-card::after {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 90px; height: 90px;
  background: radial-gradient(circle, rgba(124,58,237,0.12) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}

/* ╔══════════════════════════════════════════════════════╗
   ║              SCROLL DEMO                            ║
   ╚══════════════════════════════════════════════════════╝ */

/* Marquee tracks */
.marquee-track {
  display: flex; gap: 40px;
  animation: marquee-left 20s linear infinite;
  white-space: nowrap; will-change: transform;
}
.marquee-track.reverse { animation-name: marquee-right; }

@keyframes marquee-left {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@keyframes marquee-right {
  from { transform: translateX(-50%); }
  to   { transform: translateX(0); }
}

/* Stacking cards container */
.stack-wrapper {
  position: relative; width: 100%; max-width: 440px;
  height: 300px; margin: 0 auto;
}
.stack-card-item {
  position: absolute; inset: 0;
  border-radius: 20px; padding: 28px 32px;
  display: flex; flex-direction: column; justify-content: flex-end;
  will-change: transform, opacity;
  transition: none; /* JS controls this */
}

/* ╔══════════════════════════════════════════════════════╗
   ║              SCROLL SNAP                            ║
   ╚══════════════════════════════════════════════════════╝ */
.snap-outer {
  height: 100vh; overflow-y: scroll;
  scroll-snap-type: y mandatory; scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.snap-section {
  height: 100vh; scroll-snap-align: start;
  display: flex; flex-direction: column;
}

/* ── Mobile nav hamburger ───────────────────────────────── */
.mobile-menu-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(320px, 85vw);
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-left: 1px solid var(--border);
  z-index: 100; padding: 24px 20px;
  display: flex; flex-direction: column; gap: 8px;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}
.mobile-menu-panel.open { transform: translateX(0); }
.mobile-menu-overlay {
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(2px);
  display: none;
}
.mobile-menu-overlay.open { display: block; }
