/**
 * Chap Design System - CSS Variables
 * Contains all design tokens for colors, typography, spacing, etc.
 */

:root {
    /* ===== Color Scheme (Light Mode Default) ===== */
    --color-scheme: light;
    
    /* Backgrounds */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8ed;
    --bg-elevated: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.72);
    --bg-glass-heavy: rgba(255, 255, 255, 0.85);
    
    /* Text */
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --text-inverse: #ffffff;
    
    /* Borders */
    --border-primary: rgba(0, 0, 0, 0.08);
    --border-secondary: rgba(0, 0, 0, 0.12);
    --border-tertiary: rgba(0, 0, 0, 0.18);
    
    /* Accent Colors */
    --accent-blue: #0071e3;
    --accent-blue-hover: #0077ed;
    --accent-blue-active: #006edb;
    --accent-blue-subtle: rgba(0, 113, 227, 0.1);
    
    --accent-green: #34c759;
    --accent-green-subtle: rgba(52, 199, 89, 0.12);
    
    --accent-yellow: #ff9f0a;
    --accent-yellow-subtle: rgba(255, 159, 10, 0.12);
    
    --accent-orange: #ff9500;
    --accent-orange-subtle: rgba(255, 149, 0, 0.12);
    
    --accent-red: #ff3b30;
    --accent-red-hover: #ff453a;
    --accent-red-subtle: rgba(255, 59, 48, 0.12);
    
    --accent-purple: #af52de;
    --accent-purple-subtle: rgba(175, 82, 222, 0.12);
    
    --accent-pink: #ff2d55;
    --accent-pink-subtle: rgba(255, 45, 85, 0.12);
    
    --accent-teal: #5ac8fa;
    --accent-teal-subtle: rgba(90, 200, 250, 0.12);
    
    --accent-gray: #8e8e93;
    --accent-gray-subtle: rgba(142, 142, 147, 0.12);
    
    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
    --shadow-glow-blue: 0 0 0 3px rgba(0, 113, 227, 0.2);
    --shadow-glow-red: 0 0 0 3px rgba(255, 59, 48, 0.2);
    
    /* ===== Typography ===== */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 
                 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', 
                 Menlo, Consolas, 'Liberation Mono', monospace;
    
    /* Font Sizes */
    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-lg: 1.0625rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    
    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.2;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    
    /* Letter Spacing */
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide: 0.02em;
    
    /* ===== Spacing ===== */
    --space-0: 0;
    --space-px: 1px;
    --space-0-5: 0.125rem;
    --space-1: 0.25rem;
    --space-1-5: 0.375rem;
    --space-2: 0.5rem;
    --space-2-5: 0.625rem;
    --space-3: 0.75rem;
    --space-3-5: 0.875rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-7: 1.75rem;
    --space-8: 2rem;
    --space-9: 2.25rem;
    --space-10: 2.5rem;
    --space-11: 2.75rem;
    --space-12: 3rem;
    --space-14: 3.5rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    --space-28: 7rem;
    --space-32: 8rem;
    
    /* ===== Border Radius ===== */
    --radius-none: 0;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-2xl: 28px;
    --radius-full: 9999px;
    
    /* ===== Transitions ===== */
    --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    
    --duration-fast: 150ms;
    --duration-base: 200ms;
    --duration-slow: 300ms;
    --duration-slower: 400ms;
    
    --transition-colors: color var(--duration-fast) var(--ease-default),
                         background-color var(--duration-fast) var(--ease-default),
                         border-color var(--duration-fast) var(--ease-default);
    --transition-transform: transform var(--duration-fast) var(--ease-default);
    --transition-shadow: box-shadow var(--duration-fast) var(--ease-default);
    --transition-opacity: opacity var(--duration-fast) var(--ease-default);
    --transition-all: all var(--duration-base) var(--ease-default);
    
    /* ===== Z-Index Scale ===== */
    --z-dropdown: 250;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-popover: 600;
    --z-tooltip: 700;
    --z-toast: 800;
    
    /* ===== Layout ===== */
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 72px;
    --header-height: 64px;
    --content-max-width: 1400px;
    --form-max-width: 640px;
    
    /* ===== Breakpoints (for reference in JS) ===== */
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
    --breakpoint-2xl: 1536px;
}

