/* ==========================================================
   KeyTrace — feuille de style partagée
   Direction : roadbook de rallye / feuille de pointage.
   Un seul accent (ambre) utilisé avec parcimonie ; les données
   chiffrées (km, dates, immat, ordre) sont toujours en mono.
   ========================================================== */

@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/space-grotesk-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/space-grotesk-latin-500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/space-grotesk-latin-700-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/ibm-plex-mono-latin-700-normal.woff2') format('woff2');
}

:root {
    --ink: #23262b;
    --muted: #6b6a63;
    --paper: #f6f5f1;
    --panel: #ffffff;
    --line: #ddd9d0;
    --amber: #d98e1b;
    --amber-ink: #7a4e0d;
    --amber-tint: #f6e6c9;
    --green: #2f5d46;
    --green-tint: #dde8e1;
    --brick: #b4432f;
    --brick-tint: #f3ddd7;
    --gray-tint: #e7e5df;

    --font-ui: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--amber-ink); }
a:hover { color: var(--amber); }

/* ---------- Bandeau de navigation ---------- */

.topbar {
    background: var(--ink);
    color: var(--paper);
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.topbar .brand {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 1rem;
    color: var(--paper);
    text-decoration: none;
    border: 1px solid var(--amber);
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
}

.topbar nav { display: flex; gap: 1.1rem; flex: 1; flex-wrap: wrap; }

.topbar nav a {
    color: #cfcdc4;
    text-decoration: none;
    font-size: 0.92rem;
    padding: 0.2rem 0;
    border-bottom: 2px solid transparent;
}

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

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

.topbar .who {
    font-size: 0.85rem;
    color: #a9a79f;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.topbar .who a { color: #cfcdc4; }

/* ---------- Structure de page ---------- */

.page {
    max-width: 880px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.crumb {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.crumb a { text-decoration: none; }
.crumb a::before { content: "← "; }

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 1.2rem;
}

h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 2rem 0 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 3px solid var(--amber);
    display: inline-block;
}

h3 {
    font-size: 0.98rem;
    font-weight: 700;
    margin: 0 0 0.6rem;
}

.lede { color: var(--muted); font-size: 0.92rem; margin: -0.6rem 0 1.2rem; }

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

.btn {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    padding: 0.45rem 0.9rem;
    border-radius: 3px;
    border: 1px solid var(--ink);
    color: var(--ink);
    background: transparent;
    cursor: pointer;
}

.btn:hover { background: var(--gray-tint); color: var(--ink); }

.btn-primary {
    background: var(--amber);
    border-color: var(--amber-ink);
    color: #2a1c04;
}

.btn-primary:hover { background: #c47f16; color: #2a1c04; }

.btn-danger {
    background: var(--brick-tint);
    border-color: var(--brick);
    color: var(--brick);
}

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

.btn-row { margin: 0.8rem 0 1.2rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

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

form p { margin: 0 0 1rem; }

label { font-size: 0.88rem; font-weight: 500; display: block; margin-bottom: 0.3rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--panel);
    color: var(--ink);
    width: 100%;
    max-width: 420px;
}

input[type="checkbox"] { margin-right: 0.4rem; }

fieldset {
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.9rem 1rem;
    margin: 0 0 1.2rem;
}

legend {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0 0.4rem;
    color: var(--muted);
}

.field-error {
    background: var(--brick-tint);
    color: var(--brick);
    border: 1px solid var(--brick);
    border-radius: 3px;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ---------- Tableaux (feuille de pointage) ---------- */

table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.4rem 0 1.2rem;
    font-size: 0.92rem;
}

th {
    text-align: left;
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--muted);
    padding: 0.35rem 0.6rem;
    border-bottom: 2px solid var(--ink);
}

td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

tr:last-child td { border-bottom: 1px solid var(--ink); }

.num, td.num, .mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.km-baisse { color: var(--brick); font-weight: 700; }

img.thumb { width: 60px; height: 40px; object-fit: cover; border-radius: 2px; border: 1px solid var(--line); }
img.photo { max-width: 200px; display: block; border-radius: 3px; border: 1px solid var(--line); }

.photo-checklist-row {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.photo-checklist-row .block { margin-top: 0; flex: 1 1 260px; }

/* ---------- Pastilles de statut ---------- */

.pill {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--gray-tint);
    color: var(--ink);
}

.pill-amber { background: var(--amber-tint); color: var(--amber-ink); }
.pill-green { background: var(--green-tint); color: var(--green); }
.pill-brick { background: var(--brick-tint); color: var(--brick); }

/* ---------- Blocs (tournées, sections groupées) ---------- */

.block {
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1rem 1.1rem;
    margin-top: 1rem;
    background: var(--panel);
}

.block h3 { display: flex; align-items: center; gap: 0.6rem; }
.block h3 a { font-size: 0.78rem; font-weight: 500; }

.note { color: var(--muted); font-size: 0.88rem; font-style: italic; }

/* ---------- Cartes véhicule (boucle d'essai) — pensées mobile d'abord ---------- */

.vehicule-cards { display: flex; flex-direction: column; gap: 0.7rem; margin: 1rem 0; }

.vehicule-card {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.9rem 1rem;
    background: var(--panel);
}

.vehicule-card.retire { opacity: 0.5; }

.vehicule-card .vc-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.vehicule-card .vc-vehicule { font-weight: 700; font-size: 1.05rem; }
.vehicule-card .vc-heure { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.vehicule-card .vc-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.7rem; }
.vehicule-card .vc-select { display: flex; align-items: center; gap: 0.4rem; }
.vehicule-card .vc-select input { width: 20px; height: 20px; }

/* ---------- Ajustements mobile ---------- */

@media (max-width: 640px) {
    .page { padding: 1rem 0.9rem; }

    /* Les tableaux plus complexes (listes, historiques) défilent horizontalement
       plutôt que d'écraser leur contenu illisible sur petit écran. */
    table { display: block; overflow-x: auto; white-space: nowrap; }

    .btn { padding: 0.6rem 1rem; font-size: 0.92rem; }
    .vehicule-card .vc-actions .btn { flex: 1 1 auto; text-align: center; }
}

/* ---------- Indicateurs chiffrés (tableau de bord) ---------- */

.stat-row { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1rem 0; }

.stat-card {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.9rem 1.2rem;
    background: var(--panel);
    min-width: 160px;
    flex: 1 1 200px;
}

.stat-card .stat-number {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--amber-ink, var(--ink));
    line-height: 1;
}

.stat-card .stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }


/* ---------- Page de connexion ---------- */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
}

.login-card {
    background: var(--paper);
    border-top: 4px solid var(--amber);
    padding: 2.2rem 2rem;
    width: 100%;
    max-width: 360px;
    border-radius: 4px;
}

.login-card .brand {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.04em;
    margin: 0 0 1.4rem;
}
