/* ===== THEME SYSTEM ===== */

/* Dark Theme */
.theme-dark {
    /* Background Colors */
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-tertiary: #4a5568;
    --bg-card: #2d3748;
    --bg-modal: rgba(0, 0, 0, 0.8);
    
    /* Text Colors */
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #a0aec0;
    --text-inverse: #1a202c;
    
    /* Border Colors */
    --border-color: #4a5568;
    --border-focus: #667eea;
    
    /* Shadow Colors */
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --shadow-heavy: rgba(0, 0, 0, 0.6);
    
    /* Option Colors (slightly adjusted for dark theme) */
    --option-a-light: rgba(102, 126, 234, 0.2);
    --option-b-light: rgba(240, 147, 251, 0.2);
}

/* Theme-specific adjustments */
.theme-dark .loading-screen {
    background: linear-gradient(135deg, #2d3748, #4a5568);
}

.theme-dark .welcome-screen {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.theme-dark .logo {
    background: linear-gradient(135deg, #667eea, #f093fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-dark .icon-btn:hover {
    background: var(--primary-color);
    color: var(--bg-primary);
}

.theme-dark .secondary-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.theme-dark .secondary-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.theme-dark .category-badge {
    background: var(--primary-color);
    color: var(--bg-primary);
}

.theme-dark .vs-separator {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.theme-dark .user-choice-indicator {
    background: var(--bg-card);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.theme-dark .progress-bar {
    background: var(--bg-tertiary);
}

.theme-dark .toast {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ===== ADDITIONAL THEME OPTIONS ===== */

/* Blue Theme */
.theme-blue {
    --primary-color: #3182ce;
    --primary-dark: #2c5aa0;
    --secondary-color: #63b3ed;
    --accent-color: #90cdf4;
    
    --option-a-color: #3182ce;
    --option-b-color: #63b3ed;
    --option-a-light: rgba(49, 130, 206, 0.1);
    --option-b-light: rgba(99, 179, 237, 0.1);
}

/* Green Theme */
.theme-green {
    --primary-color: #38a169;
    --primary-dark: #2f855a;
    --secondary-color: #68d391;
    --accent-color: #9ae6b4;
    
    --option-a-color: #38a169;
    --option-b-color: #68d391;
    --option-a-light: rgba(56, 161, 105, 0.1);
    --option-b-light: rgba(104, 211, 145, 0.1);
}

/* Purple Theme */
.theme-purple {
    --primary-color: #805ad5;
    --primary-dark: #6b46c1;
    --secondary-color: #b794f6;
    --accent-color: #d6bcfa;
    
    --option-a-color: #805ad5;
    --option-b-color: #b794f6;
    --option-a-light: rgba(128, 90, 213, 0.1);
    --option-b-light: rgba(183, 148, 246, 0.1);
}

/* Pink Theme */
.theme-pink {
    --primary-color: #d53f8c;
    --primary-dark: #b83280;
    --secondary-color: #f687b3;
    --accent-color: #fbb6ce;
    
    --option-a-color: #d53f8c;
    --option-b-color: #f687b3;
    --option-a-light: rgba(213, 63, 140, 0.1);
    --option-b-light: rgba(246, 135, 179, 0.1);
}

/* Orange Theme */
.theme-orange {
    --primary-color: #dd6b20;
    --primary-dark: #c05621;
    --secondary-color: #f6ad55;
    --accent-color: #fbd38d;
    
    --option-a-color: #dd6b20;
    --option-b-color: #f6ad55;
    --option-a-light: rgba(221, 107, 32, 0.1);
    --option-b-light: rgba(246, 173, 85, 0.1);
}

/* ===== THEME TRANSITIONS ===== */
body {
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

.app-header,
.bg-card,
.modal-content,
.option-card,
.user-choice-indicator,
.progress-bar,
.toast {
    transition: background-color var(--transition-normal), border-color var(--transition-normal), color var(--transition-normal);
}

/* ===== THEME TOGGLE ANIMATION ===== */
.theme-toggle-animation {
    position: relative;
    overflow: hidden;
}

.theme-toggle-animation::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0);
    transition: all 0.6s ease-out;
    pointer-events: none;
    z-index: -1;
}

.theme-toggle-animation.animating::before {
    opacity: 0.1;
    transform: scale(1);
}

/* ===== HIGH CONTRAST THEME ===== */
.theme-high-contrast {
    --primary-color: #000000;
    --primary-dark: #000000;
    --secondary-color: #ffffff;
    --accent-color: #000000;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f0f0f0;
    --bg-tertiary: #e0e0e0;
    --bg-card: #ffffff;
    --bg-modal: rgba(0, 0, 0, 0.9);
    
    /* Text Colors */
    --text-primary: #000000;
    --text-secondary: #000000;
    --text-muted: #000000;
    --text-inverse: #ffffff;
    
    /* Border Colors */
    --border-color: #000000;
    --border-focus: #000000;
    
    /* Option Colors */
    --option-a-color: #000000;
    --option-b-color: #666666;
    --option-a-light: rgba(0, 0, 0, 0.1);
    --option-b-light: rgba(102, 102, 102, 0.1);
}

.theme-high-contrast.theme-dark {
    /* Background Colors */
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #333333;
    --bg-card: #000000;
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --text-muted: #ffffff;
    --text-inverse: #000000;
    
    /* Option Colors */
    --option-a-color: #ffffff;
    --option-b-color: #cccccc;
    --option-a-light: rgba(255, 255, 255, 0.1);
    --option-b-light: rgba(204, 204, 204, 0.1);
}

/* ===== SYSTEM PREFERENCE DETECTION ===== */
@media (prefers-color-scheme: dark) {
    :root {
        /* Default to dark theme if system preference is dark and no theme is set */
    }
}

@media (prefers-contrast: high) {
    /* Automatically apply high contrast adjustments */
    :root {
        --border-color: currentColor;
    }
    
    .option-card {
        border-width: 3px;
    }
    
    button:focus,
    .option-card:focus {
        outline-width: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .theme-toggle-animation::before {
        transition: none;
    }
}

/* ===== THEME-SPECIFIC GRADIENTS ===== */
.theme-light .primary-btn,
.theme-blue .primary-btn,
.theme-green .primary-btn,
.theme-purple .primary-btn,
.theme-pink .primary-btn,
.theme-orange .primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.theme-dark .primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.theme-high-contrast .primary-btn {
    background: var(--primary-color);
}

/* ===== SEASONAL THEMES (Optional) ===== */
.theme-winter {
    --primary-color: #4299e1;
    --secondary-color: #90cdf4;
    --accent-color: #bee3f8;
    --bg-primary: #f7faff;
    --bg-secondary: #edf2f7;
}

.theme-spring {
    --primary-color: #48bb78;
    --secondary-color: #68d391;
    --accent-color: #9ae6b4;
    --bg-primary: #f0fff4;
    --bg-secondary: #c6f6d5;
}

.theme-summer {
    --primary-color: #ed8936;
    --secondary-color: #f6ad55;
    --accent-color: #fbd38d;
    --bg-primary: #fffaf0;
    --bg-secondary: #feebc8;
}

.theme-autumn {
    --primary-color: #d69e2e;
    --secondary-color: #f6e05e;
    --accent-color: #faf089;
    --bg-primary: #fffff0;
    --bg-secondary: #fefcbf;
}

/* ===== THEME SELECTOR STYLES ===== */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.theme-option {
    padding: var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.theme-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.theme-option.active {
    border-color: var(--primary-color);
    background: var(--option-a-light);
}

.theme-preview {
    width: 40px;
    height: 20px;
    border-radius: var(--radius-sm);
    margin: 0 auto var(--spacing-sm);
}

.theme-option[data-theme="light"] .theme-preview {
    background: linear-gradient(135deg, #667eea, #f093fb);
}

.theme-option[data-theme="dark"] .theme-preview {
    background: linear-gradient(135deg, #2d3748, #4a5568);
}

.theme-option[data-theme="blue"] .theme-preview {
    background: linear-gradient(135deg, #3182ce, #63b3ed);
}

.theme-option[data-theme="green"] .theme-preview {
    background: linear-gradient(135deg, #38a169, #68d391);
}

.theme-option[data-theme="purple"] .theme-preview {
    background: linear-gradient(135deg, #805ad5, #b794f6);
}

.theme-option[data-theme="pink"] .theme-preview {
    background: linear-gradient(135deg, #d53f8c, #f687b3);
}

.theme-option[data-theme="orange"] .theme-preview {
    background: linear-gradient(135deg, #dd6b20, #f6ad55);
}