/* ═══════════════════════════════════════════════════════════════
   OLOXIA Dashboard — Professional Theme v2
   Design system aligned with oloxia.com
   ═══════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    --bg-deep:           #060810;
    --bg-primary:        #0a0d14;
    --bg-card:           #111620;
    --bg-card-hover:     #171e2c;
    --bg-header:         rgba(6, 8, 16, 0.8);
    --bg-cell:           rgba(255, 255, 255, 0.025);
    --border:            #1c2436;
    --border-light:      #253048;
    --border-subtle:     rgba(255, 255, 255, 0.05);
    --text-primary:      #e2e8f0;
    --text-secondary:    #94a3b8;
    --text-muted:        #5a6a82;
    --green:             #22c55e;
    --green-dim:         rgba(34, 197, 94, 0.12);
    --green-glow:        rgba(34, 197, 94, 0.06);
    --red:               #ef4444;
    --red-dim:           rgba(239, 68, 68, 0.12);
    --blue:              #3b82f6;
    --blue-glow:         #60a5fa;
    --yellow:            #f0c040;
    --accent:            #3b82f6;
    --mono:              'JetBrains Mono', 'Fira Code', monospace;
    --sans:              'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* League colors */
    --league-nba:        #dc2626;
    --league-ncaab:      #7c3aed;
    --league-ebasketball: #06b6d4;
    --league-default:    #6b7280;

    /* Legacy color mappings for compatibility */
    --bg:                var(--bg-deep);
    --fg:                var(--text-primary);
    --fg-muted:          var(--text-muted);
    --chart-bg:          #0f1219;

    /* Sizing */
    --radius-sm:         4px;
    --radius-md:         8px;
    --radius-lg:         12px;
    --nav-height:        60px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--sans);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Ambient grid background (matches oloxia.com) ─── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
    background-size: 64px 64px;
    pointer-events: none;
    z-index: 0;
}

/* ─── Custom scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }


/* ═══════════════════════════════════════════════════════════════
   Navigation Bar — Glassmorphism (matches oloxia.com nav)
   ═══════════════════════════════════════════════════════════════ */

.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-height);
    padding: 0 24px;
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.top-bar h1 {
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-decoration: none;
    flex-shrink: 0;
}

.top-bar h1 span { color: var(--green) !important; }

/* ─── Logo ─── */
.logo {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-decoration: none;
    flex-shrink: 0;
}

.logo span { color: var(--green); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-muted);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    transition: background 0.3s;
}

.status-dot.connected { background: var(--green); }


/* ═══════════════════════════════════════════════════════════════
   League Toggle Buttons
   ═══════════════════════════════════════════════════════════════ */

.league-toggles {
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 1;
}

.league-toggle-btn {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--text-muted);
}

.league-toggle-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-light);
    background: rgba(255, 255, 255, 0.02);
}

.league-toggle-btn.active {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.3);
}

/* League-specific active colors */
.league-toggle-btn.NBA.active {
    background: rgba(220, 38, 38, 0.10);
    color: #ef4444;
    border-color: rgba(220, 38, 38, 0.3);
}

.league-toggle-btn.NCAAB.active {
    background: rgba(124, 58, 237, 0.10);
    color: #a78bfa;
    border-color: rgba(124, 58, 237, 0.3);
}

.league-toggle-btn.EBASKETBALL_H2H.active,
.league-toggle-btn.EBASKETBALL.active {
    background: rgba(6, 182, 212, 0.10);
    color: #22d3ee;
    border-color: rgba(6, 182, 212, 0.3);
}

.league-toggle-btn.hidden-league {
    background: transparent;
    color: var(--text-secondary);
    opacity: 0.6;
    border-color: var(--border);
}


/* ═══════════════════════════════════════════════════════════════
   Source Filter Buttons
   ═══════════════════════════════════════════════════════════════ */

.source-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 1;
}

.src-filter-btn {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--text-muted);
}

.src-filter-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-light);
    background: rgba(255, 255, 255, 0.02);
}

.src-filter-btn.bet365.active {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.3);
}

.src-filter-btn.fanduel.active {
    background: rgba(59, 130, 246, 0.10);
    color: var(--blue-glow);
    border-color: rgba(96, 165, 250, 0.3);
}

/* ─── Top bar right group ─── */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

/* ─── Auth nav link ─── */
.auth-nav-link {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    white-space: nowrap;
}

.auth-nav-link:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* ─── Source indicator pill (per-card) ─── */
.source-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--mono);
    color: var(--text-muted);
}

.source-tag {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    letter-spacing: 0.04em;
    font-family: var(--mono);
    font-size: 10px;
}

.source-tag.fanduel {
    color: var(--blue-glow);
    border-color: rgba(96, 165, 250, 0.25);
    background: rgba(96, 165, 250, 0.06);
}

.source-tag.bet365 {
    color: var(--green);
    border-color: rgba(34, 197, 94, 0.25);
    background: rgba(34, 197, 94, 0.06);
}

/* ─── Version tag ─── */
.version-tag {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.5;
}


/* ═══════════════════════════════════════════════════════════════
   Game Grid
   ═══════════════════════════════════════════════════════════════ */

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 14px;
    width: 100%;
}


/* ═══════════════════════════════════════════════════════════════
   League Section Headers
   ═══════════════════════════════════════════════════════════════ */

.league-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 6px 16px;
    margin-top: 4px;
    background: transparent;
    border-left: 3px solid var(--league-default);
}

