/* ══════════════════════════════════════════════
   F1 POOL — Clean Racing Theme
   Smooth lines · Vivid color · Light & fast
   ══════════════════════════════════════════════ */

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

:root {
    /* Core palette */
    --red: #E10600;
    --red-light: #FF4136;
    --red-dark: #B30500;
    --bg: #FAFBFC;
    --surface: #FFFFFF;
    --surface-alt: #F4F6F8;
    --text: #1A1D26;
    --text-2: #5A6072;
    --text-3: #8E95A8;
    --border: #E6E9EF;
    --border-dark: #CDD2DC;
    --success: #00C853;
    --warning: #FF9100;
    --info: #2979FF;

    /* Shadows */
    --sh-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --sh-md: 0 4px 12px rgba(0,0,0,.07);
    --sh-lg: 0 8px 30px rgba(0,0,0,.1);

    /* Geometry */
    --r: 16px;
    --r-sm: 10px;
    --r-xs: 6px;

    /* Fonts */
    --f-head: 'Space Grotesk', sans-serif;
    --f-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Team colors */
    --t-mcl: #FF8000;
    --t-fer: #E8002D;
    --t-rbr: #3671C6;
    --t-mer: #27F4D2;
    --t-amr: #229971;
    --t-alp: #FF87BC;
    --t-haa: #B6BABD;
    --t-rbs: #6692FF;
    --t-wil: #64C4FF;
    --t-aud: #1D6951;
    --t-cad: #C0C0C0;
}

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

body {
    font-family: var(--f-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-decoration: none; transition: color .15s; }
a:hover { color: var(--red-dark); }

/* ── Top Accent Stripe ─────────────────────── */
body::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--red) 0%, var(--t-mcl) 20%, var(--t-mer) 40%, var(--t-rbr) 60%, var(--t-alp) 80%, var(--t-aud) 100%);
}

/* ── Navigation ────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--sh-sm);
}

.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.navbar-brand {
    font-family: var(--f-head);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--red);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand .brand-dot {
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: 50%;
    display: inline-block;
}

.navbar-links {
    display: flex;
    gap: 4px;
    list-style: none;
    align-items: center;
}

.navbar-links a {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: var(--r-sm);
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-2);
    transition: all .15s;
}

.navbar-links a:hover,
.navbar-links a.active {
    background: var(--surface-alt);
    color: var(--text);
}

.navbar-links a.active {
    color: var(--red);
    font-weight: 600;
}

.navbar-links a.admin-link {
    color: var(--warning);
    font-weight: 600;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
}

@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .menu-toggle { display: block; }
    .navbar-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0; right: 0;
        background: var(--surface);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--sh-lg);
        gap: 2px;
    }
    .navbar-links.open { display: flex; }
    .navbar-links a { padding: 10px 14px; }
}

/* ── Container ─────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

@media (max-width: 600px) {
    .container { padding: 1rem; }
}

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--r);
    border: 1px solid var(--border);
    box-shadow: var(--sh-sm);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: box-shadow .2s;
}

.card:hover { box-shadow: var(--sh-md); }

.card-header {
    font-family: var(--f-head);
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header .accent-line {
    width: 4px;
    height: 18px;
    background: var(--red);
    border-radius: 2px;
}

/* ── Page Header ───────────────────────────── */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-family: var(--f-head);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.page-header h1 .highlight {
    color: var(--red);
}

.page-header p {
    color: var(--text-2);
    margin-top: .25rem;
}

/* ── Stats ─────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--surface);
    border-radius: var(--r);
    border: 1px solid var(--border);
    padding: 1.25rem;
    box-shadow: var(--sh-sm);
    position: relative;
    overflow: hidden;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--red);
}

.stat-box .stat-value {
    font-family: var(--f-head);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    display: block;
    letter-spacing: -0.5px;
}

.stat-box .stat-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
}

/* ── Buttons ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--r-sm);
    font-size: .875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .15s;
    font-family: var(--f-body);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--red);
    color: white;
}
.btn-primary:hover { background: var(--red-dark); color: white; }

.btn-secondary {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #00A844; color: white; }

.btn-gold { background: var(--warning); color: white; }
.btn-gold:hover { background: #E67E00; color: white; }

.btn-small { padding: 6px 12px; font-size: .8rem; }

/* ── Flash Messages ────────────────────────── */
.flash-messages { margin-bottom: 1.5rem; }

