/* F1 Chronos — Résultats · design system (bleu primaire / orange accent, sombre) */

:root {
    --bg: #0a0f1c;
    --bg-soft: #0d1424;
    --card: #111a2e;
    --card-hover: #162240;
    --line: rgba(148, 163, 216, 0.14);
    --line-strong: rgba(148, 163, 216, 0.28);
    --text: #e8edf7;
    --muted: #8fa0c2;
    --blue: #3b82f6;
    --blue-strong: #2563eb;
    --blue-soft: rgba(59, 130, 246, 0.14);
    --orange: #f97316;
    --orange-strong: #ea580c;
    --orange-soft: rgba(249, 115, 22, 0.14);
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
    --gold: #f5c518;
    --silver: #c9d1e0;
    --bronze: #d08a4e;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 28px rgba(2, 6, 18, 0.5);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(1000px 500px at 85% -10%, rgba(59, 130, 246, 0.10) 0%, transparent 55%),
        radial-gradient(800px 400px at -10% 0%, rgba(249, 115, 22, 0.06) 0%, transparent 50%),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: #7fb0ff; }

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: rgba(10, 15, 28, 0.88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    letter-spacing: 0.07em;
    color: var(--text);
    white-space: nowrap;
}
.brand img { width: 22px; height: 22px; }
.brand small {
    color: var(--orange);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.topbar nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-link {
    padding: 7px 13px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--blue-soft); }
.nav-link.active { color: var(--text); background: var(--blue-soft); box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.tenant-switch { position: relative; }
.tenant-switch select {
    appearance: none;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 7px 32px 7px 14px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    max-width: 220px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238fa0c2' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.tenant-switch select:hover { border-color: var(--blue); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--muted);
}
.user-chip .role {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
}
.user-chip .role.visitor { background: var(--orange-soft); color: var(--orange); }
.user-chip .role.simracer { background: rgba(225, 6, 0, 0.15); color: #ff6b5a; }

/* ---------- Layout ---------- */

.page { max-width: 1080px; margin: 0 auto; padding: 26px 20px 80px; }
.loading { color: var(--muted); text-align: center; padding: 60px 0; }

.kicker {
    color: var(--blue);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin: 0 0 4px;
}
h1 { margin: 0 0 6px; font-size: 1.55rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.08rem; font-weight: 700; }
.lede { color: var(--muted); margin: 0 0 18px; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.page-head .titles { min-width: 0; }
.back-link { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.back-link:hover { color: var(--text); }

/* ---------- Badges & présence ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
}
.badge.public { background: var(--blue-soft); color: var(--blue); }
.badge.private { background: var(--orange-soft); color: var(--orange); }

.presence {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.83rem;
    color: var(--muted);
}
.presence .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}
.presence.on .dot {
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
    animation: pulse 2.4s infinite;
}
.presence.off .dot { background: var(--amber); }
.presence .label { font-weight: 700; }
.presence.on .label { color: var(--green); }
.presence.off .label { color: var(--amber); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
    50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.08); }
}

/* ---------- Cards & grilles ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
}
a.card {
    display: block;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
a.card:hover {
    border-color: rgba(59, 130, 246, 0.5);
    background: var(--card-hover);
    transform: translateY(-2px);
}
.card h2 { margin: 0 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.card .count { color: var(--orange); font-weight: 800; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.panel > h2 { margin: 0 0 12px; }

/* ---------- Toolbars, chips, segmented ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    margin-bottom: 14px;
    scrollbar-width: thin;
}
.chip {
    flex: none;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--bg-soft);
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--blue); }
.chip.active {
    background: var(--blue-soft);
    border-color: var(--blue);
    color: var(--text);
}
.chip .n { color: var(--orange); font-weight: 800; margin-left: 5px; font-size: 0.78rem; }

.track-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
}
.track-picker-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0;
}
.track-select {
    flex: 1;
    min-width: 200px;
    max-width: 420px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
}
.track-picker-current {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
    flex: 1 1 100%;
}
.badge.live-track {
    margin-left: 8px;
    background: var(--orange-soft);
    color: var(--orange);
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    vertical-align: middle;
}

.segmented {
    display: inline-flex;
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.segmented button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    padding: 7px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.45);
}

/* ---------- Tableau de classement ---------- */

.board-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.board { width: 100%; border-collapse: collapse; }
.board th, .board td { padding: 10px 14px; text-align: left; }
.board th {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 15, 28, 0.4);
}
.board td { border-bottom: 1px solid rgba(148, 163, 216, 0.07); }
.board tbody tr:last-child td { border-bottom: 0; }
.board tbody tr { transition: background 0.12s; }
.board tbody tr:hover { background: rgba(59, 130, 246, 0.05); }
.board tbody tr.row-me { background: rgba(225, 6, 0, 0.2); }
.board tbody tr.row-me:hover { background: rgba(225, 6, 0, 0.28); }
.board td.pilot-me { font-weight: 700; }

.session-pseudo {
    font-size: 0.85rem;
    white-space: nowrap;
}

.sim-pseudo-controls {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.sim-toolbar-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sim-toolbar-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 216, 0.08);
}
.sim-toolbar-item:last-child { border-bottom: 0; padding-bottom: 0; }
.sim-toolbar-item:first-child { padding-top: 0; }

.sim-toolbar-head {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 160px;
}

.sim-toolbar-label {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.sim-toolbar-label:hover { color: var(--blue); }

.action-menu {
    position: relative;
    display: inline-block;
}
.action-menu-trigger {
    min-width: 34px;
    font-size: 1.1rem;
    line-height: 1;
    padding: 4px 10px;
}
.action-menu-list {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 30;
    min-width: 190px;
    padding: 6px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 216, 0.18);
    background: var(--panel);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.action-menu.open .action-menu-list { display: block; }
.action-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.action-menu-item:hover { background: rgba(59, 130, 246, 0.12); }
.action-menu-item.danger { color: #f87171; }
.action-menu-item.danger:hover { background: rgba(239, 68, 68, 0.12); }

.rank { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.rank.p1 { color: var(--gold); }
.rank.p2 { color: var(--silver); }
.rank.p3 { color: var(--bronze); }

.time {
    text-align: right;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.gap {
    text-align: right;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 0.86rem;
}
.pilot { font-weight: 600; }
.sim-tag { color: var(--muted); font-size: 0.85rem; }

.empty-row td { color: var(--muted); text-align: center; padding: 28px 14px; }

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}
.pagination .info { color: var(--muted); font-size: 0.84rem; }
.pagination .pages { display: flex; align-items: center; gap: 8px; }
.pagination .current { font-weight: 700; font-size: 0.88rem; font-variant-numeric: tabular-nums; }

/* ---------- Boutons ---------- */

.btn, button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover, button:hover { border-color: var(--blue); background: var(--card-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { border-color: var(--line-strong); background: var(--bg-soft); }

.btn-primary {
    background: var(--blue-strong);
    border-color: var(--blue-strong);
    color: #fff;
}
.btn-primary:hover { background: var(--blue); border-color: var(--blue); }

.btn-accent {
    background: var(--orange-strong);
    border-color: var(--orange-strong);
    color: #fff;
}
.btn-accent:hover { background: var(--orange); border-color: var(--orange); }

.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: rgba(239, 68, 68, 0.1); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; border-radius: 7px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--blue-soft); border-color: transparent; }

/* ---------- Formulaires ---------- */

.field { margin-bottom: 14px; }
label { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; }

input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
    width: 100%;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 180px; }

.check-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.check-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
.check-item:has(input:checked) {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--text);
}
.check-item input { accent-color: var(--blue); margin: 0; }

/* Switch (accès public) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch .track {
    position: absolute;
    inset: 0;
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    transition: background 0.15s, border-color 0.15s;
}
.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.18s, background 0.15s;
}
.switch input:checked + .track { background: var(--blue-strong); border-color: var(--blue-strong); }
.switch input:checked + .track::after { transform: translateX(20px); background: #fff; }

/* ---------- Bannières, toasts, modales ---------- */

.banner {
    border-radius: var(--radius-sm);
    padding: 12px 15px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid rgba(59, 130, 246, 0.4);
    background: var(--blue-soft);
    word-break: break-word;
}
.banner.error { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.1); }
.banner.info { border-color: rgba(59, 130, 246, 0.4); background: rgba(59, 130, 246, 0.08); }
.banner.success { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.08); }

.toasts {
    position: fixed;
    bottom: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
}
.toast {
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--blue);
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    font-size: 0.88rem;
    box-shadow: var(--shadow);
    animation: slide-in 0.18s ease-out;
    max-width: 360px;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

@keyframes slide-in {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 16, 0.7);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}
.modal {
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    width: 100%;
    max-width: 460px;
    max-height: 85vh;
    overflow-y: auto;
}
.modal h2 { margin: 0 0 12px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.token-box {
    font-family: var(--mono);
    font-size: 0.8rem;
    background: var(--bg-soft);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    word-break: break-all;
    margin: 10px 0;
    user-select: all;
}

/* ---------- Admin ---------- */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.92rem;
    padding: 10px 16px;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid rgba(148, 163, 216, 0.08); vertical-align: middle; }
.admin-table th { font-size: 0.7rem; font-weight: 800; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.admin-table td { font-size: 0.9rem; }
.admin-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 0.83rem; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-dot.ok::before { background: var(--green); }
.status-dot.warn::before { background: var(--amber); }
.status-dot.err::before { background: var(--red); }

.hint { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; }

/* ---------- Divers ---------- */

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.mt { margin-top: 18px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
    .topbar nav { order: 3; flex-basis: 100%; }
    .tenant-switch select { max-width: 150px; }
    h1 { font-size: 1.3rem; }
    .board th, .board td { padding: 8px 8px; }
    .gap { display: none; }
}