.league-header.NBA {
    border-left-color: #dc2626;
}

.league-header.NCAAB {
    border-left-color: #7c3aed;
}

.league-header.EBASKETBALL_H2H,
.league-header.EBASKETBALL {
    border-left-color: #06b6d4;
}


/* ═══════════════════════════════════════════════════════════════
   Game Card
   ═══════════════════════════════════════════════════════════════ */

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 420px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        0 0 1px rgba(0, 0, 0, 0.3);
}

.game-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.3),
        0 0 1px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

/* ─── Card Header ─── */
.card-header {
    display: flex;
    flex-direction: column;
    padding: 10px 14px 8px;
    background: linear-gradient(180deg, rgba(6, 8, 16, 0.95) 0%, rgba(14, 18, 25, 0.85) 100%);
    border-bottom: 1px solid var(--border);
    gap: 5px;
    flex: 0 0 auto;
}

/* ─── Title Row ─── */
.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-source {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.card-title {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.card-period {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--yellow);
    background: rgba(240, 192, 64, 0.08);
    border: 1px solid rgba(240, 192, 64, 0.18);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.06em;
}

.card-score {
    color: var(--green);
    font-family: var(--mono);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

/* ─── Stats Grid ─── */
.card-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
}

.card-stats > div {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--text-muted);
    background: var(--bg-cell);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 3px 4px;
    transition: background 0.15s;
    letter-spacing: 0.01em;
}

.card-stats .val {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 12.5px;
}

.card-stats > div.q-act {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.12);
}

/* ─── Quarter ACT Row ─── */
.quarter-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
}

.quarter-row > div,
.quarter-row > .q-act {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--text-muted);
    background: var(--bg-cell);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 3px 4px;
    transition: background 0.15s;
}

.quarter-row > .q-act {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.12);
}

.quarter-row .val {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 12.5px;
}


/* ═══════════════════════════════════════════════════════════════
   Chart Area
   ═══════════════════════════════════════════════════════════════ */

.chart-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.chart-container {
    position: relative;
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    background: var(--chart-bg);
}

.custom-x-axis {
    display: flex;
    justify-content: space-evenly;
    background: var(--chart-bg);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 9px;
    padding: 2px 0 4px;
    border-top: 1px solid var(--border-subtle);
}

/* ─── TEP x-axis labels ─── */
.tep-x-axis {
    position: relative;
    height: 20px;
    background: var(--chart-bg);
    border-top: 1px solid var(--border-subtle);
    overflow: hidden;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.tep-x-label {
    position: absolute;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 9px;
    line-height: 20px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0.7;
}

.tep-x-label.tep-period-label {
    color: var(--text-secondary);
    font-weight: 600;
    opacity: 1;
}

/* ─── TEP Vertical Markers ─── */
.tep-vline-yellow {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dashed rgba(34, 197, 94, 0.35);
    pointer-events: none;
    z-index: 5;
}

.tep-vline-blue {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dotted rgba(59, 130, 246, 0.3);
    pointer-events: none;
    z-index: 5;
}

.tep-vline-blue-thick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dotted rgba(59, 130, 246, 0.5);
    pointer-events: none;
    z-index: 5;
}


/* ═══════════════════════════════════════════════════════════════
   Reconnect Overlay
   ═══════════════════════════════════════════════════════════════ */

.reconnect-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg-deep);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

.reconnect-overlay.active {
    display: flex;
}

.reconnect-loader {
    position: relative;
    width: 72px;
    height: 72px;
}

.ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
}

.ring-outer {
    border-top-color: var(--green);
    border-right-color: rgba(34, 197, 94, 0.2);
    animation: spin-outer 1.2s cubic-bezier(0.6, 0.15, 0.35, 0.85) infinite;
}

.ring-inner {
    inset: 14px;
    border-bottom-color: var(--blue);
    border-left-color: rgba(59, 130, 246, 0.2);
    animation: spin-inner 0.9s cubic-bezier(0.6, 0.15, 0.35, 0.85) infinite;
}

.pulse-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--green);
    animation: pulse-dot 2s ease-in-out infinite;
}

.reconnect-text {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    animation: text-fade 2s ease-in-out infinite;
}

@keyframes spin-outer  { to { transform: rotate(360deg); } }
@keyframes spin-inner  { to { transform: rotate(-360deg); } }
@keyframes pulse-dot   { 0%, 100% { opacity: 0.2; transform: translate(-50%, -50%) scale(0.7); }
                          50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.3); } }
@keyframes text-fade   { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.9; } }


/* ═══════════════════════════════════════════════════════════════
   Empty State
   ═══════════════════════════════════════════════════════════════ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 70vh;
    color: var(--text-muted);
    font-size: 15px;
    gap: 24px;
}

.empty-state .spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 10px;
    }

    .top-bar {
        padding: 0 14px;
        padding-top: env(safe-area-inset-top, 0);
        height: auto;
        min-height: var(--nav-height);
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .top-bar h1 {
        font-size: 13px;
        width: 100%;
        text-align: center;
        order: -1;
    }

    .league-toggles {
        justify-content: center;
        flex-wrap: wrap;
    }

    .top-bar-right {
        gap: 8px;
    }

    .game-card {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .game-card { height: 370px; }

    .card-stats {
        font-size: 10px;
    }

    .card-stats .val { font-size: 11px; }

    .top-bar h1 { font-size: 12px; }
}
