/* Theme Management Styles */

/* Theme Variables */
:root {
    /* Light Theme - Default */
    --theme-name: 'light';
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #e2e8f0;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --border-primary: #e2e8f0;
    --border-secondary: #cbd5e0;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --shadow-heavy: rgba(0, 0, 0, 0.25);
    
    /* Color Palette - Light */
    --primary-50: #f0f9ff;
    --primary-100: #e0f2fe;
    --primary-200: #bae6fd;
    --primary-300: #7dd3fc;
    --primary-400: #38bdf8;
    --primary-500: #0ea5e9;
    --primary-600: #0284c7;
    --primary-700: #0369a1;
    --primary-800: #075985;
    --primary-900: #0c4a6e;
    
    --secondary-50: #faf5ff;
    --secondary-100: #f3e8ff;
    --secondary-200: #e9d5ff;
    --secondary-300: #d8b4fe;
    --secondary-400: #c084fc;
    --secondary-500: #a855f7;
    --secondary-600: #9333ea;
    --secondary-700: #7c3aed;
    --secondary-800: #6b21a8;
    --secondary-900: #581c87;
    
    --accent-50: #f0fdfa;
    --accent-100: #ccfbf1;
    --accent-200: #99f6e4;
    --accent-300: #5eead4;
    --accent-400: #2dd4bf;
    --accent-500: #14b8a6;
    --accent-600: #0d9488;
    --accent-700: #0f766e;
    --accent-800: #115e59;
    --accent-900: #134e4a;
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Gradient Backgrounds */
    --gradient-primary: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    --gradient-secondary: linear-gradient(135deg, var(--secondary-500), var(--accent-500));
    --gradient-accent: linear-gradient(135deg, var(--accent-500), var(--primary-500));
    --gradient-mesh: linear-gradient(135deg, var(--primary-500) 0%, var(--secondary-500) 25%, var(--accent-500) 50%, var(--primary-500) 75%, var(--secondary-500) 100%);
    
    /* Glass Morphism */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    
    /* Neon Effects */
    --neon-primary: #00ffff;
    --neon-secondary: #ff00ff;
    --neon-accent: #00ff00;
    
    /* Interactive States */
    --hover-bg: rgba(0, 0, 0, 0.05);
    --active-bg: rgba(0, 0, 0, 0.1);
    --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.5);
}

/* Dark Theme */
[data-theme="dark"] {
    --theme-name: 'dark';
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-primary: #334155;
    --border-secondary: #475569;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --shadow-heavy: rgba(0, 0, 0, 0.6);
    
    /* Color Palette - Dark (adjusted for better contrast) */
    --primary-50: #0f172a;
    --primary-100: #1e293b;
    --primary-200: #334155;
    --primary-300: #475569;
    --primary-400: #64748b;
    --primary-500: #818cf8;
    --primary-600: #a5b4fc;
    --primary-700: #c7d2fe;
    --primary-800: #e0e7ff;
    --primary-900: #eef2ff;
    
    --secondary-50: #1e1b4b;
    --secondary-100: #312e81;
    --secondary-200: #3730a3;
    --secondary-300: #4338ca;
    --secondary-400: #6366f1;
    --secondary-500: #818cf8;
    --secondary-600: #a5b4fc;
    --secondary-700: #c7d2fe;
    --secondary-800: #e0e7ff;
    --secondary-900: #eef2ff;
    
    --accent-50: #022c22;
    --accent-100: #064e3b;
    --accent-200: #065f46;
    --accent-300: #047857;
    --accent-400: #059669;
    --accent-500: #10b981;
    --accent-600: #34d399;
    --accent-700: #6ee7b7;
    --accent-800: #a7f3d0;
    --accent-900: #d1fae5;
    
    /* Glass Morphism - Dark */
    --glass-bg: rgba(15, 23, 42, 0.3);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    
    /* Interactive States - Dark */
    --hover-bg: rgba(255, 255, 255, 0.1);
    --active-bg: rgba(255, 255, 255, 0.2);
    --focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.5);
}

/* High Contrast Theme */
[data-theme="high-contrast"] {
    --theme-name: 'high-contrast';
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #333333;
    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --text-tertiary: #cccccc;
    --border-primary: #ffffff;
    --border-secondary: #ffffff;
    --shadow-light: rgba(255, 255, 255, 0.3);
    --shadow-medium: rgba(255, 255, 255, 0.4);
    --shadow-heavy: rgba(255, 255, 255, 0.6);
    
    --primary-500: #ffffff;
    --secondary-500: #ffff00;
    --accent-500: #00ff00;
    
    --glass-bg: rgba(0, 0, 0, 0.8);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(255, 255, 255, 0.3);
}

