/* ═══════════════════════════════════════════════════════════════════
   StreakScanner — Dark Premium UI
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
    --bg-deep:      #0a0e17;
    --bg-surface:   #111827;
    --bg-card:      #1a2236;
    --bg-card-alt:  #1f2a40;
    --bg-hover:     #253352;

    --border:       #2a3550;
    --border-light: #334166;

    --text-primary:   #e8ecf4;
    --text-secondary: #8b95ad;
    --text-muted:     #5b6580;

    --accent:       #6366f1;
    --accent-light: #818cf8;
    --accent-glow:  rgba(99, 102, 241, 0.25);

    --green:        #22c55e;
    --green-bg:     rgba(34, 197, 94, 0.12);
    --yellow:       #eab308;
    --yellow-bg:    rgba(234, 179, 8, 0.12);
    --red:          #ef4444;
    --red-bg:       rgba(239, 68, 68, 0.12);
    --blue:         #3b82f6;
    --blue-bg:      rgba(59, 130, 246, 0.12);

    --radius:       12px;
    --radius-sm:    8px;
    --radius-xs:    6px;
    --shadow:       0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg:    0 8px 48px rgba(0, 0, 0, 0.5);
    --transition:   0.2s ease;

    --sidebar-w:    260px;
    --font:         'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
}

a { color: var(--accent-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: #a5b4fc; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 1.8rem; }
.brand-text { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); }
.accent { color: var(--accent-light); }

.sidebar-nav { list-style: none; padding: 16px 12px; flex: 1; }
.sidebar-nav li { margin-bottom: 4px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500; font-size: 1.05rem;
    transition: all var(--transition);
}
.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a.active {
    background: var(--accent-glow);
    color: var(--accent-light);
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon { font-size: 1.25rem; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.user-badge { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700; font-size: 0.85rem; color: white;
}
.user-name { font-size: 0.95rem; color: var(--text-secondary); }
.logout-btn {
    font-size: 1.2rem; color: var(--text-muted);
    padding: 4px 10px; border-radius: var(--radius-xs);
    transition: all var(--transition);
}
.logout-btn:hover { color: var(--red); background: var(--red-bg); }

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px; right: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px; border-radius: var(--radius-sm);
    z-index: 1000; font-size: 1.5rem;
    cursor: pointer;
}

/* ── Main Content ───────────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); padding: 32px 40px; flex: 1; min-height: 100vh; width: calc(100% - var(--sidebar-w)); }
.main-full { padding: 0; flex: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ── Page Header ────────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-secondary); margin-top: 4px; font-size: 1.05rem; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.card--highlight { border-color: var(--accent); box-shadow: 0 0 20px var(--accent-glow); }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: 8px;}
.card-body { padding: 24px; }
.card-text { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 16px; line-height: 1.65; }

/* ── Stats Grid ─────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    display: flex; align-items: center; gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card--accent { border-color: var(--accent); background: linear-gradient(135deg, var(--bg-card), rgba(99,102,241,0.08)); }
.stat-icon { font-size: 2rem; }
.stat-body { display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

/* ── Grid Layouts ───────────────────────────────────────────────── */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 1.5rem; }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table thead th {
    text-align: left; padding: 12px 16px;
    font-size: 0.8rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(42, 53, 80, 0.5);
    vertical-align: middle;
    white-space: nowrap;
}
.table tbody tr:hover { background: var(--bg-hover); }

.match-cell { font-weight: 500; }
.vs { color: var(--text-muted); margin: 0 4px; font-weight: 400; }
.odds-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.weights-cell code {
    font-size: 0.8rem; background: var(--bg-deep);
    padding: 4px 8px; border-radius: var(--radius-xs);
    white-space: normal; word-break: break-all; display: block; max-width: 250px;
}
.rank-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent-glow); color: var(--accent-light);
    font-weight: 700; font-size: 0.85rem;
}

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 4px 10px;
    border-radius: 999px; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-accent { background: var(--accent-glow); color: var(--accent-light); }

/* ── Text Colors ────────────────────────────────────────────────── */
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-accent { color: var(--accent-light); }
.text-muted { color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card-alt);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); color: var(--text-primary); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); color: white; }
.btn-accent {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-color: transparent; color: white;
}
.btn-accent:hover { opacity: 0.9; color: white; }
.btn-secondary { background: transparent; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-full { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 0.9rem; font-weight: 500; color: var(--text-secondary);
}
.form-group input, .form-group select {
    width: 100%; padding: 12px 14px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font); font-size: 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.scan-form { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.scan-form .form-group { margin-bottom: 0; flex: 1; min-width: 200px; }

/* ── Auth ────────────────────────────────────────────────────────── */
.auth-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; width: 100%; padding: 20px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08), transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(139,92,246,0.06), transparent 50%),
        var(--bg-deep);
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
}
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-logo { font-size: 3.5rem; margin-bottom: 12px; }
.auth-header h1 { font-size: 1.8rem; font-weight: 700; }
.auth-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 6px; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 0.9rem; }