/* ===== Dark Mode ===== */
[data-theme="dark"],
.dark {
    --color-scheme: dark;
    
    /* Backgrounds */
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-elevated: #2c2c2e;
    --bg-glass: rgba(28, 28, 30, 0.72);
    --bg-glass-heavy: rgba(28, 28, 30, 0.85);
    
    /* Text */
    --text-primary: #f5f5f7;
    --text-secondary: #98989d;
    --text-tertiary: #6e6e73;
    --text-inverse: #1d1d1f;
    
    /* Borders */
    --border-primary: rgba(255, 255, 255, 0.08);
    --border-secondary: rgba(255, 255, 255, 0.12);
    --border-tertiary: rgba(255, 255, 255, 0.18);
    
    /* Accent Colors - slightly brighter for dark mode */
    --accent-blue: #0a84ff;
    --accent-blue-hover: #409cff;
    --accent-blue-active: #0077ed;
    --accent-blue-subtle: rgba(10, 132, 255, 0.15);
    
    --accent-green: #30d158;
    --accent-green-subtle: rgba(48, 209, 88, 0.15);
    
    --accent-yellow: #ffd60a;
    --accent-yellow-subtle: rgba(255, 214, 10, 0.15);
    
    --accent-orange: #ff9f0a;
    --accent-orange-subtle: rgba(255, 159, 10, 0.15);
    
    --accent-red: #ff453a;
    --accent-red-hover: #ff6961;
    --accent-red-subtle: rgba(255, 69, 58, 0.15);
    
    --accent-purple: #bf5af2;
    --accent-purple-subtle: rgba(191, 90, 242, 0.15);
    
    --accent-pink: #ff375f;
    --accent-pink-subtle: rgba(255, 55, 95, 0.15);
    
    --accent-teal: #64d2ff;
    --accent-teal-subtle: rgba(100, 210, 255, 0.15);
    
    --accent-gray: #98989d;
    --accent-gray-subtle: rgba(152, 152, 157, 0.15);
    
    /* Shadows - darker for dark mode */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow-blue: 0 0 0 3px rgba(10, 132, 255, 0.3);
    --shadow-glow-red: 0 0 0 3px rgba(255, 69, 58, 0.3);
}

/* System preference detection (when no explicit theme set) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --color-scheme: dark;
        
        --bg-primary: #000000;
        --bg-secondary: #1c1c1e;
        --bg-tertiary: #2c2c2e;
        --bg-elevated: #2c2c2e;
        --bg-glass: rgba(28, 28, 30, 0.72);
        --bg-glass-heavy: rgba(28, 28, 30, 0.85);
        
        --text-primary: #f5f5f7;
        --text-secondary: #98989d;
        --text-tertiary: #6e6e73;
        --text-inverse: #1d1d1f;
        
        --border-primary: rgba(255, 255, 255, 0.08);
        --border-secondary: rgba(255, 255, 255, 0.12);
        --border-tertiary: rgba(255, 255, 255, 0.18);
        
        --accent-blue: #0a84ff;
        --accent-blue-hover: #409cff;
        --accent-blue-active: #0077ed;
        --accent-blue-subtle: rgba(10, 132, 255, 0.15);
        
        --accent-green: #30d158;
        --accent-green-subtle: rgba(48, 209, 88, 0.15);
        
        --accent-yellow: #ffd60a;
        --accent-yellow-subtle: rgba(255, 214, 10, 0.15);
        
        --accent-orange: #ff9f0a;
        --accent-orange-subtle: rgba(255, 159, 10, 0.15);
        
        --accent-red: #ff453a;
        --accent-red-hover: #ff6961;
        --accent-red-subtle: rgba(255, 69, 58, 0.15);
        
        --accent-purple: #bf5af2;
        --accent-purple-subtle: rgba(191, 90, 242, 0.15);
        
        --accent-pink: #ff375f;
        --accent-pink-subtle: rgba(255, 55, 95, 0.15);
        
        --accent-teal: #64d2ff;
        --accent-teal-subtle: rgba(100, 210, 255, 0.15);
        
        --accent-gray: #98989d;
        --accent-gray-subtle: rgba(152, 152, 157, 0.15);
        
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
        --shadow-glow-blue: 0 0 0 3px rgba(10, 132, 255, 0.3);
        --shadow-glow-red: 0 0 0 3px rgba(255, 69, 58, 0.3);
    }
}
