/**
 * =====================================================
 * UNIFIED THEME VARIABLES
 * Single source of truth for colors across the entire project
 * Supports Light Mode & Dark Mode
 * WCAG 2.1 AA Compliant
 * =====================================================
 */

/* =====================================================
   LIGHT MODE (DEFAULT)
   ===================================================== */
:root {
    /* === PRIMARY BRAND COLORS === */
    --color-primary-50: #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-200: #bfdbfe;
    --color-primary-300: #93c5fd;
    --color-primary-400: #60a5fa;
    --color-primary-500: #3b82f6;    /* Main brand blue */
    --color-primary-600: #2563eb;
    --color-primary-700: #1d4ed8;
    --color-primary-800: #1e40af;
    --color-primary-900: #1e3a8a;

    /* === SECONDARY ACCENT COLORS === */
    --color-secondary-50: #f5f3ff;
    --color-secondary-100: #ede9fe;
    --color-secondary-200: #ddd6fe;
    --color-secondary-300: #c4b5fd;
    --color-secondary-400: #a78bfa;
    --color-secondary-500: #8b5cf6;   /* Purple accent */
    --color-secondary-600: #7c3aed;
    --color-secondary-700: #6d28d9;
    --color-secondary-800: #5b21b6;
    --color-secondary-900: #4c1d95;

    /* === SUCCESS COLORS === */
    --color-success-50: #f0fdf4;
    --color-success-100: #dcfce7;
    --color-success-200: #bbf7d0;
    --color-success-300: #86efac;
    --color-success-400: #4ade80;
    --color-success-500: #22c55e;
    --color-success-600: #16a34a;    /* Main success green */
    --color-success-700: #15803d;
    --color-success-800: #166534;
    --color-success-900: #14532d;

    /* === WARNING COLORS === */
    --color-warning-50: #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-200: #fde68a;
    --color-warning-300: #fcd34d;
    --color-warning-400: #fbbf24;
    --color-warning-500: #f59e0b;    /* Main warning yellow */
    --color-warning-600: #d97706;
    --color-warning-700: #b45309;
    --color-warning-800: #92400e;
    --color-warning-900: #78350f;

    /* === ERROR/DANGER COLORS === */
    --color-error-50: #fef2f2;
    --color-error-100: #fee2e2;
    --color-error-200: #fecaca;
    --color-error-300: #fca5a5;
    --color-error-400: #f87171;
    --color-error-500: #ef4444;
    --color-error-600: #dc2626;      /* Main error red */
    --color-error-700: #b91c1c;
    --color-error-800: #991b1b;
    --color-error-900: #7f1d1d;

    /* === INFO COLORS === */
    --color-info-50: #ecfeff;
    --color-info-100: #cffafe;
    --color-info-200: #a5f3fc;
    --color-info-300: #67e8f9;
    --color-info-400: #22d3ee;
    --color-info-500: #06b6d4;       /* Main info cyan */
    --color-info-600: #0891b2;
    --color-info-700: #0e7490;
    --color-info-800: #155e75;
    --color-info-900: #164e63;

    /* === GRAYSCALE === */
    --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 THEME VARIABLES (LIGHT MODE) === */
    
    /* Backgrounds */
    --theme-bg-primary: #ffffff;
    --theme-bg-secondary: #f9fafb;
    --theme-bg-tertiary: #f3f4f6;
    --theme-bg-elevated: #ffffff;
    --theme-bg-overlay: rgba(0, 0, 0, 0.5);
    
    /* Text Colors */
    --theme-text-primary: #111827;
    --theme-text-secondary: #4b5563;
    --theme-text-tertiary: #6b7280;
    --theme-text-muted: #9ca3af;
    --theme-text-on-primary: #ffffff;
    --theme-text-on-accent: #ffffff;
    
    /* Borders */
    --theme-border-light: #e5e7eb;
    --theme-border-medium: #d1d5db;
    --theme-border-strong: #9ca3af;
    
    /* Interactive States */
    --theme-hover-bg: #f3f4f6;
    --theme-hover-border: #d1d5db;
    --theme-active-bg: #e5e7eb;
    --theme-focus-ring: rgba(59, 130, 246, 0.3);
    
    /* Shadows */
    --theme-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --theme-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --theme-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --theme-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Admin-Specific */
    --admin-sidebar-bg: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    --admin-sidebar-text: #ffffff;
    --admin-sidebar-text-muted: rgba(255, 255, 255, 0.7);
    --admin-sidebar-hover: rgba(255, 255, 255, 0.1);
    --admin-sidebar-active: rgba(255, 255, 255, 0.15);
    --admin-sidebar-border: rgba(255, 255, 255, 0.1);
    
    /* Status Badge Colors */
    --badge-success-bg: rgba(22, 163, 74, 0.1);
    --badge-success-text: #15803d;
    --badge-warning-bg: rgba(245, 158, 11, 0.12);
    --badge-warning-text: #b45309;
    --badge-error-bg: rgba(220, 38, 38, 0.12);
    --badge-error-text: #b91c1c;
    --badge-info-bg: rgba(59, 130, 246, 0.1);
    --badge-info-text: #1d4ed8;
    
    /* Level Badge Colors */
    --badge-beginner-bg: rgba(16, 185, 129, 0.1);
    --badge-beginner-text: #047857;
    --badge-intermediate-bg: rgba(245, 158, 11, 0.12);
    --badge-intermediate-text: #b45309;
    --badge-advanced-bg: rgba(239, 68, 68, 0.12);
    --badge-advanced-text: #b91c1c;
}

