/*
  🚀 SIGNAL SWAP - ENHANCED DESIGN SYSTEM v2.0
  State-of-the-art design system with glass morphism, advanced animations, and perfect spacing
*/

/* ================================== */
/* ENHANCED CSS CUSTOM PROPERTIES     */
/* ================================== */
:root {
  /* ===== THEME SYSTEM ===== */
  /* Dark Theme (Default) */
  --theme-bg-primary: #0a0c10;       /* Deep space background */
  --theme-bg-secondary: #12151a;     /* Card background */
  --theme-bg-tertiary: #1a1d21;      /* Navigation background */
  --theme-bg-elevated: #22272b;      /* Elevated surfaces */
  --theme-bg-interactive: #2d333b;   /* Interactive elements */
  
  /* Surface Variants with Glass Morphism */
  --glass-bg: rgba(34, 39, 43, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(20px);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  
  /* Text Hierarchy */
  --text-primary: #f8fafc;           /* Highest contrast */
  --text-secondary: #e2e8f0;         /* Primary content */
  --text-tertiary: #94a3b8;          /* Secondary content */
  --text-quaternary: #64748b;        /* Muted content */
  --text-interactive: #38bdf8;       /* Interactive text */
  
  /* Brand System */
  --brand-primary: #0ea5e9;          /* Primary brand */
  --brand-secondary: #0284c7;        /* Brand hover */
  --brand-accent: #38bdf8;           /* Accent color */
  --brand-gradient: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 50%, #06b6d4 100%);
  --brand-glow: 0 0 20px rgba(14, 165, 233, 0.3);
  
  /* Semantic Colors */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  
  /* ===== SPACING SYSTEM (4px base) ===== */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;
  
  /* ===== TYPOGRAPHY SYSTEM ===== */
  /* Font Families */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --font-display: 'Inter', sans-serif;
  
  /* Font Sizes (Fluid Scale) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.875vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.8rem + 2.25vw, 3rem);
  --text-5xl: clamp(3rem, 2.4rem + 3vw, 4rem);
  --text-6xl: clamp(3.75rem, 3rem + 3.75vw, 5rem);
  
  /* Font Weights */
  --weight-light: 300;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-black: 900;
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
  
  /* ===== BORDER RADIUS SYSTEM ===== */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;
  
  /* ===== SHADOW SYSTEM ===== */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.2);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.4);
  --shadow-glow-lg: 0 0 40px rgba(14, 165, 233, 0.6);
  
  /* ===== ANIMATION SYSTEM ===== */
  /* Timing Functions */
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Durations */
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;
  --duration-slower: 500ms;
  
  /* ===== Z-INDEX SYSTEM ===== */
  --z-base: 0;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-fixed: 30;
  --z-modal-backdrop: 40;
  --z-modal: 50;
  --z-popover: 60;
  --z-tooltip: 70;
  --z-notification: 80;
  --z-max: 999;
  
  /* ===== BREAKPOINTS ===== */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* ===== LIGHT THEME OVERRIDES ===== */
[data-theme="light"] {
  --theme-bg-primary: #ffffff;
  --theme-bg-secondary: #f8fafc;
  --theme-bg-tertiary: #f1f5f9;
  --theme-bg-elevated: #e2e8f0;
  --theme-bg-interactive: #cbd5e1;
  
  --glass-bg: rgba(248, 250, 252, 0.8);
  --glass-border: rgba(0, 0, 0, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  
  --text-primary: #0f172a;
  --text-secondary: #1e293b;
  --text-tertiary: #475569;
  --text-quaternary: #64748b;
  
  --brand-glow: 0 0 20px rgba(14, 165, 233, 0.2);
  --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.3);
  --shadow-glow-lg: 0 0 40px rgba(14, 165, 233, 0.4);
}

/* ===== AUTO THEME SWITCHING ===== */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --theme-bg-primary: #ffffff;
    --theme-bg-secondary: #f8fafc;
    --theme-bg-tertiary: #f1f5f9;
    --theme-bg-elevated: #e2e8f0;
    --theme-bg-interactive: #cbd5e1;
    
    --glass-bg: rgba(248, 250, 252, 0.8);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    
    --text-primary: #0f172a;
    --text-secondary: #1e293b;
    --text-tertiary: #475569;
    --text-quaternary: #64748b;
  }
}

/* ================================== */
/* GLASS MORPHISM COMPONENTS          */
/* ================================== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.glass-card {
  @extend .glass;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--duration-normal) var(--ease-out-quart);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow), var(--shadow-glow);
}

.glass-nav {
  @extend .glass;
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-6);
}

/* ================================== */
/* ENHANCED BUTTON SYSTEM            */
/* ================================== */
.btn {
  /* Base button styles */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out-quart);
  position: relative;
  overflow: hidden;
  user-select: none;
  
  /* Prevent button text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Button sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
}

.btn-xl {
  padding: var(--space-6) var(--space-12);
  font-size: var(--text-lg);
}

/* Primary button with glass morphism */
.btn-primary {
  background: var(--brand-gradient);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--brand-glow);
}

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

/* Glass button */
.btn-glass {
  @extend .glass;
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-glass:hover {
  background: var(--theme-bg-interactive);
  transform: translateY(-1px);
}

/* Magnetic button effect */
.btn-magnetic {
  transition: all var(--duration-fast) var(--ease-spring);
}

/* ================================== */
/* ENHANCED LAYOUT SYSTEM            */
/* ================================== */

/* Container with perfect spacing */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

@media (min-width: 768px) {
  .container {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

/* Responsive grid system */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

/* Flexbox utilities with proper spacing */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ================================== */
/* SPACING UTILITIES                  */
/* ================================== */

/* Margin utilities */
.m-0 { margin: var(--space-0); }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }

.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding utilities */
.p-0 { padding: var(--space-0); }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }

/* ================================== */
/* ANIMATION CLASSES                  */
/* ================================== */

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out-quart);
}

/* Slide in from left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-slide-in-left {
  animation: slideInLeft var(--duration-normal) var(--ease-spring);
}

/* Scale in animation */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-scale-in {
  animation: scaleIn var(--duration-fast) var(--ease-out-quart);
}

/* Glow pulse animation */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: var(--shadow-md);
  }
  50% {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
  }
}

.animate-glow-pulse {
  animation: glowPulse 2s ease-in-out infinite;
}

/* ================================== */
/* PERFORMANCE OPTIMIZATIONS         */
/* ================================== */

/* Enable hardware acceleration for animations */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

/* Smooth scrolling enhancements */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}