/* PulseCore BPT Visualization Suite - Theme System */

/* Light Theme (Default) */
:root {
    --theme-bg-primary: #ffffff;
    --theme-bg-secondary: #f8fafc;
    --theme-bg-tertiary: #f1f5f9;
    --theme-text-primary: #0f172a;
    --theme-text-secondary: #334155;
    --theme-text-tertiary: #64748b;
    --theme-border: #e2e8f0;
    --theme-border-light: #f1f5f9;
    --theme-shadow: rgba(0, 0, 0, 0.1);
    --theme-shadow-light: rgba(0, 0, 0, 0.05);
}

/* Dark Theme */
[data-theme="dark"] {
    --theme-bg-primary: #0f172a;
    --theme-bg-secondary: #1e293b;
    --theme-bg-tertiary: #334155;
    --theme-text-primary: #f8fafc;
    --theme-text-secondary: #e2e8f0;
    --theme-text-tertiary: #94a3b8;
    --theme-border: #475569;
    --theme-border-light: #334155;
    --theme-shadow: rgba(0, 0, 0, 0.3);
    --theme-shadow-light: rgba(0, 0, 0, 0.2);
    
    /* Update color variables for dark theme */
    --gray-50: var(--theme-bg-primary);
    --gray-100: var(--theme-bg-secondary);
    --gray-200: var(--theme-bg-tertiary);
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: var(--theme-text-primary);
}

/* BPT Scientific Theme */
[data-theme="scientific"] {
    --primary-color: #1e40af;
    --secondary-color: #7c2d12;
    --accent-color: #065f46;
    --bpt-primary: #1e40af;
    --theme-bg-primary: #fefefe;
    --theme-bg-secondary: #f9fafb;
    --theme-bg-tertiary: #f3f4f6;
    --theme-text-primary: #111827;
    --theme-text-secondary: #374151;
    --theme-text-tertiary: #6b7280;
    --theme-border: #d1d5db;
    --theme-border-light: #e5e7eb;
}

/* High Contrast Theme */
[data-theme="high-contrast"] {
    --primary-color: #000000;
    --secondary-color: #ffffff;
    --accent-color: #0066cc;
    --theme-bg-primary: #ffffff;
    --theme-bg-secondary: #f0f0f0;
    --theme-bg-tertiary: #e0e0e0;
    --theme-text-primary: #000000;
    --theme-text-secondary: #333333;
    --theme-text-tertiary: #666666;
    --theme-border: #000000;
    --theme-border-light: #cccccc;
    --theme-shadow: rgba(0, 0, 0, 0.5);
    --theme-shadow-light: rgba(0, 0, 0, 0.3);
}

/* Color Scheme Themes for Visualizations */