/* =====================================================
   DARK MODE
   ===================================================== */
html.dark-theme,
body.dark-theme {
    /* === SEMANTIC THEME VARIABLES (DARK MODE) === */
    
    /* Backgrounds */
    --theme-bg-primary: #0f172a;
    --theme-bg-secondary: #1e293b;
    --theme-bg-tertiary: #334155;
    --theme-bg-elevated: #1e293b;
    --theme-bg-overlay: rgba(0, 0, 0, 0.7);
    
    /* Text Colors */
    --theme-text-primary: #f1f5f9;
    --theme-text-secondary: #cbd5e1;
    --theme-text-tertiary: #94a3b8;
    --theme-text-muted: #64748b;
    --theme-text-on-primary: #f1f5f9;
    --theme-text-on-accent: #ffffff;
    
    /* Borders */
    --theme-border-light: #334155;
    --theme-border-medium: #475569;
    --theme-border-strong: #64748b;
    
    /* Interactive States */
    --theme-hover-bg: rgba(59, 130, 246, 0.1);
    --theme-hover-border: #475569;
    --theme-active-bg: rgba(59, 130, 246, 0.15);
    --theme-focus-ring: rgba(96, 165, 250, 0.4);
    
    /* Shadows (enhanced for dark mode) */
    --theme-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --theme-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --theme-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --theme-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    
    /* Admin-Specific (Dark) */
    --admin-sidebar-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --admin-sidebar-text: #e2e8f0;
    --admin-sidebar-text-muted: rgba(226, 232, 240, 0.6);
    --admin-sidebar-hover: rgba(59, 130, 246, 0.15);
    --admin-sidebar-active: rgba(59, 130, 246, 0.25);
    --admin-sidebar-border: rgba(148, 163, 184, 0.1);
    
    /* Status Badge Colors (Dark) */
    --badge-success-bg: rgba(34, 197, 94, 0.15);
    --badge-success-text: #6ee7b7;
    --badge-warning-bg: rgba(251, 191, 36, 0.15);
    --badge-warning-text: #fcd34d;
    --badge-error-bg: rgba(248, 113, 113, 0.15);
    --badge-error-text: #fca5a5;
    --badge-info-bg: rgba(96, 165, 250, 0.15);
    --badge-info-text: #93c5fd;
    
    /* Level Badge Colors (Dark) */
    --badge-beginner-bg: rgba(52, 211, 153, 0.15);
    --badge-beginner-text: #6ee7b7;
    --badge-intermediate-bg: rgba(251, 191, 36, 0.15);
    --badge-intermediate-text: #fcd34d;
    --badge-advanced-bg: rgba(248, 113, 113, 0.15);
    --badge-advanced-text: #fca5a5;
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */

/* Background Colors */
.bg-primary { background-color: var(--theme-bg-primary) !important; }
.bg-secondary { background-color: var(--theme-bg-secondary) !important; }
.bg-tertiary { background-color: var(--theme-bg-tertiary) !important; }

/* Text Colors */
.text-primary { color: var(--theme-text-primary) !important; }
.text-secondary { color: var(--theme-text-secondary) !important; }
.text-tertiary { color: var(--theme-text-tertiary) !important; }
.text-muted { color: var(--theme-text-muted) !important; }

/* Status Colors */
.text-success { color: var(--color-success-600) !important; }
.text-warning { color: var(--color-warning-600) !important; }
.text-error { color: var(--color-error-600) !important; }
.text-info { color: var(--color-info-600) !important; }

html.dark-theme .text-success,
body.dark-theme .text-success { color: var(--badge-success-text) !important; }
html.dark-theme .text-warning,
body.dark-theme .text-warning { color: var(--badge-warning-text) !important; }
html.dark-theme .text-error,
body.dark-theme .text-error { color: var(--badge-error-text) !important; }
html.dark-theme .text-info,
body.dark-theme .text-info { color: var(--badge-info-text) !important; }

/* Border Colors */
.border-light { border-color: var(--theme-border-light) !important; }
.border-medium { border-color: var(--theme-border-medium) !important; }
.border-strong { border-color: var(--theme-border-strong) !important; }

/* =====================================================
   SMOOTH TRANSITIONS
   ===================================================== */
* {
    transition: background-color 0.2s ease, 
                color 0.2s ease, 
                border-color 0.2s ease,
                box-shadow 0.2s ease;
}

/* =====================================================
   ACCESSIBILITY & FOCUS STATES
   ===================================================== */
*:focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--theme-focus-ring);
}

html.dark-theme *:focus-visible,
body.dark-theme *:focus-visible {
    outline: 2px solid var(--color-primary-400);
    box-shadow: 0 0 0 4px var(--theme-focus-ring);
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
    :root {
        --theme-bg-primary: #ffffff;
        --theme-text-primary: #000000;
        --theme-shadow-md: none;
    }
}

/* =====================================================
   HIGH CONTRAST MODE SUPPORT
   ===================================================== */
@media (prefers-contrast: high) {
    :root {
        --theme-border-light: #000000;
        --theme-text-secondary: #000000;
    }
    
    html.dark-theme,
    body.dark-theme {
        --theme-border-light: #ffffff;
        --theme-text-secondary: #ffffff;
    }
}

/* =====================================================
   REDUCED MOTION SUPPORT
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
