@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #0366d6;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}


.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Legacy Blazor template shell styles removed; layout is now driven by theme.css (.app-shell/.container) */

:root {
    --zdyno-primary: #3957C2;
    --zdyno-secondary: #FF8000;
    --bg: #f6f7fb;
    --panel: #ffffff;
    --panel-soft: #eef2ff;
    --text: #0f172a;
    --muted: #4b5563;
    --border: #d8def0;
    --shadow: 0 16px 50px rgba(17, 24, 39, 0.08);
    --radius: 14px;
    --radius-sm: 10px;
}

body {
    background: var(--bg);
    color: var(--text);
}

/* Event builder layout */
.create-event { display: flex; flex-direction: column; gap: 1rem; color: var(--text); }

.create-event .hero {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem 1.25rem;
    background: linear-gradient(120deg, rgba(57, 87, 194, 0.12), rgba(255, 128, 0, 0.12));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
}

.create-event .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: var(--zdyno-primary);
    margin: 0 0 0.25rem 0;
    font-weight: 700;
}

.create-event .lede { color: var(--muted); margin: 0.25rem 0 0; }
.create-event .hero h2 { margin: 0 0 0.2rem 0; color: var(--text); }
.create-event .hero-meta { display: flex; gap: 0.5rem; align-items: center; }

.create-event .pill {
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: rgba(57, 87, 194, 0.12);
    color: var(--zdyno-primary);
    border: 1px solid rgba(57, 87, 194, 0.35);
    font-size: 0.9rem;
    font-weight: 700;
}
.create-event .pill.ghost {
    background: transparent;
    border-color: rgba(15, 23, 42, 0.08);
    color: var(--muted);
}

.event-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    align-items: start;
}

.event-main { display: flex; flex-direction: column; gap: 1rem; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    color: var(--text);
}