/* ── Flash Messages ─────────────────────────────────────────────── */
.flash-container { margin-bottom: 20px; }
.flash {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
    transition: opacity 0.3s ease;
    animation: slideDown 0.3s ease;
}
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.flash-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.flash-info { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }
.flash-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2rem; opacity: 0.6; padding: 4px; display: grid; place-items: center; }

/* ── Metrics ────────────────────────────────────────────────────── */
.backtest-summary, .slip-summary { display: flex; flex-wrap: wrap; gap: 24px; }
.metric { display: flex; flex-direction: column; }
.metric-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 4px; }
.metric-value { font-size: 1.35rem; font-weight: 700; }

/* ── Actions Row ────────────────────────────────────────────────── */
.actions-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state { color: var(--text-muted); font-size: 0.95rem; text-align: center; padding: 32px 16px; }

/* ── Tennis Scanner ─────────────────────────────────────────────── */
.tennis-tabs { display: flex; gap: 12px; margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.tennis-tab { padding: 8px 16px; font-weight: 600; color: var(--text-muted); border-radius: var(--radius-sm); transition: var(--transition); display: flex; align-items: center; gap: 8px; }
.tennis-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.tennis-tab--active { background: var(--bg-hover); color: var(--text-primary); }
.tennis-tab-badge { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; font-weight: 700; }
.tennis-tab-badge--o75 { background: var(--green-bg); color: var(--green); }
.tennis-tab-badge--o85 { background: var(--accent-glow); color: var(--accent-light); }

.tennis-candidates { display: grid; gap: 16px; }
.tennis-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; }
.tennis-card--banker {
    border: 2px solid #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, var(--bg-card) 45%, rgba(245, 158, 11, 0.05) 100%);
    box-shadow: 0 6px 22px rgba(16, 185, 129, 0.18);
}
.tennis-card--banker .tennis-card-header {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.16) 0%, var(--bg-card-alt) 100%);
    border-bottom: 1px solid rgba(16, 185, 129, 0.25);
}
.badge-gold {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-emerald {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34d399;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.banker-info-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(16, 185, 129, 0.06) 100%);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.86rem;
    color: #cbd5e1;
    line-height: 1.45;
}
.banker-info-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}
.tennis-card-header { display: flex; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg-card-alt); flex-wrap: wrap; gap: 8px; }
.tennis-card-rank { margin-right: 16px; }
.tennis-card-tournament { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 200px; }
.tennis-card-body { padding: 20px; }
.tennis-card-matchup { font-size: 1.15rem; font-weight: 600; margin-bottom: 8px; }
.tennis-player-name { color: var(--text-primary); }
.tennis-card-meta { display: flex; gap: 16px; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 20px; }
.tennis-card-meta span { display: flex; align-items: center; gap: 6px; }
.tennis-card-stats { display: flex; gap: 24px; flex-wrap: wrap; }
.tennis-stat { display: flex; flex-direction: column; }
.tennis-stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.tennis-stat-value { font-size: 1.1rem; font-weight: 600; }
.tennis-card-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.1); }

.score-dist-grid { display: flex; flex-direction: column; gap: 12px; }
.score-dist-bar { display: flex; align-items: center; gap: 16px; }
.score-dist-label { width: 60px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.score-dist-track { flex: 1; height: 12px; background: var(--bg-deep); border-radius: 6px; overflow: hidden; }
.score-dist-fill { height: 100%; border-radius: 6px; }
.score-dist-fill--o75 { background: var(--green); }
.score-dist-fill--o85 { background: var(--accent); }
.score-dist-value { width: 50px; text-align: right; font-weight: 600; font-size: 0.9rem; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .grid-2col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 280px; box-shadow: var(--shadow-lg); }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 70px 16px 24px; width: 100%; }
    .mobile-menu-btn { display: block; }
    
    .stats-grid { grid-template-columns: 1fr 1fr; }
    
    .scan-form { flex-direction: column; align-items: stretch; }
    .scan-form .btn { width: 100%; }
    
    .form-row { grid-template-columns: 1fr; }
    
    .page-header h1 { font-size: 1.8rem; }
    .stat-value { font-size: 1.4rem; }
    
    .actions-row { flex-direction: column; }
    .actions-row .btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .metric-value { font-size: 1.15rem; }
}
