/* =============================================================================
   TPH GLOBAL STYLES - DESIGN SYSTEM
   Professional theme system with light/dark mode support
   Performance-optimized, no compromises
   ============================================================================= */

/* =============================================================================
   CSS CUSTOM PROPERTIES - LIGHT MODE (DEFAULT)
   ============================================================================= */

:root {
    /* =========================================================================
       COLOR PALETTE - LIGHT MODE
       ========================================================================= */
    
    /* Brand Colors */
    --color-brand-primary: #667eea;
    --color-brand-primary-hover: #5568d3;
    --color-brand-primary-active: #4557bc;
    --color-brand-primary-light: #8b9cff;
    --color-brand-primary-subtle: #e8ebff;
    
    --color-brand-secondary: #764ba2;
    --color-brand-secondary-hover: #5f3d85;
    --color-brand-secondary-active: #4a2f68;
    
    /* 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;
    
    /* Neutral Colors - Background */
    --color-bg-primary: #ffffff;
    --color-bg-secondary: #f8f9fa;
    --color-bg-tertiary: #f1f3f5;
    --color-bg-elevated: #ffffff;
    --color-bg-overlay: rgba(0, 0, 0, 0.5);
    
    /* Neutral Colors - Surface */
    --color-surface-primary: #ffffff;
    --color-surface-secondary: #f8f9fa;
    --color-surface-hover: #f1f3f5;
    --color-surface-active: #e9ecef;
    
    /* Neutral Colors - Border */
    --color-border-primary: #e0e0e0;
    --color-border-secondary: #dee2e6;
    --color-border-focus: #667eea;
    --color-border-error: #ef4444;
    
    /* Neutral Colors - Text */
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #666666;
    --color-text-tertiary: #999999;
    --color-text-disabled: #cccccc;
    --color-text-inverse: #ffffff;
    --color-text-link: #667eea;
    --color-text-link-hover: #5568d3;
    
    /* Gradient Presets */
    --gradient-brand-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-brand-subtle: linear-gradient(135deg, #e8ebff 0%, #f3e7f9 100%);
    --gradient-surface: linear-gradient(to bottom, #ffffff, #f8f9fa);
    --gradient-overlay: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
    
    /* =========================================================================
       SHADOWS
       ========================================================================= */
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
    --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.20);
    --shadow-2xl: 0 24px 48px rgba(0, 0, 0, 0.24);
    
    /* Focus Shadow */
    --shadow-focus: 0 0 0 3px rgba(102, 126, 234, 0.3);
    --shadow-focus-error: 0 0 0 3px rgba(239, 68, 68, 0.3);
    
    /* Inset Shadows */
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    
    /* =========================================================================
       TYPOGRAPHY
       ========================================================================= */
    
    /* Font Families */
    --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                        'Helvetica Neue', Arial, sans-serif;
    --font-family-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 
                        'Courier New', monospace;
    
    /* Font Sizes */
    --font-size-xs: 0.75rem;      /* 12px */
    --font-size-sm: 0.875rem;     /* 14px */
    --font-size-base: 1rem;       /* 16px */
    --font-size-lg: 1.125rem;     /* 18px */
    --font-size-xl: 1.25rem;      /* 20px */
    --font-size-2xl: 1.5rem;      /* 24px */
    --font-size-3xl: 1.875rem;    /* 30px */
    --font-size-4xl: 2.25rem;     /* 36px */
    --font-size-5xl: 3rem;        /* 48px */
    --font-size-6xl: 3.75rem;     /* 60px */
    
    /* Font Weights */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;
    --font-weight-black: 900;
    
    /* Line Heights */
    --line-height-none: 1;
    --line-height-tight: 1.25;
    --line-height-snug: 1.375;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    --line-height-loose: 2;
    
    /* Letter Spacing */
    --letter-spacing-tighter: -0.05em;
    --letter-spacing-tight: -0.025em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;
    --letter-spacing-wider: 0.05em;
    --letter-spacing-widest: 0.1em;
    
    /* =========================================================================
       SPACING SYSTEM (8px base unit)
       ========================================================================= */
    
    --space-0: 0;
    --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-7: 1.75rem;   /* 28px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    --space-20: 5rem;     /* 80px */
    --space-24: 6rem;     /* 96px */
    
    /* =========================================================================
       BORDER RADIUS
       ========================================================================= */
    
    --radius-none: 0;
    --radius-sm: 0.375rem;    /* 6px */
    --radius-base: 0.5rem;    /* 8px */
    --radius-md: 0.75rem;     /* 12px */
    --radius-lg: 1rem;        /* 16px */
    --radius-xl: 1.25rem;     /* 20px */
    --radius-2xl: 1.5rem;     /* 24px */
    --radius-3xl: 2rem;       /* 32px */
    --radius-full: 9999px;
    
    /* =========================================================================
       TRANSITIONS & ANIMATIONS
       ========================================================================= */
    
    /* Easing Functions */
    --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-sharp: cubic-bezier(0.4, 0, 0.6, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Duration */
    --duration-instant: 50ms;
    --duration-fast: 150ms;
    --duration-base: 200ms;
    --duration-slow: 300ms;
    --duration-slower: 500ms;
    
    /* Combined Transitions */
    --transition-fast: var(--duration-fast) var(--ease-in-out);
    --transition-base: var(--duration-base) var(--ease-in-out);
    --transition-slow: var(--duration-slow) var(--ease-in-out);
    
    /* =========================================================================
       Z-INDEX SCALE
       ========================================================================= */
    
    --z-base: 0;
    --z-dropdown: 1000;
    --z-sticky: 1100;
    --z-fixed: 1200;
    --z-modal-backdrop: 1300;
    --z-modal: 1400;
    --z-popover: 1500;
    --z-tooltip: 1600;
    --z-notification: 1700;
    --z-maximum: 9999;
    
    /* =========================================================================
       BREAKPOINTS (for reference in JS)
       ========================================================================= */
    
    --breakpoint-xs: 320px;
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
    --breakpoint-2xl: 1536px;
    
    /* =========================================================================
       LAYOUT CONSTRAINTS
       ========================================================================= */
    
    --container-max-width: 1400px;
    --viewport-margin: 20px;
    --header-height: 80px;
}

/* =============================================================================
   DARK MODE THEME
   ============================================================================= */

body.dark-mode {
    /* =========================================================================
       COLOR PALETTE - DARK MODE
       ========================================================================= */
    
    /* Brand Colors (adjusted for dark backgrounds) */
    --color-brand-primary: #8b9cff;
    --color-brand-primary-hover: #a5b3ff;
    --color-brand-primary-active: #bec9ff;
    --color-brand-primary-light: #667eea;
    --color-brand-primary-subtle: #1e2338;
    
    --color-brand-secondary: #9d6dc4;
    --color-brand-secondary-hover: #b38ad4;
    --color-brand-secondary-active: #c9a7e4;
    
    /* Semantic Colors (adjusted) */
    --color-success: #34d399;
    --color-success-light: #064e3b;
    --color-warning: #fbbf24;
    --color-warning-light: #78350f;
    --color-error: #f87171;
    --color-error-light: #7f1d1d;
    --color-info: #60a5fa;
    --color-info-light: #1e3a8a;
    
    /* Neutral Colors - Background */
    --color-bg-primary: #0f0f1a;
    --color-bg-secondary: #16162a;
    --color-bg-tertiary: #1a1a2e;
    --color-bg-elevated: #1e1e32;
    --color-bg-overlay: rgba(0, 0, 0, 0.75);
    
    /* Neutral Colors - Surface */
    --color-surface-primary: #1a1a2e;
    --color-surface-secondary: #1e1e32;
    --color-surface-hover: #252541;
    --color-surface-active: #2a2a45;
    
    /* Neutral Colors - Border */
    --color-border-primary: #2a2a3e;
    --color-border-secondary: #323250;
    --color-border-focus: #8b9cff;
    --color-border-error: #f87171;
    
    /* Neutral Colors - Text */
    --color-text-primary: #e8e8f0;
    --color-text-secondary: #b0b0c0;
    --color-text-tertiary: #808090;
    --color-text-disabled: #505060;
    --color-text-inverse: #0f0f1a;
    --color-text-link: #8b9cff;
    --color-text-link-hover: #a5b3ff;
    
    /* Gradient Presets */
    --gradient-brand-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-brand-subtle: linear-gradient(135deg, #1e2338 0%, #251e32 100%);
    --gradient-surface: linear-gradient(to bottom, #1a1a2e, #16162a);
    --gradient-overlay: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.9));
    
    /* =========================================================================
       SHADOWS - DARK MODE
       ========================================================================= */
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.7);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.85);
    --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.9);
    --shadow-2xl: 0 24px 48px rgba(0, 0, 0, 0.95);
    
    /* Focus Shadow */
    --shadow-focus: 0 0 0 3px rgba(139, 156, 255, 0.4);
    --shadow-focus-error: 0 0 0 3px rgba(248, 113, 113, 0.4);
    
    /* Inset Shadows */
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* =============================================================================
   BASE STYLES
   ============================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    transition: background-color var(--transition-slow),
                color var(--transition-slow);
    min-height: 100vh;
}

