/* ─── RESET & VARIABLES ─────────────────────────────────────────── */

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

:root {
    --bg-base: #0a0a0a;
    --bg-surface: #111111;
    --bg-card: #1a1a1a;
    --bg-hover: #222222;
    --border: #2a2a2a;
    --border-light: #333333;
    --red: #e10600;
    --red-dark: #b30500;
    --red-glow: rgba(225, 6, 0, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-muted: #555555;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --radius: 6px;
    --transition: 0.2s ease;
}

html,
body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    overflow: hidden;
}


/* ─── LAYOUT ─────────────────────────────────────────────────────── */

body {
    display: flex;
}

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 24px 0;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


/* ─── SIDEBAR ────────────────────────────────────────────────────── */

.sidebar-brand {
    padding: 0 24px 24px;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -0.5px;
}

.brand-f1 {
    color: var(--red);
    font-style: italic;
}

.brand-tracker {
    color: var(--text-primary);
}

.sidebar-meta {
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border);
}

.meta-label {
    display: block;
    color: var(--red);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.meta-version {
    display: block;
    color: var(--text-muted);
    font-size: 10px;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid var(--border);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    cursor: pointer;
}

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

.nav-item.active {
    color: var(--red);
    border-left-color: var(--red);
    background: var(--red-glow);
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}


/* ─── TOPBAR ─────────────────────────────────────────────────────── */

.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
}

.topbar-nav {
    display: flex;
    gap: 32px;
}

.topbar-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    cursor: pointer;
}

.topbar-nav a:hover {
    color: var(--text-primary);
}

.topbar-nav a.active {
    color: var(--red);
    border-bottom-color: var(--red);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 12px;
    letter-spacing: 1px;
    width: 220px;
    outline: none;
    transition: border-color var(--transition);
}

.search-box input:focus {
    border-color: var(--red);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
}

.icon-btn:hover {
    border-color: var(--red);
    color: var(--text-primary);
}


/* ─── PAGES ──────────────────────────────────────────────────────── */

.page {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 36px 40px;
}

.page.active {
    display: block;
}


/* ─── TYPOGRAPHY ─────────────────────────────────────────────────── */

.page-title {
    font-size: 36px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -1px;
    margin-bottom: 6px;
}

.page-title.red {
    color: var(--red);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 32px;
}


/* ─── STAT CARDS ─────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 36px;
    font-weight: 900;
    color: var(--text-primary);
}

.stat-icon {
    font-size: 32px;
    opacity: 0.15;
}


/* ─── SECTION HEADER ─────────────────────────────────────────────── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-secondary);
}


/* ─── BUTTONS ────────────────────────────────────────────────────── */

.btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--red);
    color: #fff;
}

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

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-outline:hover {
    border-color: var(--red);
    color: var(--red);
}

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red);
}

.btn-danger:hover {
    background: var(--red);
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}


/* ─── DRIVER CARDS ───────────────────────────────────────────────── */

.drivers-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.driver-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
}

.driver-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.driver-card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: top;
    filter: grayscale(60%);
    display: block;
    background: var(--bg-hover);
}

.driver-card-img-placeholder {
    width: 100%;
    height: 200px;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--text-muted);
}

.driver-card-body {
    padding: 16px;
}

.driver-team {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.team-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    flex-shrink: 0;
}

.driver-name {
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 12px;
}

.driver-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.driver-number {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-muted);
}

.driver-nationality {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.driver-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.driver-actions .btn {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 6px 8px;
    font-size: 10px;
}


/* ─── RACE CARDS ─────────────────────────────────────────────────── */

.races-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.race-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
}

.race-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.race-card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    filter: grayscale(50%) brightness(0.7);
    display: block;
    background: var(--bg-hover);
    position: relative;
}

.race-card-img-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #1a1a1a, #0a0a0a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.race-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 4px 8px;
    border-radius: 3px;
}

.race-card-img-wrap {
    position: relative;
}

.race-card-body {
    padding: 16px;
}

.race-country {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.race-name {
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 12px;
}

.race-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.race-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.race-info-icon {
    color: var(--text-muted);
}

.race-actions {
    display: flex;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}


/* ─── RESULTS TABLE ──────────────────────────────────────────────── */

.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

thead {
    background: var(--bg-surface);
}

th {
    padding: 14px 20px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px 20px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

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

tbody tr:hover {
    background: var(--bg-hover);
}

.pos-cell {
    font-size: 18px;
    font-weight: 900;
    color: var(--text-muted);
    width: 60px;
}

.pos-cell.top3 {
    color: var(--text-primary);
}

.pos-cell::before {
    content: '0';
    color: transparent;
}

.points-cell {
    color: var(--red);
    font-weight: 700;
    font-size: 15px;
}

.fl-icon {
    color: var(--red);
    font-size: 14px;
}

.driver-col {
    display: flex;
    flex-direction: column;
}

.driver-col-name {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
}

.driver-col-nat {
    font-size: 11px;
    color: var(--text-secondary);
}


/* ─── SEARCH + FILTERS BAR ───────────────────────────────────────── */

.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.filter-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 12px;
    outline: none;
    transition: border-color var(--transition);
    flex: 1;
    max-width: 320px;
}

.filter-input:focus {
    border-color: var(--red);
}

.filter-input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

.filter-select:focus {
    border-color: var(--red);
}

.filter-select option {
    background: var(--bg-card);
}


/* ─── PAGINATION ─────────────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    justify-content: center;
}

.page-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: all var(--transition);
}

.page-btn:hover {
    border-color: var(--red);
    color: var(--red);
}

.page-btn.active {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-info {
    color: var(--text-secondary);
    font-size: 12px;
}


/* ─── MODAL ──────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--red);
}

.modal-body {
    padding: 24px;
}


/* ─── FORMS ──────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus {
    border-color: var(--red);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select option {
    background: var(--bg-surface);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}


/* ─── TOAST ──────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--red);
    color: var(--text-primary);
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    z-index: 2000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast.success {
    border-left-color: #00c851;
}

.toast.error {
    border-left-color: var(--red);
}


/* ─── LOADING ────────────────────────────────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--red);
    border-radius: 50%;
    margin-right: 12px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* ─── EMPTY STATE ────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}


/* ─── SCROLLBAR ──────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--red);
}


/* ─── DASHBOARD SPECIFIC ─────────────────────────────────────────── */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    margin-top: 8px;
}

.recent-results-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.recent-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.recent-result-row {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    transition: background var(--transition);
}

.recent-result-row:hover {
    background: var(--bg-hover);
}

.recent-result-row:last-child {
    border-bottom: none;
}

.rr-pos {
    font-size: 20px;
    font-weight: 900;
    color: var(--text-muted);
    width: 28px;
}

.rr-pos.p1 {
    color: var(--red);
}

.rr-info {
    flex: 1;
}

.rr-name {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
}

.rr-team {
    font-size: 11px;
    color: var(--text-secondary);
}

.rr-right {
    text-align: right;
}

.rr-gp {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rr-pts {
    font-size: 13px;
    font-weight: 700;
    color: var(--red);
}

.season-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.season-bar-label {
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.season-progress-wrap {
    flex: 1;
}

.season-progress-track {
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}

.season-progress-fill {
    height: 100%;
    background: var(--red);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.season-pct {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}