.flash {
    padding: 12px 16px;
    border-radius: var(--r-sm);
    margin-bottom: .5rem;
    font-size: .875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 4px solid;
}

.flash-success { background: #E8F5E9; color: #2E7D32; border-color: #4CAF50; }
.flash-error { background: #FFEBEE; color: #C62828; border-color: #E53935; }
.flash-info { background: #E3F2FD; color: #1565C0; border-color: #2196F3; }

/* ── Forms ─────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: .9rem;
    font-family: var(--f-body);
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(225,6,0,.1);
}

/* ── Driver Grid ───────────────────────────── */
.driver-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: .75rem;
    margin-top: 1rem;
}

.driver-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    padding: 1rem 1rem 1rem 1.25rem;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    border-left: 5px solid var(--team-color, var(--border));
}

.driver-card:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
}

.driver-card.selected {
    border-color: var(--success);
    border-left-color: var(--success);
    background: #F0FFF4;
}

.driver-card.selected::after {
    content: '\2713';
    position: absolute;
    top: 8px; right: 8px;
    background: var(--success);
    color: white;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: bold;
}

.driver-card.unavailable {
    opacity: .35;
    cursor: not-allowed;
    background: var(--surface-alt);
}

.driver-card .driver-name {
    font-weight: 700;
    font-size: .95rem;
}

.driver-card .driver-team {
    font-size: .8rem;
    color: var(--text-2);
    margin-top: 2px;
}

.driver-card .driver-uses {
    font-size: .75rem;
    color: var(--text-3);
    margin-top: 6px;
}

.driver-card .driver-uses .remaining { font-weight: 700; color: var(--success); }
.driver-card .driver-uses .remaining.low { color: var(--warning); }
.driver-card .driver-uses .remaining.none { color: var(--red); }

/* ── Usage Grid ────────────────────────────── */
.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 6px;
}

.usage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--r-xs);
    background: var(--surface-alt);
    font-size: .83rem;
}

.usage-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.usage-pips { display: flex; gap: 3px; margin-left: auto; }

.usage-pip {
    width: 14px; height: 14px;
    border-radius: 3px;
    border: 2px solid var(--border-dark);
    background: var(--surface);
}

.usage-pip.used { background: var(--red); border-color: var(--red); }

/* ── Tables ────────────────────────────────── */
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

table th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-3);
    font-weight: 600;
    padding: .75rem;
    border-bottom: 2px solid var(--border);
    text-align: left;
}

table td {
    padding: .75rem;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

table tbody tr:hover { background: var(--surface-alt); }

/* ── Race Chips ────────────────────────────── */
.race-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1.5rem;
}

.race-chip {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    text-decoration: none;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.race-chip:hover { border-color: var(--red); color: var(--red); }

.race-chip.active {
    background: var(--red);
    color: white;
    border-color: var(--red);
}

.race-chip.has-pick {
    background: #E8F5E9;
    border-color: var(--success);
    color: #2E7D32;
}

.race-chip .sprint-badge {
    background: var(--warning);
    color: white;
    font-size: .6rem;
    padding: 1px 4px;
    border-radius: 3px;
}

/* ══════════════════════════════════════════════
   STANDINGS — Race Track Visualization
   ══════════════════════════════════════════════ */
.race-track {
    background: var(--surface);
    border-radius: var(--r);
    border: 1px solid var(--border);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--sh-sm);
}

.race-track .track-title {
    font-family: var(--f-head);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
}

.track-lane {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}

.track-position {
    font-family: var(--f-head);
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-3);
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.track-position.p1 { color: var(--red); }

