/* ═══════════════════════════════════════════════════════
   NEXUSCODE — Cyberpunk Design System
   Neon-soaked, dark-UI aesthetic with electric accents
   ═══════════════════════════════════════════════════════ */

:root {
  /* ── Core Palette ── */
  --bg-void:            #06060b;
  --bg-deep:            #0a0a12;
  --bg-base:            #0e0e18;
  --bg-surface:         #13131f;
  --bg-elevated:        #1a1a2e;
  --bg-overlay:         rgba(10, 10, 18, 0.92);

  /* ── Neon Accents ── */
  --neon-cyan:          #00f0ff;
  --neon-cyan-dim:      #00f0ff80;
  --neon-cyan-ghost:    #00f0ff15;
  --neon-magenta:       #ff00aa;
  --neon-magenta-dim:   #ff00aa80;
  --neon-magenta-ghost: #ff00aa15;
  --neon-purple:        #8b5cf6;
  --neon-purple-dim:    #8b5cf680;
  --neon-yellow:        #ffd93d;
  --neon-yellow-dim:    #ffd93d80;
  --neon-green:         #00ff88;
  --neon-green-dim:     #00ff8880;
  --neon-red:           #ff4757;
  --neon-red-dim:       #ff475780;
  --neon-orange:        #ff8c42;

  /* ── Text ── */
  --text-primary:       #e8eaf0;
  --text-secondary:     #8b8fa8;
  --text-muted:         #565874;
  --text-inverse:       #0a0a12;

  /* ── Borders ── */
  --border-subtle:      rgba(255, 255, 255, 0.06);
  --border-default:     rgba(255, 255, 255, 0.1);
  --border-strong:      rgba(255, 255, 255, 0.18);
  --border-neon:        rgba(0, 240, 255, 0.25);
  --border-neon-strong: rgba(0, 240, 255, 0.5);

  /* ── Glow Effects ── */
  --glow-cyan:          0 0 20px rgba(0, 240, 255, 0.3), 0 0 60px rgba(0, 240, 255, 0.1);
  --glow-magenta:       0 0 20px rgba(255, 0, 170, 0.3), 0 0 60px rgba(255, 0, 170, 0.1);
  --glow-purple:        0 0 20px rgba(139, 92, 246, 0.3), 0 0 60px rgba(139, 92, 246, 0.1);
  --glow-subtle:        0 0 10px rgba(0, 240, 255, 0.1);
  --glow-inset:         inset 0 0 30px rgba(0, 240, 255, 0.03);

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

  /* ── Typography ── */
  --font-ui:            'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:          'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --text-xs:            0.6875rem;
  --text-sm:            0.75rem;
  --text-base:          0.8125rem;
  --text-md:            0.875rem;
  --text-lg:            1rem;
  --text-xl:            1.25rem;
  --text-2xl:           1.5rem;

  /* ── Radius ── */
  --radius-sm:          4px;
  --radius-md:          6px;
  --radius-lg:          10px;
  --radius-xl:          14px;
  --radius-full:        9999px;

  /* ── Transitions ── */
  --ease-out:           cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:        cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:      120ms;
  --duration-normal:    200ms;
  --duration-slow:      350ms;

  /* ── Z-Index Scale ── */
  --z-panel:            1;
  --z-divider:          10;
  --z-topbar:           100;
  --z-modal:            1000;
  --z-toast:            2000;
  --z-tooltip:          3000;

  /* ── Layout ── */
  --topbar-height:      48px;
  --bottombar-height:   28px;
  --tab-height:         36px;
  --console-header-height: 32px;
  --divider-size:       6px;
}

/* ── Light Mode Overrides ── */
[data-theme="cyberpunk-light"] {
  --bg-void:            #f0f1f5;
  --bg-deep:            #e8e9ee;
  --bg-base:            #ffffff;
  --bg-surface:         #f5f6fa;
  --bg-elevated:        #ffffff;
  --bg-overlay:         rgba(255, 255, 255, 0.95);
  --text-primary:       #1a1a2e;
  --text-secondary:     #565874;
  --text-muted:         #8b8fa8;
  --border-subtle:      rgba(0, 0, 0, 0.06);
  --border-default:     rgba(0, 0, 0, 0.1);
  --border-strong:      rgba(0, 0, 0, 0.18);
  --glow-subtle:        0 0 10px rgba(0, 240, 255, 0.06);
  --glow-inset:         inset 0 0 30px rgba(0, 240, 255, 0.01);
}

/* ═══════════════════════════════════════════════════════
   BASE RESET & FOUNDATIONS
   ═══════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-void);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  line-height: 1.5;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(0, 240, 255, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 90%, rgba(255, 0, 170, 0.03) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 50% 50%, rgba(139, 92, 246, 0.02) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: bgPulse 20s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.7; }
  100% { opacity: 1; }
}

[data-theme="cyberpunk-light"] body::before {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(0, 240, 255, 0.02) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 90%, rgba(255, 0, 170, 0.015) 0%, transparent 60%);
  animation: none;
}

/* Selection */
::selection {
  background: var(--neon-cyan-dim);
  color: var(--text-inverse);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan-dim);
}

/* Scrollbar Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════
   ANIMATION UTILITIES
   ═══════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: var(--glow-subtle); }
  50%      { box-shadow: var(--glow-cyan); }
}

@keyframes neonFlicker {
  0%, 100% { opacity: 1; }
  92%      { opacity: 1; }
  93%      { opacity: 0.8; }
  94%      { opacity: 1; }
  96%      { opacity: 0.9; }
  97%      { opacity: 1; }
}

@keyframes scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

@keyframes borderGlow {
  0%, 100% { border-color: var(--border-neon); }
  50%      { border-color: var(--border-neon-strong); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(100%) scale(0.9); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════
   GLASSMORPHISM UTILITY
   ═══════════════════════════════════════════════════════ */

.glass {
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
}

.glass-elevated {
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-default);
}

/* ═══════════════════════════════════════════════════════
   NEON BUTTON UTILITY
   ═══════════════════════════════════════════════════════ */

.neon-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--neon-cyan);
  border-radius: var(--radius-md);
  background: var(--neon-cyan-ghost);
  color: var(--neon-cyan);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  text-decoration: none;
}

.neon-btn:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: var(--glow-subtle);
  transform: translateY(-1px);
}

.neon-btn:active {
  transform: translateY(0);
}

.neon-btn--magenta {
  border-color: var(--neon-magenta);
  background: var(--neon-magenta-ghost);
  color: var(--neon-magenta);
}

.neon-btn--magenta:hover {
  background: rgba(255, 0, 170, 0.15);
  box-shadow: 0 0 10px rgba(255, 0, 170, 0.2);
}

/* ═══════════════════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════════════════ */

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-default);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ═══════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + var(--sp-4));
  right: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastIn var(--duration-slow) var(--ease-spring);
  pointer-events: auto;
  max-width: 360px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toast.removing {
  animation: toastOut var(--duration-normal) var(--ease-out) forwards;
}

.toast-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.toast--success { border-color: var(--neon-green-dim); }
.toast--success .toast-icon { color: var(--neon-green); }
.toast--error   { border-color: var(--neon-red-dim); }
.toast--error .toast-icon { color: var(--neon-red); }
.toast--info    { border-color: var(--neon-cyan-dim); }
.toast--info .toast-icon { color: var(--neon-cyan); }
.toast--warn    { border-color: var(--neon-yellow-dim); }
.toast--warn .toast-icon { color: var(--neon-yellow); }
