/* ============================================================
   BETTING MASTER — QUANT TRADING TERMINAL DESIGN SYSTEM
   High-precision dark theme, responsive, accessible
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ---------- Reset & Box Model ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Background Layering */
    --bg-base:        #080b0f;
    --bg-primary:     #0c1017;
    --bg-surface:     #121822;
    --bg-card:        #161e2a;
    --bg-card-hover:  #1d2737;
    --bg-elevated:    #222d3d;
    --bg-input:       #0a0e14;
    
    /* Borders */
    --border-subtle:  #1e293b;
    --border-default: #283548;
    --border-strong:  #3b4c65;
    --border-accent:  rgba(56, 189, 248, 0.4);

    /* Text Colors */
    --text-primary:   #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;
    --text-disabled:  #475569;

    /* Semantics & Indicators */
    --accent:         #38bdf8;
    --accent-hover:   #0ea5e9;
    --accent-dim:     rgba(56, 189, 248, 0.12);
    --accent-glow:    rgba(56, 189, 248, 0.25);

    --positive:       #10b981;
    --positive-hover: #059669;
    --positive-dim:   rgba(16, 185, 129, 0.12);
    --positive-glow:  rgba(16, 185, 129, 0.25);

    --negative:       #f43f5e;
    --negative-dim:   rgba(244, 63, 94, 0.12);

    --warning:        #f59e0b;
    --warning-dim:    rgba(245, 158, 11, 0.12);

    --info:           #818cf8;
    --info-dim:       rgba(129, 140, 248, 0.12);

    --paper:          #a855f7;
    --paper-dim:      rgba(168, 85, 247, 0.15);

    /* Typography */
    --font:           'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono:           'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

    /* Radii */
    --radius-xs:      3px;
    --radius-sm:      6px;
    --radius-md:      8px;
    --radius-lg:      12px;
    --radius-pill:    9999px;

    /* Shadows */
    --shadow-sm:      0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md:      0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg:      0 12px 30px rgba(0, 0, 0, 0.6);
    --shadow-accent:  0 0 16px var(--accent-glow);

    /* Layout metrics */
    --sidebar-w:      240px;
    --header-h:       64px;
}

html {
    font-size: 14px;
    background: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Accessibility: focus rings */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ---------- Typography Utilities ---------- */
.mono { font-family: var(--mono); font-feature-settings: 'tnum' 1; }
.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.82rem; }
.text-md { font-size: 0.92rem; }
.text-lg { font-size: 1.15rem; }
.text-xl { font-size: 1.45rem; }
.text-2xl { font-size: 1.85rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.text-paper { color: var(--paper); }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.brand-sub {
    font-size: 0.68rem;
    font-family: var(--mono);
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 16px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 10px 12px 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    text-decoration: none;
    position: relative;
}

.sidebar-nav a:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
    border-left: 3px solid var(--accent);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.sidebar-nav .nav-icon {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.status-indicator-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}
.pulse-dot.online { background: var(--positive); box-shadow: 0 0 8px var(--positive); }
.pulse-dot.reconnecting { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.pulse-dot.offline { background: var(--negative); box-shadow: 0 0 8px var(--negative); }
.pulse-dot.auth { background: var(--paper); box-shadow: 0 0 8px var(--paper); }

/* ---------- Main Layout ---------- */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-header {
    height: var(--header-h);
    padding: 0 28px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(18, 24, 34, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1.1rem;
}

.page-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-clock-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.refresh-indicator {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--mono);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all 0.15s ease;
}
.refresh-indicator:hover {
    border-color: var(--border-default);
    color: var(--text-primary);
    background: var(--bg-card);
}

.page-content {
    padding: 24px 28px 48px;
    flex: 1;
    max-width: 1600px;
    width: 100%;
}

/* ---------- Cards & Grid System ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}
.card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.card-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-value {
    font-size: 1.85rem;
    font-weight: 700;
    font-family: var(--mono);
    line-height: 1.2;
    color: var(--text-primary);
}

.card-sub {
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---------- Panels ---------- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.panel-body {
    padding: 18px 20px;
}
.panel-body.no-pad { padding: 0; }

/* ---------- Tables ---------- */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
}

.data-table th {
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-secondary);
    transition: background 0.12s;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.data-table .mono { font-family: var(--mono); font-size: 0.8rem; }
.data-table .right { text-align: right; }
.data-table .center { text-align: center; }
.data-table .nowrap { white-space: nowrap; }

/* Table density modes */
body[data-density="compact"] .data-table td { padding: 6px 10px; font-size: 0.78rem; }
body[data-density="compact"] .data-table th { padding: 6px 10px; font-size: 0.68rem; }

/* ---------- Badges & Chips ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-green   { background: var(--positive-dim); color: var(--positive); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-yellow  { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-red     { background: var(--negative-dim); color: var(--negative); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-blue    { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--border-accent); }
.badge-purple  { background: var(--paper-dim); color: var(--paper); border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-muted   { background: rgba(255, 255, 255, 0.04); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.badge-outline { background: transparent; border: 1px solid var(--border-default); color: var(--text-secondary); }

/* Sport chips */
.sport-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    border-radius: var(--radius-xs);
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    text-transform: uppercase;
}
.sport-chip.soccer   { border-color: rgba(16, 185, 129, 0.4); color: var(--positive); }
.sport-chip.hockey   { border-color: rgba(56, 189, 248, 0.4); color: var(--accent); }
.sport-chip.football { border-color: rgba(245, 158, 11, 0.4); color: var(--warning); }
.sport-chip.baseball { border-color: rgba(217, 119, 6, 0.4); color: #d97706; }
.sport-chip.tennis   { border-color: rgba(168, 85, 247, 0.4); color: var(--paper); }

/* Horizon tag */
.horizon-tag {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--border-accent);
}
.horizon-tag.close {
    background: var(--warning-dim);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.4);
}