/* =============================================================================
   TYPOGRAPHY CLASSES
   ============================================================================= */

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }
.text-4xl { font-size: var(--font-size-4xl); }
.text-5xl { font-size: var(--font-size-5xl); }
.text-6xl { font-size: var(--font-size-6xl); }

.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.font-extrabold { font-weight: var(--font-weight-extrabold); }
.font-black { font-weight: var(--font-weight-black); }

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-brand { color: var(--color-brand-primary); }

/* =============================================================================
   HEADING STYLES
   ============================================================================= */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--color-text-primary);
    margin: 0;
}

h1 { font-size: var(--font-size-5xl); }
h2 { font-size: var(--font-size-4xl); }
h3 { font-size: var(--font-size-3xl); }
h4 { font-size: var(--font-size-2xl); }
h5 { font-size: var(--font-size-xl); }
h6 { font-size: var(--font-size-lg); }

/* =============================================================================
   LINK STYLES
   ============================================================================= */

a {
    color: var(--color-text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-text-link-hover);
}

a:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* =============================================================================
   BUTTON RESET
   ============================================================================= */

button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* =============================================================================
   FOCUS STATES (GLOBAL)
   ============================================================================= */

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* =============================================================================
   SELECTION STYLES
   ============================================================================= */

::selection {
    background-color: var(--color-brand-primary-light);
    color: var(--color-text-inverse);
}

::-moz-selection {
    background-color: var(--color-brand-primary-light);
    color: var(--color-text-inverse);
}

/* =============================================================================
   SCROLLBAR STYLES
   ============================================================================= */

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-brand-primary);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-brand-primary-hover);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-brand-primary) var(--color-bg-secondary);
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

.gradient-brand-text {
    background: var(--gradient-brand-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-brand-bg {
    background: var(--gradient-brand-primary);
}

/* =============================================================================
   PERFORMANCE OPTIMIZATIONS
   ============================================================================= */

@media (prefers-contrast: high) {
    :root {
        --color-border-primary: #000000;
        --color-text-secondary: #333333;
    }
    
    body.dark-mode {
        --color-border-primary: #ffffff;
        --color-text-secondary: #cccccc;
    }
}

/* Force GPU acceleration for common animated elements */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a {
        text-decoration: underline;
    }
}