/* static/css/themes.css */

/* ==================== CSS VARIABLES (DARK THEME) ==================== */

:root,
[data-theme="dark"] {
    /* ── Background Colors ── */
    --bg-primary: #0a0e13;
    --bg-secondary: #0f1419;
    --bg-tertiary: #1a1d24;
    --bg-elevated: #1e2329;
    --bg-hover: #2d3748;
    
    /* ── Text Colors ── */
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    
    /* ── Border Colors ── */
    --border-primary: #1e2329;
    --border-secondary: #374151;
    --border-tertiary: #4b5563;
    
    /* ── Accent Colors (Gold Theme) ── */
    --accent-primary: #d4af37;
    --accent-secondary: #c29f31;
    --accent-light: #f4e5c2;
    --accent-text: #0a0e13;
    --accent-glow: rgba(212, 175, 55, 0.15);
    
    /* ── State Colors ── */
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --info: #3b82f6;
    
    /* ── Chart Colors ── */
    --chart-up: #0ecb81;
    --chart-down: #f6465d;
    --chart-grid: #1f2226;
    --chart-border: #2b3139;
    
    /* ── Input Colors ── */
    --input-bg: #1e2329;
    --input-border: #374151;
    
    /* ── Group Colors ── */
    --group-red: #f44336;
    --group-blue: #2196F3;
    --group-green: #4CAF50;
    --group-yellow: #FFC107;
    --group-purple: #9C27B0;
    --group-orange: #FF9800;
    --group-pink: #E91E63;
    --group-cyan: #00BCD4;
    
    /* ── Shadows ── */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(212, 175, 55, 0.15);
    --shadow-lg: 0 10px 40px rgba(212, 175, 55, 0.25);
    
    /* ── Font ── */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;
    
    /* ── Z-Index ── */
    --z-header: 100;
    --z-sidebar: 10;
    --z-right-panel: 20;
    --z-modal: 1000;
    --z-toast: 2000;
}

/* ==================== LIGHT THEME ==================== */

[data-theme="light"] {
    /* ── Backgrounds ── */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --bg-elevated: #ffffff;
    --bg-hover: #e9ecef;
    
    /* ── Text (ОСНОВНОЙ ЦВЕТ ОСТАЁТСЯ ТЁМНЫМ) ── */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;
    
    /* ── Borders ── */
    --border-primary: #e5e7eb;
    --border-secondary: #d1d5db;
    --border-tertiary: #9ca3af;
    
    /* ── Accent (ЗОЛОТО, НЕМНОГО ТЕМНЕЕ) ── */
    --accent-primary: #b8860b;
    --accent-secondary: #9a7009;
    --accent-light: #daa520;
    --accent-text: #ffffff;
    --accent-glow: rgba(184, 134, 11, 0.12);
    
    /* ── State colors (те же, что и в dark) ── */
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --info: #3b82f6;
    
    /* ── Chart ── */
    --chart-up: #10b981;
    --chart-down: #ef4444;
    --chart-grid: #f3f4f6;
    --chart-border: #e5e7eb;
    
    /* ── Input ── */
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    
    /* ── Group Colors (те же) ── */
    --group-red: #f44336;
    --group-blue: #2196F3;
    --group-green: #4CAF50;
    --group-yellow: #FFC107;
    --group-purple: #9C27B0;
    --group-orange: #FF9800;
    --group-pink: #E91E63;
    --group-cyan: #00BCD4;
    
    /* ── Shadows ── */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
}

/* ==================== DARK THEME EXPLICIT ==================== */