/* ---------- Buttons & Inputs ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    font-family: var(--font);
    user-select: none;
}

.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-strong);
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #041019;
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-elevated);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 9px;
    font-size: 0.74rem;
}

.filter-input, .filter-select {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font);
    transition: border-color 0.15s;
}

.filter-input:focus, .filter-select:focus {
    border-color: var(--accent);
    outline: none;
}

/* ---------- Filter Bar ---------- */
.filters-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

/* ---------- Progress Bar ---------- */
.progress-wrap {
    width: 100%;
    height: 6px;
    background: var(--bg-surface);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-top: 6px;
}
.progress-bar {
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 0.4s ease;
}
.progress-bar.ok     { background: var(--positive); }
.progress-bar.warn   { background: var(--warning); }
.progress-bar.danger { background: var(--negative); }

/* ---------- Quant Signal Cards Grid ---------- */
.signals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.signal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    position: relative;
}
.signal-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.signal-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bet-hero {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bet-selection {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.bet-book-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.bet-odds-display {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--positive);
    text-align: right;
    line-height: 1;
}

.signal-metric-pills {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.signal-metric-pills .pill {
    background: var(--bg-surface);
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    font-family: var(--mono);
    border: 1px solid var(--border-subtle);
}

/* ---------- Empty States ---------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
    opacity: 0.6;
}
.empty-state h3 {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}
.empty-state p {
    font-size: 0.85rem;
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ---------- Skeletons ---------- */
.skeleton {
    background: linear-gradient(90deg, #161e2a 25%, #222d3d 37%, #161e2a 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(4, 7, 12, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
}
.modal-title { font-weight: 700; font-size: 1rem; }

/* ---------- Command Palette (Cmd+K) ---------- */
.command-palette-dialog {
    max-width: 600px;
}
.command-palette-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-card);
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font);
}
.command-palette-input:focus { outline: none; }
.command-palette-list {
    max-height: 340px;
    overflow-y: auto;
    padding: 8px;
}
.command-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    font-size: 0.88rem;
}
.command-item:hover, .command-item.selected {
    background: var(--accent-dim);
    color: var(--accent);
}

/* ---------- Toasts ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 0.84rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast-success { background: #064e3b; color: #a7f3d0; border: 1px solid #059669; }
.toast-error   { background: #881337; color: #fecdd3; border: 1px solid #e11d48; }
.toast-info    { background: #1e1b4b; color: #c7d2fe; border: 1px solid #4f46e5; }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---------- Responsive Breakpoints ---------- */
@media (max-width: 1024px) {
    .main { margin-left: 0; }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .mobile-menu-btn { display: inline-flex; }
    .page-content { padding: 16px; }
}

@media (max-width: 640px) {
    .cards { grid-template-columns: 1fr; }
    .signals-grid { grid-template-columns: 1fr; }
    .page-header { padding: 0 16px; }
    .header-clock-wrap { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
