/* ══════════════════════════════════════════════════════════════════════════════
   BatQQQ — TradingView-Inspired Theme System
   ══════════════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Sora:wght@500;600;700&display=swap');

:root {
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Sora', 'IBM Plex Sans', sans-serif;
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2035;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --border-color: rgba(42, 46, 57, 0.6);
    --border-light: rgba(42, 46, 57, 0.3);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-purple: #a78bfa;
    --accent-teal: #06b6d4;
}

:root[data-theme='light'] {
    --bg-primary: #edf3fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #dfe8f4;
    --bg-hover: rgba(34, 47, 74, 0.06);
    --border-color: rgba(74, 100, 132, 0.22);
    --border-light: rgba(74, 100, 132, 0.12);
    --text-primary: #152742;
    --text-secondary: #546b89;
    --text-muted: #73839a;
    --accent-blue: #0079b8;
    --accent-green: #0f9f57;
    --accent-red: #d34b64;
    --accent-orange: #d88b00;
    --accent-purple: #6d67ff;
    --accent-teal: #0082a8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* ── Loading Overlay ── */
.loading-overlay {
    position: fixed; inset: 0;
    background: var(--bg-primary);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
    width: 48px; height: 48px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
    font-size: 18px; font-weight: 600; color: var(--text-primary);
    margin-bottom: 8px;
}
.loading-subtext { font-size: 13px; color: var(--text-muted); }

/* ── App Container ── */
.app-container {
    display: flex; flex-direction: column;
    height: 100vh; overflow: hidden;
}

/* ── Header ── */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    height: 44px; min-height: 44px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-center { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; }
.header-right { display: flex; align-items: center; gap: 10px; }

.separator {
    width: 1px; height: 20px;
    background: var(--border-color);
    margin: 0 6px;
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff;
}
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--text-primary); line-height: 1.1; }
.logo-subtitle { font-size: 9px; color: var(--text-muted); font-weight: 400; }

.view-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 8px;
    border-left: 1px solid var(--border-color);
}

.view-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
}

.view-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.view-link.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.28);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}

/* ── Symbol Buttons ── */
.symbol-btn {
    background: transparent; border: none; color: var(--text-muted);
    font-family: inherit; font-size: 12px; font-weight: 500;
    padding: 4px 10px; border-radius: 4px;
    cursor: pointer; transition: all 0.15s;
}
.symbol-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.symbol-btn.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ── Timeframe Buttons ── */
.tf-group { display: flex; gap: 2px; }
.tf-btn {
    background: transparent; border: 1px solid transparent; color: var(--text-muted);
    font-family: inherit; font-size: 11px; font-weight: 500;
    padding: 3px 8px; border-radius: 3px;
    cursor: pointer; transition: all 0.15s;
}
.tf-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.tf-btn.active {
    color: #fff;
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

/* ── Time Range Buttons ── */
.time-range-group { display: flex; gap: 2px; }
.time-btn {
    background: transparent; border: 1px solid transparent; color: var(--text-muted);
    font-family: inherit; font-size: 10px; font-weight: 500;
    padding: 3px 6px; border-radius: 3px;
    cursor: pointer; transition: all 0.15s;
}
.time-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.time-btn.active {
    color: var(--accent-orange);
    background: rgba(249, 115, 22, 0.1);
    border-color: rgba(249, 115, 22, 0.2);
}

/* ── Refresh & Status ── */
.refresh-btn {
    background: transparent; border: 1px solid var(--border-color);
    color: var(--text-secondary); font-family: inherit;
    font-size: 11px; padding: 3px 10px; border-radius: 4px;
    cursor: pointer; transition: all 0.2s;
}
.refresh-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.refresh-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.theme-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-btn:hover {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.status-indicator { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent-green);
}
.status-dot.loading { background: var(--accent-orange); animation: pulse 1.5s infinite; }
.status-dot.error { background: var(--accent-red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Live Badge ── */
.live-badge {
    display: flex; align-items: center; gap: 5px;
    font-size: 10px; font-weight: 600; color: var(--accent-green);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 2px 8px; border-radius: 4px;
}
.live-pulse {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent-green);
    animation: livePulse 1.5s ease-in-out infinite;
}
.live-time {
    color: var(--text-muted); font-weight: 400;
    font-variant-numeric: tabular-nums;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

/* ── Charts Container ── */
.charts-container {
    flex: 1;
    display: flex; flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chart-panel {
    position: relative;
    min-height: 40px;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
}
.chart-panel:last-child { border-bottom: none; }

.chart-panel > div:last-child {
    position: absolute;
    inset: 0;
}

/* ── Chart Labels ── */
.chart-label {
    position: absolute;
    top: 6px; left: 10px;
    z-index: 10;
    display: flex; align-items: baseline; gap: 8px;
    pointer-events: none;
}
.chart-label-text {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
}
.chart-label-price {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.chart-label-change {
    font-size: 12px; font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.chart-label-change.positive { color: var(--accent-green); }
.chart-label-change.negative { color: var(--accent-red); }

/* ── Breadth Legends ── */
.breadth-legend {
    position: absolute;
    top: 4px; left: 10px;
    z-index: 10;
    display: flex; align-items: center; gap: 12px;
    pointer-events: none;
}
.legend-item {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text-secondary);
}
.legend-dot {
    width: 6px; height: 6px; border-radius: 50%;
}
.legend-dot.os {
    background: var(--accent-blue);
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}
.legend-dot.ob {
    background: var(--accent-red);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}
.legend-value {
    font-weight: 600; color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 36px;
}

/* ── Footer ── */
.footer-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    height: 28px; min-height: 28px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 10px; color: var(--text-muted);
}
.footer-stats { display: flex; gap: 16px; }
.footer-stat { display: flex; gap: 4px; }
.footer-stat-label { color: var(--text-muted); }
.footer-stat-value { color: var(--text-secondary); font-weight: 500; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

@media (max-width: 1400px) {
    .header {
        padding: 0 12px;
        gap: 8px;
    }

    .header-left {
        gap: 8px;
    }

    .header-center {
        gap: 2px;
    }

    .view-link {
        min-width: 68px;
        padding: 4px 8px;
    }
}

@media (max-width: 1180px) {
    .header {
        height: auto;
        min-height: 52px;
        padding: 8px 12px;
        flex-wrap: wrap;
    }

    .header-left,
    .header-center,
    .header-right {
        width: 100%;
    }

    .header-center {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .header-right {
        justify-content: space-between;
    }
}
