/* CSS Variables for Light Theme */
:root {
    /* Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.9);
    --bg-footer: #f1f5f9;
    --bg-hover: #f1f5f9;

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Border & Dividers */
    --border-color: #e2e8f0;
    --divider-color: #f1f5f9;

    /* Accent Colors */
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #dbeafe;

    /* Status Colors */
    --success-color: #10b981;
    --success-bg: #dcfce7;
    --warning-color: #f59e0b;
    --warning-bg: #fef3cd;
    --error-color: #ef4444;
    --error-bg: #fee2e2;
    --info-color: #3b82f6;
    --info-bg: #dbeafe;

    /* Gradients */
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --gradient-card: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;

    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    /* Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-header: rgba(15, 23, 42, 0.9);
    --bg-footer: #020617;
    --bg-hover: #334155;

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    /* Border & Dividers */
    --border-color: #334155;
    --divider-color: #475569;

    /* Accent Colors */
    --accent-color: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-light: #1e3a8a;

    /* Status Colors */
    --success-color: #34d399;
    --success-bg: #064e3b;
    --warning-color: #fbbf24;
    --warning-bg: #451a03;
    --error-color: #f87171;
    --error-bg: #7f1d1d;
    --info-color: #60a5fa;
    --info-bg: #1e3a8a;

    /* Gradients */
    --gradient-start: #4338ca;
    --gradient-end: #7c3aed;
    --gradient-card: linear-gradient(135deg, #4338ca 0%, #7c3aed 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

/* System Theme Detection */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        /* Auto Dark Theme */
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-card: #1e293b;
        --bg-header: rgba(15, 23, 42, 0.9);
        --bg-footer: #020617;
        --bg-hover: #334155;

        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;

        --border-color: #334155;
        --divider-color: #475569;

        --accent-color: #60a5fa;
        --accent-hover: #3b82f6;
        --accent-light: #1e3a8a;

        --success-color: #34d399;
        --success-bg: #064e3b;
        --warning-color: #fbbf24;
        --warning-bg: #451a03;
        --error-color: #f87171;
        --error-bg: #7f1d1d;
        --info-color: #60a5fa;
        --info-bg: #1e3a8a;

        --gradient-start: #4338ca;
        --gradient-end: #7c3aed;

        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    }
}

/* Theme Transition */
* {
    transition: background-color var(--transition-normal),
                color var(--transition-normal),
                border-color var(--transition-normal),
                box-shadow var(--transition-normal);
}

/* Color Scheme */
html {
    color-scheme: light;
}

[data-theme="dark"] {
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection Styling */
::selection {
    background-color: var(--accent-light);
    color: var(--text-primary);
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }

    .header,
    .footer,
    .scroll-buttons,
    .mobile-nav-overlay {
        display: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }

    [data-theme="dark"] {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}