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

:root {
    --blue: #2563eb;
    --blue-hover: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
}

/* ── Layout ───────────────────────────────────────────────────────── */
.layout { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 100;
}

.topbar-brand { font-weight: 700; font-size: 1.1rem; }

.topbar-nav { display: flex; gap: 1rem; align-items: center; }
.topbar-nav a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background .15s;
}
.topbar-nav a:hover { background: var(--gray-100); color: var(--gray-800); }

.main-content { max-width: 900px; margin: 2rem auto; padding: 0 1rem; width: 100%; }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 1.05rem; margin-bottom: 1rem; color: var(--gray-800); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn-primary {
    background: var(--blue);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.5rem 1.1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background .15s;
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-sm {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-radius: 5px;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background .15s;
}
.btn-sm:hover { background: var(--gray-200); }

.btn-xs {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0 0.25rem;
    font-size: 0.8rem;
}
.btn-xs:hover { color: var(--red); }

.btn-danger-sm {
    background: #fee2e2;
    color: var(--red);
    border: 1px solid #fca5a5;
    border-radius: 5px;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.btn-danger-sm:hover { background: #fecaca; }

.btn-link {
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
    color: var(--gray-600);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-decoration: none;
}
.btn-link:hover { background: var(--gray-100); }

/* ── Forms ────────────────────────────────────────────────────────── */
input, select {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
    width: 100%;
    background: white;
}
input:focus, select:focus { outline: 2px solid var(--blue); border-color: transparent; }

.form-row { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 150px; }

.form-grid { display: grid; grid-template-columns: 160px 1fr; gap: 0.6rem 1rem; align-items: center; margin-bottom: 1rem; }
.form-grid label { font-size: 0.85rem; color: var(--gray-600); }

label { display: block; font-size: 0.85rem; color: var(--gray-600); margin-bottom: 0.25rem; margin-top: 0.75rem; }
label:first-child { margin-top: 0; }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius);
    padding: 0.65rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.9rem;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: var(--red); border: 1px solid #fca5a5; }

/* ── Auth Box ─────────────────────────────────────────────────────── */
.auth-box {
    max-width: 420px;
    margin: 3rem auto;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.auth-box h1 { font-size: 1.4rem; margin-bottom: 1.25rem; }

.tabs { display: flex; gap: 0; margin-bottom: 1.25rem; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--gray-200); }
.tabs button {
    flex: 1; padding: 0.55rem; border: none; background: var(--gray-50);
    cursor: pointer; font-size: 0.9rem; color: var(--gray-600);
    transition: background .15s;
}
.tabs button.active { background: var(--blue); color: white; font-weight: 600; }

/* ── Player List (Trainer) ─────────────────────────────────────────── */
.player-list { display: flex; flex-direction: column; gap: 0.75rem; }
.player-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: var(--shadow);
}
.player-info { display: flex; align-items: center; gap: 0.75rem; }
.location-badge { font-size: 0.78rem; padding: 0.2rem 0.6rem; border-radius: 99px; }
.location-badge.set   { background: #dcfce7; color: #15803d; }
.location-badge.unset { background: var(--gray-100); color: var(--gray-600); }

.invite-section { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.invite-label { color: var(--gray-600); }
.invite-code { background: var(--gray-100); padding: 0.2rem 0.6rem; border-radius: 4px; font-family: monospace; font-size: 1rem; letter-spacing: .08em; }

.parent-list { font-size: 0.85rem; color: var(--gray-600); display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.tag { background: #dbeafe; color: #1d4ed8; padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.78rem; }

/* ── Event Cards ──────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; }

.event-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.event-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.event-header h2 { font-size: 1.1rem; margin-bottom: 0.2rem; }
.event-meta { font-size: 0.83rem; color: var(--gray-600); }

.event-type { font-weight: 600; }
.event-type.traininga { color: var(--blue); }
.event-type.trainingb { color: #7c3aed; }
.event-type.game       { color: var(--green); }

.rides-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .rides-grid { grid-template-columns: 1fr; } }

.ride-panel {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--gray-50);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.ride-panel h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }

.driver-info, .no-driver { font-size: 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; }
.assignments { font-size: 0.85rem; }
.assignment-row { display: flex; justify-content: space-between; align-items: center; padding: 0.2rem 0; }

.add-passenger { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.add-passenger select { flex: 1; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}
.modal {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    width: min(420px, 90vw);
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 0.25rem; }
.modal-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

/* ── Misc ─────────────────────────────────────────────────────────── */
.muted { color: var(--gray-400); font-size: 0.85rem; }
h1 { font-size: 1.5rem; margin-bottom: 1.25rem; }
code { font-family: monospace; }

.destination-icon { font-size: 22px; line-height: 1; }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge { font-size:.75rem; padding:.2rem .6rem; border-radius:99px; font-weight:600; white-space:nowrap; }
.badge-green  { background:#dcfce7; color:#15803d; }
.badge-orange { background:#fef3c7; color:#b45309; }
.badge-red    { background:#fee2e2; color:#dc2626; }

.tag-red { background:#fee2e2; color:#dc2626; padding:.15rem .5rem; border-radius:99px; font-size:.78rem; }

/* ── Missing players section ──────────────────────────────────────── */
.missing-section {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: var(--radius);
    padding: .6rem 1rem;
    margin-bottom: .75rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.missing-row { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; font-size: .85rem; }
.missing-label { color: var(--gray-600); font-weight: 500; }

/* ── Past events ──────────────────────────────────────────────────── */
.past-event-row {
    display: flex; align-items: center; gap: 1rem;
    padding: .5rem 0; border-bottom: 1px solid var(--gray-100);
    font-size: .85rem;
}
.past-event-row:last-child { border-bottom: none; }

/* ── Settings: location rows ──────────────────────────────────────── */
.location-row {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 0; border-bottom: 1px solid var(--gray-100);
}
.location-row:last-of-type { border-bottom: none; }

/* ── Dashboard stats table ────────────────────────────────────────── */
.stats-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.stats-table th {
    text-align: left; padding: .4rem .75rem;
    border-bottom: 2px solid var(--gray-200);
    color: var(--gray-600); font-size: .8rem; text-transform: uppercase;
}
.stats-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--gray-100); }
.stats-table tr:last-child td { border-bottom: none; }

.stat-bar { background: var(--gray-100); border-radius: 99px; height: 6px; width: 80px; }
.stat-bar-fill { background: var(--blue); border-radius: 99px; height: 100%; transition: width .3s; }

/* ── Dashboard coverage ───────────────────────────────────────────── */
.coverage-row {
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: .75rem 1rem; margin-bottom: .6rem;
}
.coverage-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.coverage-detail { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.coverage-direction { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .85rem; }
.coverage-dir-label { color: var(--gray-600); font-weight: 500; min-width: 3rem; }

/* ── Absence section ──────────────────────────────────────────────── */
.absence-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    background: #f8fafc;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .6rem 1rem;
    margin-bottom: .75rem;
    font-size: .85rem;
}
.absence-section-trainer { background: #fff7ed; border-color: #fed7aa; }
.absence-row {
    display: flex; align-items: center; gap: .5rem;
    width: 100%; padding: .2rem 0;
}
.absence-row + .absence-row { border-top: 1px solid var(--gray-100); }