/* Viridis Color Scheme */
.color-scheme-viridis {
    --viz-color-1: #440154;
    --viz-color-2: #482777;
    --viz-color-3: #3f4a8a;
    --viz-color-4: #31678e;
    --viz-color-5: #26838f;
    --viz-color-6: #1f9d8a;
    --viz-color-7: #6cce5a;
    --viz-color-8: #b6de2b;
    --viz-color-9: #fee825;
    --viz-gradient: linear-gradient(45deg, #440154, #482777, #3f4a8a, #31678e, #26838f, #1f9d8a, #6cce5a, #b6de2b, #fee825);
}

/* Plasma Color Scheme */
.color-scheme-plasma {
    --viz-color-1: #0d0887;
    --viz-color-2: #5d01a6;
    --viz-color-3: #9c179e;
    --viz-color-4: #d0438e;
    --viz-color-5: #f48c6c;
    --viz-color-6: #ffbe5a;
    --viz-color-7: #fce51d;
    --viz-gradient: linear-gradient(45deg, #0d0887, #5d01a6, #9c179e, #d0438e, #f48c6c, #ffbe5a, #fce51d);
}

/* Cool Color Scheme */
.color-scheme-cool {
    --viz-color-1: #1e3a8a;
    --viz-color-2: #1e40af;
    --viz-color-3: #2563eb;
    --viz-color-4: #0891b2;
    --viz-color-5: #0d9488;
    --viz-color-6: #059669;
    --viz-color-7: #16a34a;
    --viz-gradient: linear-gradient(45deg, #1e3a8a, #1e40af, #2563eb, #0891b2, #0d9488, #059669, #16a34a);
}

/* Warm Color Scheme */
.color-scheme-warm {
    --viz-color-1: #dc2626;
    --viz-color-2: #ea580c;
    --viz-color-3: #d97706;
    --viz-color-4: #ca8a04;
    --viz-color-5: #65a30d;
    --viz-color-6: #16a34a;
    --viz-color-7: #059669;
    --viz-gradient: linear-gradient(45deg, #dc2626, #ea580c, #d97706, #ca8a04, #65a30d, #16a34a, #059669);
}

/* BPT Primary Color Scheme */
.color-scheme-bpt-primary {
    --viz-color-1: #1e40af;
    --viz-color-2: #2563eb;
    --viz-color-3: #3b82f6;
    --viz-color-4: #60a5fa;
    --viz-color-5: #7c3aed;
    --viz-color-6: #8b5cf6;
    --viz-color-7: #a78bfa;
    --viz-gradient: linear-gradient(45deg, #1e40af, #2563eb, #3b82f6, #60a5fa, #7c3aed, #8b5cf6, #a78bfa);
}

/* Rainbow Color Scheme */
.color-scheme-rainbow {
    --viz-color-1: #ef4444;
    --viz-color-2: #f97316;
    --viz-color-3: #eab308;
    --viz-color-4: #22c55e;
    --viz-color-5: #06b6d4;
    --viz-color-6: #3b82f6;
    --viz-color-7: #8b5cf6;
    --viz-color-8: #ec4899;
    --viz-gradient: linear-gradient(45deg, #ef4444, #f97316, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899);
}

/* Theme-specific Component Overrides */

/* Dark Theme Overrides */
[data-theme="dark"] body {
    background-color: var(--theme-bg-primary);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .app-header {
    background: var(--theme-bg-secondary);
    border-bottom-color: var(--theme-border);
}

[data-theme="dark"] section {
    background: var(--theme-bg-primary);
    border-color: var(--theme-border);
}

[data-theme="dark"] .section-header {
    background: var(--theme-bg-secondary);
    border-bottom-color: var(--theme-border);
}

[data-theme="dark"] .variable-selector,
[data-theme="dark"] .equation-builder,
[data-theme="dark"] .range-controls,
[data-theme="dark"] .control-group {
    background: var(--theme-bg-secondary);
}

[data-theme="dark"] .search-input,
[data-theme="dark"] .equation-textarea,
[data-theme="dark"] .range-item input,
[data-theme="dark"] .range-item select {
    background: var(--theme-bg-primary);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .search-suggestions {
    background: var(--theme-bg-primary);
    border-color: var(--theme-border);
}

[data-theme="dark"] .suggestion-item:hover {
    background: var(--theme-bg-secondary);
}

[data-theme="dark"] .chart-type-btn {
    background: var(--theme-bg-primary);
    border-color: var(--theme-border);
    color: var(--theme-text-secondary);
}

[data-theme="dark"] .chart-type-btn:hover {
    background: var(--theme-bg-secondary);
}

[data-theme="dark"] .result-card {
    background: var(--theme-bg-secondary);
    border-color: var(--theme-border);
}

[data-theme="dark"] .card-header {
    background: var(--theme-bg-primary);
    border-bottom-color: var(--theme-border);
}

[data-theme="dark"] .modal-content {
    background: var(--theme-bg-primary);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background: var(--theme-bg-secondary);
    border-color: var(--theme-border);
}

[data-theme="dark"] .chart-3d-container {
    background: var(--theme-bg-secondary);
}

[data-theme="dark"] .chart-loading,
[data-theme="dark"] .chart-error {
    background: var(--theme-bg-secondary);
}

/* Scientific Theme Overrides */
[data-theme="scientific"] .app-title {
    font-family: 'Times New Roman', serif;
    font-weight: 400;
}

[data-theme="scientific"] .equation-textarea,
[data-theme="scientific"] .preview-content {
    font-family: 'Computer Modern', 'Times New Roman', serif;
}

[data-theme="scientific"] .variable-tag {
    font-family: 'Computer Modern', monospace;
}

/* High Contrast Theme Overrides */
[data-theme="high-contrast"] .btn-outline {
    border-width: 3px;
}

[data-theme="high-contrast"] .chart-type-btn {
    border-width: 3px;
}

[data-theme="high-contrast"] .chart-type-btn.active {
    background: var(--theme-text-primary);
    color: var(--theme-bg-primary);
}

[data-theme="high-contrast"] .search-input:focus,
[data-theme="high-contrast"] .equation-textarea:focus {
    border-width: 3px;
    box-shadow: 0 0 0 3px var(--accent-color);
}

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

/* Theme Toggle Animation */
.theme-toggle-animation {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .loading-spinner {
        animation: none;
        border: 4px solid var(--gray-300);
        border-top-color: var(--primary-color);
    }
}

/* Print Theme */
@media print {
    :root {
        --theme-bg-primary: white;
        --theme-bg-secondary: white;
        --theme-bg-tertiary: white;
        --theme-text-primary: black;
        --theme-text-secondary: black;
        --theme-text-tertiary: #666666;
        --theme-border: black;
        --theme-border-light: #cccccc;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    section {
        background: white !important;
        border: 2px solid black !important;
        box-shadow: none !important;
    }
    
    .section-header {
        background: white !important;
        border-bottom: 2px solid black !important;
    }
    
    .chart-wrapper {
        background: white !important;
    }
}

/* Accessibility Enhancements */
@media (prefers-contrast: high) {
    :root {
        --theme-border: #000000;
        --theme-shadow: rgba(0, 0, 0, 0.8);
    }
    
    .btn {
        border: 2px solid;
    }
    
    .chart-type-btn {
        border-width: 2px;
    }
}

/* Focus Visible for Better Accessibility */
.btn:focus-visible,
.chart-type-btn:focus-visible,
.search-input:focus-visible,
.equation-textarea:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* Custom Scrollbar for Dark Theme */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--theme-bg-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--theme-border);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--theme-text-tertiary);
}

/* Color Scheme Utilities */
.text-viz-1 { color: var(--viz-color-1); }
.text-viz-2 { color: var(--viz-color-2); }
.text-viz-3 { color: var(--viz-color-3); }
.text-viz-4 { color: var(--viz-color-4); }
.text-viz-5 { color: var(--viz-color-5); }
.text-viz-6 { color: var(--viz-color-6); }
.text-viz-7 { color: var(--viz-color-7); }
.text-viz-8 { color: var(--viz-color-8); }
.text-viz-9 { color: var(--viz-color-9); }

.bg-viz-1 { background-color: var(--viz-color-1); }
.bg-viz-2 { background-color: var(--viz-color-2); }
.bg-viz-3 { background-color: var(--viz-color-3); }
.bg-viz-4 { background-color: var(--viz-color-4); }
.bg-viz-5 { background-color: var(--viz-color-5); }
.bg-viz-6 { background-color: var(--viz-color-6); }
.bg-viz-7 { background-color: var(--viz-color-7); }
.bg-viz-8 { background-color: var(--viz-color-8); }
.bg-viz-9 { background-color: var(--viz-color-9); }

.gradient-viz {
    background: var(--viz-gradient);
}

/* Theme-specific Chart Styles */
.chart-container[data-color-scheme="viridis"] {
    --chart-primary: var(--viz-color-5);
    --chart-secondary: var(--viz-color-7);
}

.chart-container[data-color-scheme="plasma"] {
    --chart-primary: var(--viz-color-4);
    --chart-secondary: var(--viz-color-6);
}

.chart-container[data-color-scheme="cool"] {
    --chart-primary: var(--viz-color-3);
    --chart-secondary: var(--viz-color-5);
}

.chart-container[data-color-scheme="warm"] {
    --chart-primary: var(--viz-color-3);
    --chart-secondary: var(--viz-color-5);
}

.chart-container[data-color-scheme="bpt-primary"] {
    --chart-primary: var(--viz-color-2);
    --chart-secondary: var(--viz-color-5);
}

.chart-container[data-color-scheme="rainbow"] {
    --chart-primary: var(--viz-color-4);
    --chart-secondary: var(--viz-color-6);
}