[data-theme="dark"] {
    --bg-primary: #0a0e13;
    --bg-secondary: #0f1419;
    --bg-tertiary: #1a1d24;
    --bg-elevated: #1e2329;
    --bg-hover: #2d3748;
    
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    
    --border-primary: #1e2329;
    --border-secondary: #374151;
    --border-tertiary: #4b5563;
    
    --accent-primary: #d4af37;
    --accent-secondary: #c29f31;
    --accent-light: #f4e5c2;
    --accent-text: #0a0e13;
    --accent-glow: rgba(212, 175, 55, 0.15);
    
    --chart-grid: #1f2226;
    --chart-border: #2b3139;
    
    --input-bg: #1e2329;
    --input-border: #374151;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(212, 175, 55, 0.15);
    --shadow-lg: 0 10px 40px rgba(212, 175, 55, 0.25);
}

/* ==================== LIGHT THEME SPECIFIC FIXES ==================== */

/* ✅ Заголовки золотистые в светлой теме */
[data-theme="light"] .sidebar-title,
[data-theme="light"] .logo,
[data-theme="light"] .ctr-name,
[data-theme="light"] .chb-symbol-btn,
[data-theme="light"] .chart-symbol,
[data-theme="light"] .panel-section h4,
[data-theme="light"] .panel-section h5,
[data-theme="light"] .ticker-symbol,
[data-theme="light"] .instrument-symbol,
[data-theme="light"] .setting-group h4,
[data-theme="light"] .panel-header h3 {
    color: #b8860b !important;
    font-weight: 700;
}

/* ✅ Основной текст остаётся тёмным */
[data-theme="light"] .text-primary,
[data-theme="light"] .ctr-price,
[data-theme="light"] .chb-price,
[data-theme="light"] .header-left {
    color: #111827 !important;
}

/* ✅ Цифры и данные остаются нормального цвета */
[data-theme="light"] .price,
[data-theme="light"] .value {
    color: #111827 !important;
}

/* ✅ GREEN/RED для изменений (НЕ убираем) */
[data-theme="light"] .positive,
[data-theme="light"] .ctr-change.positive,
[data-theory="light"] .ticker-change.positive {
    color: #10b981 !important;
}

[data-theme="light"] .negative,
[data-theme="light"] .ctr-change.negative,
[data-theme="light"] .ticker-change.negative {
    color: #ef4444 !important;
}

/* ── Buttons в светлой теме ── */
[data-theme="light"] .btn {
    color: #111827;
    border-color: #d1d5db;
    background: #ffffff;
}

[data-theme="light"] .btn:hover {
    background: #f9fafb;
    border-color: #b8860b;
}

[data-theme="light"] .btn-primary {
    background: #b8860b;
    color: #ffffff;
    border-color: #b8860b;
}

[data-theme="light"] .btn-primary:hover {
    background: #9a7009;
    border-color: #9a7009;
    opacity: 1;
}

[data-theme="light"] .btn-secondary {
    background: #f8f9fa;
    color: #111827;
    border-color: #d1d5db;
}

[data-theme="light"] .btn-secondary:hover {
    background: #f1f3f5;
    border-color: #b8860b;
}

[data-theme="light"] .btn-danger {
    background: #ef4444;
    color: #ffffff;
}

[data-theme="light"] .btn-danger:hover {
    background: #dc2626;
}

/* ── Header buttons в светлой теме ── */
[data-theme="light"] .header-btn {
    color: #111827;
    border-color: #d1d5db;
    background: #ffffff;
}

[data-theme="light"] .header-btn:hover {
    background: #f9fafb;
    border-color: #b8860b;
}

[data-theme="light"] .header-btn.active {
    background: #b8860b;
    color: #ffffff;
    border-color: #b8860b;
}

/* ── Selects в светлой теме ── */
[data-theme="light"] .header-select,
[data-theme="light"] .form-select {
    background: #ffffff;
    color: #111827;
    border-color: #d1d5db;
}

[data-theme="light"] .header-select:hover,
[data-theme="light"] .form-select:hover {
    border-color: #b8860b;
}

