/**
 * Design Tokens - CSS Custom Properties
 * Centralized design system for maintainability and consistency
 * Phase 3 Optimization: McKinsey Grade Frontend Audit
 */

:root {
    /* === Color Palette === */
    /* Primary Brand Colors */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    
    /* Neutral Grays */
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    
    /* Semantic Colors */
    --color-success: #10b981;
    --color-success-light: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-error: #ef4444;
    --color-error-light: #fee2e2;
    --color-info: #3b82f6;
    --color-info-light: #dbeafe;
    
    /* === Typography === */
    --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-family-mono: 'SF Mono', 'Consolas', 'Monaco', monospace;
    
    /* Font Sizes (fluid typography) */
    --font-size-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --font-size-sm: clamp(0.875rem, 0.8rem + 0.3vw, 1rem);
    --font-size-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    --font-size-lg: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
    --font-size-xl: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
    --font-size-2xl: clamp(1.5rem, 1.35rem + 0.75vw, 2rem);
    --font-size-3xl: clamp(1.875rem, 1.65rem + 1.125vw, 2.5rem);
    
    /* Font Weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* Line Heights */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
    
    /* === Spacing === */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    
    /* === Border Radius === */
    --radius-sm: 0.25rem;   /* 4px */
    --radius-md: 0.375rem;  /* 6px */
    --radius-lg: 0.5rem;    /* 8px */
    --radius-xl: 0.75rem;   /* 12px */
    --radius-2xl: 1rem;     /* 16px */
    --radius-full: 9999px;  /* Pill shape */
    
    /* === Shadows === */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* === Z-Index === */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    
    /* === Transitions === */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* === Motion/Animation Tokens === */
    /* Easing curves */
    --ease-linear: linear;
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    
    /* Duration tokens */
    --duration-instant: 50ms;
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
    --duration-slower: 600ms;
    --duration-slowest: 1000ms;
    
    /* Animation presets */
    --animation-fade-in: fade-in var(--duration-normal) var(--ease-out);
    --animation-slide-up: slide-up var(--duration-normal) var(--ease-spring);
    --animation-slide-down: slide-down var(--duration-normal) var(--ease-spring);
    --animation-scale-in: scale-in var(--duration-fast) var(--ease-spring);
    --animation-spin: spin var(--duration-slowest) var(--ease-linear) infinite;
    --animation-pulse: pulse 2s var(--ease-in-out) infinite;
    --animation-bounce: bounce var(--duration-slow) var(--ease-bounce);
    
    /* Stagger delays for sequential animations */
    --stagger-1: 50ms;
    --stagger-2: 100ms;
    --stagger-3: 150ms;
    --stagger-4: 200ms;
    --stagger-5: 250ms;
    
    /* === Component Tokens === */
    /* Cards */
    --card-padding: var(--space-6);
    --card-padding-sm: var(--space-4);
    --card-padding-lg: var(--space-8);
    --card-radius: var(--radius-xl);
    --card-shadow: var(--shadow-md);
    --card-shadow-hover: var(--shadow-lg);
    --card-border: 1px solid var(--color-gray-200);
    --card-bg: #ffffff;
    --card-bg-elevated: #ffffff;
    
    /* Buttons */
    --btn-padding-x: var(--space-4);
    --btn-padding-y: var(--space-3);
    --btn-radius: var(--radius-lg);
    --btn-font-weight: var(--font-weight-semibold);
    --btn-transition: all var(--duration-fast) var(--ease-spring);
    
    /* Inputs */
    --input-padding-x: var(--space-4);
    --input-padding-y: var(--space-3);
    --input-radius: var(--radius-lg);
    --input-border: 1px solid var(--color-gray-300);
    --input-border-focus: 2px solid var(--color-primary);
    --input-bg: #ffffff;
    
    /* Badges */
    --badge-padding-x: var(--space-3);
    --badge-padding-y: var(--space-1);
    --badge-radius: var(--radius-full);
    --badge-font-size: var(--font-size-xs);
    --badge-font-weight: var(--font-weight-semibold);
    
    /* Tooltips */
    --tooltip-bg: var(--color-gray-900);
    --tooltip-color: #ffffff;
    --tooltip-radius: var(--radius-md);
    --tooltip-padding: var(--space-2) var(--space-3);
    
    /* Modals */
    --modal-radius: var(--radius-2xl);
    --modal-shadow: var(--shadow-2xl);
    --modal-backdrop: rgba(0, 0, 0, 0.5);
    --modal-padding: var(--space-6);
    
    /* === Elevation/Depth System === */
    --elevation-0: none;
    --elevation-1: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --elevation-2: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --elevation-3: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --elevation-4: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    --elevation-5: 0 25px 50px rgba(0, 0, 0, 0.25);
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-blur: blur(12px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
    
    /* === Breakpoints (for JS usage) === */
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
    --breakpoint-2xl: 1536px;
    
    /* === Component-Specific === */
    --sidebar-width: 280px;
    --header-height: 64px;
    --input-height: 40px;
    --button-height: 40px;
    
    /* === Performance Optimizations === */
    /* GPU-accelerated properties */
    --gpu-transform: translateZ(0);
    --gpu-backface: hidden;
}

/* Dark Mode Overrides (Future Phase) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-gray-50: #111827;
        --color-gray-100: #1f2937;
        --color-gray-900: #f9fafb;
        /* Add dark mode tokens as needed */
    }
}