.card header {
    font-weight: 700;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.step { position: relative; }
.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--zdyno-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.9rem;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.field.two-col { flex-direction: row; gap: 0.75rem; }
.field.two-col > div { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }

.create-event label { color: var(--muted); font-size: 0.95rem; font-weight: 600; }
.create-event .text,
.create-event select,
.create-event input[type="text"],
.create-event input[type="date"],
.create-event input[type="number"],
.create-event input[type="datetime-local"],
.class-setup input,
.race-setup input,
.simple input,
.simple select {
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.8rem;
    font-size: 0.95rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.primary,
.ghost,
.secondary,
.link,
.create-event button {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.15s ease;
}

.primary {
    background: linear-gradient(120deg, var(--zdyno-primary), var(--zdyno-secondary));
    color: #fff;
    padding: 0.65rem 1rem;
    border: none;
    box-shadow: 0 8px 18px rgba(57, 87, 194, 0.25);
}
.primary:hover { filter: brightness(1.02); }

.ghost {
    background: transparent;
    color: var(--zdyno-primary);
    border: 1px solid var(--border);
    padding: 0.65rem 1rem;
}
.ghost.active {
    background: rgba(57, 87, 194, 0.12);
    border-color: rgba(57, 87, 194, 0.35);
    color: #15316f;
}

.secondary {
    background: rgba(57, 87, 194, 0.14);
    color: var(--zdyno-primary);
    border: 1px solid rgba(57, 87, 194, 0.35);
    padding: 0.5rem 0.85rem;
}

.link { background: transparent; color: var(--zdyno-primary); padding: 0.35rem 0.5rem; border: none; }
.primary[disabled], .ghost[disabled], .secondary[disabled] { opacity: 0.45; cursor: not-allowed; }

.danger {
    background: #dc3545;
    color: #fff;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    transition: all 0.15s ease;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.25);
}
.danger:hover { filter: brightness(0.92); }
.danger[disabled] { opacity: 0.45; cursor: not-allowed; }
.wide { width: 100%; }

.subcard {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    margin-top: 0.75rem;
    background: #f8f9fe;
}
.subcard-header { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.subcard h5 { margin: 0; color: var(--text); }
.muted { color: var(--muted); margin: 0.1rem 0 0; }

.simple {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.65rem;
    color: var(--text);
}
.simple th, .simple td { border-bottom: 1px solid var(--border); padding: 0.5rem 0.35rem; }
.simple th { text-align: left; color: var(--muted); font-size: 0.9rem; font-weight: 700; }

.event-summary { position: sticky; top: 1rem; }

.summary-card {
    background: linear-gradient(180deg, #f8f9ff, #eef2ff);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    color: var(--text);
}
.summary-card h4 { margin: 0 0 0.25rem 0; }
.summary-card dl { margin: 1rem 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 0.75rem; }
.summary-card dt { color: var(--muted); font-size: 0.9rem; }
.summary-card dd { margin: 0; font-weight: 700; }

/* Member hub */
.member-shell { color: var(--text); }
.member-layout { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.member-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 0.5rem; background: var(--panel-soft); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.nav-chip { padding: 0.55rem 0.9rem; border: 1px solid transparent; border-radius: 999px; background: white; color: var(--text); cursor: pointer; transition: all 120ms ease; }
.nav-chip:hover { border-color: var(--border); box-shadow: 0 6px 18px rgba(0,0,0,0.06); }
.nav-chip.active { background: var(--zdyno-primary); color: white; border-color: var(--zdyno-primary); box-shadow: 0 8px 20px rgba(57,87,194,0.25); }
.nav-chip:disabled { opacity: 0.35; cursor: not-allowed; }
.member-content { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: 160px 1fr; gap: 0.5rem 0.75rem; align-items: center; margin-top: 0.5rem; }
.form-grid input { width: 100%; }
.form-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }
.chip-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* pill-shaped filter chips */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.85rem;
    border-radius: 999px;
    border: 1.5px solid var(--color-border, #e5e7eb);
    background: var(--color-surface, #fff);
    color: var(--color-muted, #6b7280);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
    line-height: 1.4;
    user-select: none;
}
.chip:hover {
    border-color: var(--color-primary, #3b82f6);
    color: var(--color-primary, #3b82f6);
    background: var(--color-surface, #f0f6ff);
}
.chip.selected, .chip[aria-pressed="true"] {
    background: var(--color-primary, #3b82f6);
    border-color: var(--color-primary, #3b82f6);
    color: #fff;
    font-weight: 600;
}

.filter-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.75rem; }
.filter-row.align-end { align-items: flex-end; }

.table-scroll, .drivers-table-wrapper { overflow: auto; max-height: 70vh; }
.table-sticky, .drivers-table { position: relative; }
.table-sticky thead th, .drivers-table thead th { position: sticky; top: 0; background: #f8fafc; z-index: 2; box-shadow: 0 2px 4px -2px rgba(0,0,0,0.2); }

/* ── Timeslip table ───────────────────────────────────────── */
.timeslip-table-wrapper {
    overflow: auto;
    max-height: 70vh;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    background: var(--panel);
}

.timeslip-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    color: var(--text);
    position: relative;
}

/* Dark racing header */
.timeslip-table thead tr {
    background: #0f172a;
}
.timeslip-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #0f172a;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.7rem 0.8rem;
    white-space: nowrap;
    border-bottom: 2px solid #1e293b;
    border-right: none;
    user-select: none;
    transition: color 0.12s;
}
.timeslip-table thead th[style*="cursor:pointer"]:hover,
.timeslip-table thead th[style*="cursor: pointer"]:hover { color: #e2e8f0; }

/* Alternating rows */
.timeslip-table tbody tr:nth-child(odd)  td { background: #ffffff; }
.timeslip-table tbody tr:nth-child(even) td { background: #f5f7ff; }

/* Row hover — overrides alternating */
.timeslip-table tbody tr:hover td { background: rgba(57,87,194,0.07) !important; }

/* Cells */
.timeslip-table td {
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid #eef0f8;
    vertical-align: middle;
    line-height: 1.35;
}

/* Non-finish rows */
.timeslip-table .slip-nonfinish td {
    background: #f9fafc !important;
    color: #94a3b8 !important;
}
.timeslip-table .slip-nonfinish td .muted { color: #cbd5e1; }

/* Timing number cells — monospace, right-aligned, bold */
.timeslip-table td.col-time {
    font-family: 'SF Mono', ui-monospace, 'Fira Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.93rem;
    color: #1e293b;
    text-align: right;
    white-space: nowrap;
    letter-spacing: -0.01em;
}
.timeslip-table th.col-time { text-align: right; }

/* Primary distance (best/main time) gets brand colour */
.timeslip-table td.col-time-primary {
    color: var(--zdyno-primary);
    font-size: 0.98rem;
    font-weight: 700;
}

/* Heat / small number columns */
.timeslip-table td.col-num {
    font-variant-numeric: tabular-nums;
    text-align: center;
    font-weight: 600;
    color: #334155;
}
.timeslip-table th.col-num { text-align: center; }

/* Lane pills */
.lane-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.lane-pill--left  { background: rgba(14,165,233,0.12); color: #0369a1; }
.lane-pill--right { background: rgba(249,115,22,0.12);  color: #c2410c; }

/* Last row no divider */
.timeslip-table tbody tr:last-child td { border-bottom: none; }
/* ── end timeslip table ──────────────────────────────────── */

th.drivers-actions-column, td.drivers-actions-column { width: 1%; text-align: right; white-space: nowrap; }
.drivers-actions { display: inline-flex; justify-content: flex-end; gap: 0.35rem; flex-wrap: nowrap; align-items: center; }
.drivers-actions.chip-row { display: inline-flex; flex-wrap: nowrap; }
.drivers-actions .pill { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flag-indicator { color: #b45309; font-size: 11px; margin-left: 6px; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #fbbf24; background: #fff7d1; border-radius: 999px; padding: 2px 6px; font-weight: 700; line-height: 1; }
.slip-nonfinish td { color: #6b7280; background: #f7f8fb; }
.slip-result-badge { display: inline-flex; align-items: center; gap: 4px; color: #b00020; border: 1px solid #f4c7c7; background: #fff5f5; border-radius: 999px; padding: 2px 8px; font-weight: 700; font-size: 11px; }
.slip-highlight { position: relative; }
.slip-highlight::after { content: ""; position: absolute; inset: 0; box-sizing: border-box; border: 2px solid #0ea5e9; border-radius: 6px; pointer-events: none; box-shadow: 0 0 0 2px rgba(14,165,233,0.15); }
.invalid-indicator { color: #b91c1c; margin-left: 6px; font-weight: 800; border: 1px solid #fecdd3; background: #fff1f2; border-radius: 8px; padding: 2px 6px; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.value-wrap { display: inline-flex; align-items: center; gap: 6px; }
.value-invalid { color: #b91c1c; text-decoration: line-through; font-weight: 700; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 0.75rem; margin-top: 0.5rem; }
.stacked { display: flex; flex-direction: column; gap: 1rem; }

@media (max-width: 1024px) {
    .nav-chip { flex: 1 1 46%; justify-content: center; text-align: center; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .event-grid { grid-template-columns: 1fr; }
    .event-summary { position: static; }
}

/* Class setup */
.class-setup { display: flex; flex-direction: column; gap: 0.75rem; }
.class-header { display: flex; justify-content: space-between; align-items: center; }
.class-header h4 { margin: 0; color: var(--text); }
.class-header p { margin: 0; }

.class-setup table { width: 100%; border-collapse: collapse; }
.class-setup th, .class-setup td { border-bottom: 1px solid var(--border); padding: 0.5rem 0.35rem; text-align: left; }
.class-setup th { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

/* Race setup */
.race-setup { display: flex; flex-direction: column; gap: 0.8rem; }
.race-setup .group {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    background: var(--panel-soft);
    box-shadow: var(--shadow);
}
.race-setup .group-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.race-setup h5 { margin: 0; color: var(--text); }
.race-setup .check { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; color: var(--text); }
.race-setup .check input { accent-color: var(--zdyno-primary); width: 18px; height: 18px; }
.race-setup .muted { color: var(--muted); }

/* Admin shells (racetracks/timing systems) */
.admin-shell { display: flex; flex-direction: column; gap: 1rem; color: var(--text); }
.admin-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    background: linear-gradient(120deg, rgba(57,87,194,0.12), rgba(255,128,0,0.12));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.admin-hero h2 { margin: 0; color: var(--text); }
.hero-actions { display: flex; gap: 0.5rem; }

.admin-banner {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    background: #f8f9fe;
    box-shadow: var(--shadow);
}
.admin-banner.error { border-color: #f1b5b5; background: #fff6f6; color: #a43d3d; }
.admin-banner.success { border-color: #b7e4c7; background: #f3fff7; color: #2a6f49; }

.admin-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 1024px) { .admin-grid { grid-template-columns: 1fr; } }

.admin-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow);
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.75rem; }
.card-title { margin: 0.25rem 0 0 0; color: var(--text); }
.list-head { align-items: center; }

.admin-form { display: flex; flex-direction: column; gap: 0.85rem; }
.admin-form label { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.admin-input {
    width: 100%;
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.8rem;
    font-size: 0.95rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.admin-input.textarea { min-height: 120px; font-family: inherit; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem 1rem; }
.admin-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0.75rem;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.admin-check { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; color: var(--text); }
.admin-checkbox { width: 18px; height: 18px; accent-color: var(--zdyno-primary); }

.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.table-wrap { width: 100%; overflow-x: auto; }
.admin-table { width: 100%; }
.admin-table tr.is-active { background: #f1f4ff; }
.table-actions { display: flex; gap: 0.35rem; justify-content: flex-end; }
.link.danger { color: #c0392b; }
.link.danger:hover { color: #a83227; }

.repeater { display: flex; flex-direction: column; gap: 0.65rem; }
.repeater-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.6rem;
    align-items: end;
    padding: 0.75rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #f8f9fe;
}

.detail-card { margin-top: 0.9rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.85rem; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 0.1rem 0; }
.code-grid pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid #1f2937;
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 0;
}

/* Busy overlay */
.busy-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1200;
}

.busy-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.busy-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
}

.busy-card {
    position: relative;
    background: #ffffff;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    min-width: 240px;
    text-align: center;
}

.busy-card h4 {
    margin: 0 0 0.35rem 0;
    color: var(--text);
}

.busy-card p {
    margin: 0;
    color: var(--muted);
}

.busy-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid #dfe3f5;
    border-top-color: var(--zdyno-primary);
    margin: 0 auto 0.85rem auto;
    animation: busy-spin 0.8s linear infinite;
}

@keyframes busy-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Inline suggestions for user lookup */

.suggest-pop {
    position: absolute;
    top: 0;
    left: calc(100% + 0.5rem);
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: var(--radius-sm);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    display: grid;
    min-width: 280px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 30;
    color: #f8fafc;
}

.suggest-option {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    cursor: pointer;
    color: #f8fafc;
}

.suggest-option:hover {
    background: #1f2937;
}

.suggest-vehicles {
    color: #cbd5e1;
    font-size: 0.9rem;
}

.suggest-foot {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #1f2937;
    background: #0f172a;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.email-suggest {
    position: relative;
    display: flex;
    gap: 0.35rem;
    align-items: center;
}