[data-theme="light"] .header-select:focus,
[data-theme="light"] .form-select:focus {
    border-color: #b8860b;
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

/* ── Inputs в светлой теме ── */
[data-theme="light"] .form-input,
[data-theme="light"] .search-input {
    background: #ffffff;
    color: #111827;
    border-color: #d1d5db;
}

[data-theme="light"] .form-input::placeholder,
[data-theme="light"] .search-input::placeholder {
    color: #9ca3af;
}

[data-theme="light"] .form-input:focus,
[data-theme="light"] .search-input:focus {
    border-color: #b8860b;
    background: #f9fafb;
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

/* ── Sidebar items в светлой теме ── */
[data-theme="light"] .instrument-item {
    background: #ffffff;
    border-color: transparent;
}

[data-theme="light"] .instrument-item:hover {
    background: #f9fafb;
    border-left-color: #b8860b;
}

[data-theme="light"] .instrument-item.active {
    background: #f1f3f5;
    border-left-color: #b8860b;
}

/* ── Coin table в светлой теме ── */
[data-theme="light"] .coin-table-header {
    background: #f8f9fa;
    border-color: #e5e7eb;
    color: #4b5563;
}

[data-theme="light"] .coin-table-row {
    background: #ffffff;
}

[data-theme="light"] .coin-table-row:hover {
    background: #f9fafb;
}

[data-theme="light"] .coin-table-row.active {
    background: #f1f3f5;
    border-left-color: #b8860b;
}

/* ── Group markers в светлой теме ── */
[data-theme="light"] .group-marker {
    background: #ffffff;
    border-color: #d1d5db;
    color: #4b5563;
}

[data-theme="light"] .group-marker:hover {
    border-color: #b8860b;
    background: #f9fafb;
}

[data-theme="light"] .group-marker.active {
    background: #b8860b;
    color: #ffffff;
    border-color: #b8860b;
    font-weight: 700;
}

/* ── Sidebar в светлой теме ── */
[data-theme="light"] .sidebar {
    background: #ffffff;
    border-color: #e5e7eb;
}

[data-theme="light"] .sidebar-header,
[data-theme="light"] .search-bar,
[data-theme="light"] .sort-select-wrapper {
    border-color: #e5e7eb;
    background: #ffffff;
}

/* ── Chart header в светлой теме ── */
[data-theme="light"] .chart-header-bar {
    background: #f8f9fa;
    border-color: #e5e7eb;
}

[data-theme="light"] .chb-symbol-btn {
    background: #ffffff;
    border-color: #d1d5db;
    color: #b8860b;
}

[data-theme="light"] .chb-symbol-btn:hover {
    background: #f9fafb;
    border-color: #b8860b;
}

[data-theme="light"] .chb-btn {
    background: #ffffff;
    border-color: #d1d5db;
    color: #111827;
}

[data-theme="light"] .chb-btn:hover {
    background: #f9fafb;
    border-color: #b8860b;
    color: #b8860b;
}

/* ── Right panel в светлой теме ── */
[data-theme="light"] .right-panel {
    background: #ffffff;
    border-color: #e5e7eb;
}

[data-theme="light"] .panel-content {
    background: #ffffff;
}

[data-theme="light"] .panel-section {
    border-color: #e5e7eb;
}

[data-theme="light"] .panel-header {
    border-color: #e5e7eb;
    background: #f8f9fa;
}

[data-theme="light"] .panel-header h3 {
    color: #b8860b;
}

/* ── Modal в светлой теме ── */
[data-theme="light"] .modal-content {
    background: #ffffff;
    border: 1px solid #d1d5db;
}

[data-theme="light"] .modal-content h3 {
    color: #b8860b;
}

[data-theme="light"] .modal-close {
    color: #9ca3af;
}

[data-theme="light"] .modal-close:hover {
    color: #111827;
}

/* ── Toast в светлой теме ── */
[data-theme="light"] .toast {
    background: #ffffff;
    color: #111827;
    border-color: #e5e7eb;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .toast-success {
    border-left-color: #10b981;
}

[data-theme="light"] .toast-error {
    border-left-color: #ef4444;
}

[data-theme="light"] .toast-warning {
    border-left-color: #f59e0b;
}

[data-theme="light"] .toast-info {
    border-left-color: #b8860b;
}

/* ── Ticker в светлой теме ── */
[data-theme="light"] .ticker-container {
    background: #f8f9fa;
    border-color: #e5e7eb;
}

[data-theme="light"] .ticker-item:hover {
    background: #f1f3f5;
}

/* ── Context menu в светлой теме ── */
[data-theme="light"] .context-menu {
    background: #ffffff;
    border-color: #d1d5db;
}

[data-theme="light"] .context-menu-item {
    color: #111827;
}

[data-theme="light"] .context-menu-item:hover {
    background: #f9fafb;
}

/* ── Listings в светлой теме ── */
[data-theme="light"] .listing-card {
    background: #ffffff;
    border-color: #e5e7eb;
}

[data-theme="light"] .listing-card:hover {
    border-color: #b8860b;
}

/* ── Alerts в светлой теме ── */
[data-theme="light"] .alert-item {
    background: #ffffff;
    border-color: #e5e7eb;
}

[data-theme="light"] .alert-symbol {
    color: #b8860b;
}

/* ── Drawings в светлой теме ── */
[data-theme="light"] .drawing-item {
    background: #ffffff;
    border-color: #e5e7eb;
}

/* ── Settings groups в светлой теме ── */
[data-theme="light"] .setting-group {
    background: #f8f9fa;
    border-color: #e5e7eb;
}

[data-theme="light"] .setting-group h4 {
    color: #b8860b;
}

/* ── Tutorial в светлой теме ── */
[data-theme="light"] .tutorial-tooltip {
    background: #ffffff;
    border: 2px solid #b8860b;
}

[data-theme="light"] .tutorial-tooltip .tooltip-header h4 {
    color: #b8860b;
}

[data-theme="light"] .tutorial-welcome-prompt {
    background: #ffffff;
    border: 2px solid #b8860b;
}

[data-theme="light"] .tutorial-welcome-prompt .prompt-text h4 {
    color: #b8860b;
}

/* ── No data / Loading в светлой теме ── */
[data-theme="light"] .no-data,
[data-theme="light"] .loading {
    color: #9ca3af;
}

[data-theme="light"] .error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── Scrollbar в светлой теме ── */
[data-theme="light"] ::-webkit-scrollbar-track {
    background: #f8f9fa;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #d1d5db;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ── Resizer в светлой теме ── */
[data-theme="light"] .resizer-left {
    background: transparent;
}

[data-theme="light"] .resizer-left:hover {
    background: #b8860b;
}

/* ==================== CANDLE TOOLTIP LIGHT ==================== */

[data-theme="light"] .candle-tooltip {
    background: #ffffff;
    border: 2px solid #b8860b;
    color: #111827;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .candle-tooltip .ct-label {
    color: #4b5563;
}

/* ==================== TRANSITIONS ==================== */

* {
    transition: background-color 0.15s ease, 
                border-color 0.15s ease, 
                color 0.15s ease;
}

button, a, input, select, textarea {
    transition: all 0.2s ease;
}

/* ==================== PRINT STYLES ==================== */

@media print {
    [data-theme="light"],
    [data-theme="dark"] {
        --bg-primary: #ffffff;
        --bg-secondary: #f8f9fa;
        --text-primary: #111827;
        --text-secondary: #4b5563;
        --border-primary: #e5e7eb;
        --border-secondary: #d1d5db;
        --accent-primary: #b8860b;
    }
}

/* ==================== REDUCED MOTION ==================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==================== HIGH CONTRAST ==================== */

@media (prefers-contrast: more) {
    :root,
    [data-theme="dark"] {
        --border-primary: #1a1f26;
        --border-secondary: #4b5563;
        --text-secondary: #a0a9b8;
    }
    
    [data-theme="light"] {
        --border-primary: #bfbfbf;
        --border-secondary: #999999;
        --text-secondary: #333333;
    }
}