/* Reduced Motion Preference (Accessibility) */
@media (prefers-reduced-motion: reduce) {
    :root {
        --transition-fast: 0ms;
        --transition-base: 0ms;
        --transition-slow: 0ms;
        --duration-fast: 0ms;
        --duration-normal: 0ms;
        --duration-slow: 0ms;
    }
}

/* === Global Keyframe Animations === */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slide-up {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-down {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-right {
    from { 
        opacity: 0;
        transform: translateX(20px);
    }
    to { 
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slide-in-left {
    from { 
        opacity: 0;
        transform: translateX(-20px);
    }
    to { 
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scale-in {
    from { 
        opacity: 0;
        transform: scale(0.95);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scale-out {
    from { 
        opacity: 1;
        transform: scale(1);
    }
    to { 
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes spring-in {
    0% { 
        opacity: 0;
        transform: scale(0.9);
    }
    50% { 
        transform: scale(1.02);
    }
    100% { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 100% { 
        transform: translateY(0);
    }
    50% { 
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0%, 100% { 
        opacity: 1;
    }
    50% { 
        opacity: 0.5;
    }
}

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

@keyframes shimmer {
    0% { 
        background-position: -200% 0;
    }
    100% { 
        background-position: 200% 0;
    }
}

@keyframes float {
    0%, 100% { 
        transform: translateY(0);
    }
    50% { 
        transform: translateY(-5px);
    }
}

@keyframes glow-pulse {
    0%, 100% { 
        box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
    }
    50% { 
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.8);
    }
}

/* === Animation Utility Classes === */
.animate-fade-in { animation: fade-in var(--duration-normal) var(--ease-out) forwards; }
.animate-slide-up { animation: slide-up var(--duration-normal) var(--ease-spring) forwards; }
.animate-slide-down { animation: slide-down var(--duration-normal) var(--ease-spring) forwards; }
.animate-scale-in { animation: scale-in var(--duration-fast) var(--ease-spring) forwards; }
.animate-spring-in { animation: spring-in var(--duration-slow) var(--ease-spring) forwards; }
.animate-bounce { animation: bounce var(--duration-slow) var(--ease-bounce) infinite; }
.animate-pulse { animation: pulse 2s var(--ease-in-out) infinite; }
.animate-spin { animation: spin 1s var(--ease-linear) infinite; }
.animate-shimmer { 
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite; 
}
.animate-float { animation: float 3s var(--ease-in-out) infinite; }
.animate-glow { animation: glow-pulse 2s var(--ease-in-out) infinite; }

/* Stagger animation delays */
.stagger-1 { animation-delay: var(--stagger-1); }
.stagger-2 { animation-delay: var(--stagger-2); }
.stagger-3 { animation-delay: var(--stagger-3); }
.stagger-4 { animation-delay: var(--stagger-4); }
.stagger-5 { animation-delay: var(--stagger-5); }

/* Hover transition utilities */
.hover-lift {
    transition: transform var(--duration-fast) var(--ease-spring), 
                box-shadow var(--duration-fast) var(--ease-out);
}
.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--elevation-3);
}

.hover-scale {
    transition: transform var(--duration-fast) var(--ease-spring);
}
.hover-scale:hover {
    transform: scale(1.02);
}

.hover-glow {
    transition: box-shadow var(--duration-fast) var(--ease-out);
}
.hover-glow:hover {
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}