.track-name {
    font-weight: 600;
    font-size: .9rem;
    width: 100px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-bar-container {
    flex: 1;
    height: 32px;
    background: var(--surface-alt);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
}

.track-bar {
    height: 100%;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    transition: width 1.2s cubic-bezier(.4,0,.2,1);
    min-width: 36px;
    position: relative;
}

.track-car {
    font-size: 1.2rem;
    position: absolute;
    right: 4px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.track-points {
    font-family: var(--f-head);
    font-size: .8rem;
    font-weight: 700;
    width: 60px;
    text-align: right;
    flex-shrink: 0;
    color: var(--text);
}

.finish-line {
    width: 8px;
    height: 100%;
    position: absolute;
    right: 0; top: 0;
    background: repeating-linear-gradient(180deg, #000 0px, #000 4px, #fff 4px, #fff 8px);
    opacity: .15;
}

/* ── Pick Rows ─────────────────────────────── */
.pick-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: background .15s;
}

.pick-row:hover { background: var(--surface-alt); }
.pick-row.completed { border-left: 3px solid var(--success); }
.pick-row.locked { background: var(--surface-alt); }

.pick-row .race-round {
    font-family: var(--f-head);
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-3);
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.pick-row .race-info { flex: 1; min-width: 0; }

.pick-row .race-name {
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pick-row .race-date { font-size: .8rem; color: var(--text-3); }

.pick-row .pick-driver {
    font-weight: 600;
    font-size: .875rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--surface-alt);
}

.pick-row .pick-points {
    font-family: var(--f-head);
    font-size: .8rem;
    font-weight: 700;
    width: 50px;
    text-align: right;
    flex-shrink: 0;
}

.pick-row .pick-points.positive { color: var(--success); }
.pick-row .no-pick { color: var(--text-3); font-style: italic; font-size: .85rem; }
.pick-row .secret-pick { color: var(--text-3); font-style: italic; font-size: .85rem; }

/* ── Auth Pages ────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #FAFBFC 0%, #F0F2F5 100%);
}

.auth-card {
    background: var(--surface);
    border-radius: var(--r);
    border: 1px solid var(--border);
    box-shadow: var(--sh-lg);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.auth-card::before {
    content: '';
    display: block;
    height: 4px;
    margin: -3rem -2.5rem 2rem;
    border-radius: var(--r) var(--r) 0 0;
    background: linear-gradient(90deg, var(--red) 0%, var(--t-mcl) 25%, var(--t-mer) 50%, var(--t-rbr) 75%, var(--t-alp) 100%);
}

.auth-card h1 {
    font-family: var(--f-head);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.auth-card h1 .red { color: var(--red); }

.auth-card .subtitle {
    color: var(--text-2);
    margin-bottom: 1.5rem;
    font-size: .9rem;
}

.auth-card .form-group { text-align: left; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: .5rem; padding: 12px; }

.auth-links { margin-top: 1.25rem; font-size: .85rem; color: var(--text-2); }

/* ── Admin ─────────────────────────────────── */
.admin-section {
    border: 2px dashed var(--warning);
    border-radius: var(--r);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: #FFF8E1;
}

.admin-section h2 {
    font-family: var(--f-head);
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.admin-race-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.admin-race-row:last-child { border-bottom: none; }

.admin-race-round {
    font-family: var(--f-head);
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-3);
    width: 30px;
}

.admin-race-name { font-weight: 600; flex: 1; min-width: 150px; }

.admin-badge {
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-completed { background: #E8F5E9; color: #2E7D32; }
.badge-revealed { background: #E3F2FD; color: #1565C0; }
.badge-sprint { background: #FFF3E0; color: #E65100; }
.badge-upcoming { background: #FFF8E1; color: #F57F17; }
.badge-locked { background: #FFEBEE; color: #C62828; }

/* ── Grid ──────────────────────────────────── */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 600px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .driver-grid { grid-template-columns: 1fr; }
    .track-name { width: 70px; font-size: .8rem; }
    .track-points { width: 50px; font-size: .75rem; }
    .page-header h1 { font-size: 1.3rem; }
}