/* Theme Transition */
* {
    transition: 
        background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease,
        box-shadow 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
    position: relative;
    width: 60px;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: 15px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 2px solid var(--border-primary);
}

.theme-toggle.dark {
    background: var(--primary-600);
}

.theme-toggle::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: var(--bg-primary);
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow-medium);
}

.theme-toggle.dark::before {
    transform: translateX(30px);
}

.theme-toggle-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    transition: opacity 0.3s ease;
}

.theme-toggle.dark .theme-toggle-icon.sun {
    opacity: 0;
}

.theme-toggle:not(.dark) .theme-toggle-icon.moon {
    opacity: 0;
}

/* Auto Theme Detection */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
    }
}

/* Theme-Specific Component Styles */
.theme-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px var(--shadow-light);
    transition: all 0.3s ease;
}

.theme-card:hover {
    box-shadow: 0 8px 25px var(--shadow-medium);
    transform: translateY(-2px);
}

.theme-button {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px var(--shadow-light);
}

.theme-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px var(--shadow-medium);
}

.theme-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow-light);
}

.theme-button.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.theme-button.ghost {
    background: transparent;
    color: var(--primary-500);
    border: 1px solid var(--primary-500);
}

.theme-input {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.theme-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: var(--focus-ring);
}

.theme-select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: var(--focus-ring);
}

/* Theme Aware Gradients */
.gradient-bg {
    background: var(--gradient-primary);
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Glass Morphism Effects */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Neon Effects */
.neon-border {
    border: 2px solid var(--neon-primary);
    box-shadow: 
        0 0 5px var(--neon-primary),
        0 0 10px var(--neon-primary),
        0 0 15px var(--neon-primary);
    animation: neon-pulse 2s infinite alternate;
}

@keyframes neon-pulse {
    from {
        box-shadow: 
            0 0 5px var(--neon-primary),
            0 0 10px var(--neon-primary),
            0 0 15px var(--neon-primary);
    }
    to {
        box-shadow: 
            0 0 2px var(--neon-primary),
            0 0 5px var(--neon-primary),
            0 0 8px var(--neon-primary);
    }
}

/* Theme-Specific Animations */
[data-theme="dark"] .animate-glow {
    animation: dark-glow 2s infinite alternate;
}

@keyframes dark-glow {
    from {
        box-shadow: 0 0 5px var(--primary-500);
    }
    to {
        box-shadow: 0 0 20px var(--primary-500), 0 0 30px var(--primary-500);
    }
}

/* Performance Theme */
[data-performance="low"] * {
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
}

/* Theme Preset Buttons */
.theme-presets {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.theme-preset {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.theme-preset::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border-radius: 50%;
}

.theme-preset.light::before {
    background: linear-gradient(135deg, #ffffff, #f0f9ff);
}

.theme-preset.dark::before {
    background: linear-gradient(135deg, #0f172a, #1e293b);
}

.theme-preset.high-contrast::before {
    background: linear-gradient(135deg, #000000, #333333);
}

.theme-preset.active {
    border-color: var(--primary-500);
    transform: scale(1.1);
}

/* Theme Transition Overlay */
.theme-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.theme-transition-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive Theme Adjustments */
@media (max-width: 768px) {
    .theme-toggle {
        width: 50px;
        height: 25px;
    }
    
    .theme-toggle::before {
        width: 20px;
        height: 20px;
        transform: translateX(0);
    }
    
    .theme-toggle.dark::before {
        transform: translateX(25px);
    }
    
    .theme-presets {
        justify-content: center;
    }
}

/* Print Styles */
@media print {
    :root {
        --bg-primary: white;
        --text-primary: black;
        --border-primary: #ccc;
    }
    
    [data-theme="dark"],
    [data-theme="high-contrast"] {
        --bg-primary: white;
        --text-primary: black;
        --border-primary: #ccc;
    }
}

/* Accessibility Theme Considerations */
@media (prefers-contrast: high) {
    :root {
        --border-primary: #000000;
        --border-secondary: #000000;
    }
    
    [data-theme="dark"] {
        --border-primary: #ffffff;
        --border-secondary: #ffffff;
    }
}

/* Theme Storage Indicator */
.theme-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.theme-status.show {
    opacity: 1;
    transform: translateY(0);
}