/* Jetons de l'interface. Les couleurs des camions (--camion-*) restent celles du mode clair :
   la carte OpenStreetMap est toujours claire, et la pastille du panneau doit être identique au tracé. */
:root {
    color-scheme: light;
    --fond: #f4f4f2;
    --surface: #fcfcfb;
    --surface-survol: #efefec;
    --bordure: #dddcd7;
    --texte: #0b0b0b;
    --texte-secondaire: #52514e;
    --texte-attenue: #77766f;
    --accent: #2a78d6;
    --critique: #d03b3b;
    --avertissement-fond: #fdf3dc;
    --camion-1: #2a78d6;
    --camion-2: #eb6834;
    --camion-3: #1baf7a;
    --rayon: 6px;
    --hauteur-barre: 52px;
    --succes: #0ca30c;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --fond: #121211;
        --surface: #1a1a19;
        --surface-survol: #262624;
        --bordure: #383835;
        --texte: #f0efec;
        --texte-secondaire: #c3c2b7;
        --texte-attenue: #9a998f;
        --accent: #3987e5;
        --avertissement-fond: #3a2f14;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --fond: #121211;
    --surface: #1a1a19;
    --surface-survol: #262624;
    --bordure: #383835;
    --texte: #f0efec;
    --texte-secondaire: #c3c2b7;
    --texte-attenue: #9a998f;
    --accent: #3987e5;
    --avertissement-fond: #3a2f14;
}

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

html, body {
    margin: 0;
    height: 100%;
    background: var(--fond);
    color: var(--texte);
}

h1:focus {
    outline: none;
}

a {
    color: var(--accent);
}

.page-simple {
    max-width: 40rem;
    margin: 3rem auto;
    padding: 0 16px;
}

/* ---------- Écrans de gestion (optimisations, aires, paramètres) ---------- */

.ecran {
    display: grid;
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 48px;
}

.ecran > header h1 {
    margin: 0;
    font-size: 22px;
}

.ecran > header p {
    margin: 4px 0 0;
    color: var(--texte-secondaire);
}

.bloc {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    background: var(--surface);
}

.bloc > h2 {
    margin: 0;
    font-size: 16px;
}

.bloc > p {
    margin: 0;
}

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

.champ {
    display: grid;
    gap: 4px;
    align-content: start;
    color: var(--texte-secondaire);
    font-size: 13px;
}

.champ > span:first-child {
    font-weight: 600;
    color: var(--texte);
}

.champ small {
    color: var(--texte-attenue);
    font-size: 12px;
}

.unite {
    display: flex;
    align-items: center;
    gap: 6px;
}

.unite input {
    flex: 1;
    min-width: 0;
}

.unite > span {
    color: var(--texte-attenue);
    white-space: nowrap;
}

input[type="text"], input[type="tel"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], select, textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    background: var(--surface);
    color: var(--texte);
    font: inherit;
    font-size: 14px;
}

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

input[aria-invalid="true"] {
    border-color: var(--critique);
}

.case {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    color: var(--texte);
    cursor: pointer;
}

.case input {
    margin-top: 3px;
}

.erreur-champ {
    color: var(--critique);
    font-size: 12px;
    font-weight: 600;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.bouton {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    background: var(--surface);
    color: var(--texte);
    font: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.bouton:hover {
    background: var(--surface-survol);
}

.bouton.principal {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.bouton.principal:hover {
    filter: brightness(1.08);
}

.bouton.danger {
    color: var(--critique);
}

.bouton.petit {
    padding: 3px 9px;
    font-size: 13px;
}

.bouton:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.message {
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--rayon);
    font-size: 14px;
}

.message.erreur {
    border-left: 3px solid var(--critique);
    background: var(--avertissement-fond);
}

.message.succes {
    border-left: 3px solid var(--succes);
    background: var(--surface-survol);
}

.message.info {
    border-left: 3px solid var(--accent);
    background: var(--surface-survol);
}

.message ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.tableau {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tableau th {
    color: var(--texte-attenue);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
}

.tableau th, .tableau td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--bordure);
    vertical-align: middle;
}

.tableau td.nombre, .tableau th.nombre {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tableau tr.choisie td {
    background: var(--surface-survol);
}

.defilement {
    overflow-x: auto;
}

/* Statut : toujours un libellé, la couleur n'est qu'un complément. */
.statut {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
}

.statut::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--texte-attenue);
}

.statut.Terminee::before {
    background: var(--succes);
}

.statut.EnCours::before {
    background: var(--accent);
    animation: pulsation 1.2s ease-in-out infinite;
}

.statut.Echec::before {
    background: var(--critique);
}

@keyframes pulsation {
    50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
    .statut.EnCours::before {
        animation: none;
    }
}

.attenue {
    color: var(--texte-secondaire);
    font-size: 13px;
}

/* Masqué à l'écran, lu par les lecteurs d'écran (global : sert aussi aux composants comme InputFile). */
.visuellement-cache {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Chauffeurs : avatars, photos de camion, validité des documents ---------- */

.avatar {
    flex: none;
    width: var(--taille);
    height: var(--taille);
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c);
    background: var(--surface-survol);
}

.avatar.initiales {
    display: inline-grid;
    place-items: center;
    color: var(--texte-secondaire);
    font-size: calc(var(--taille) * 0.38);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.photo-camion {
    flex: none;
    border-radius: var(--rayon);
    object-fit: cover;
    background: var(--surface-survol);
}

.photo-camion.vide {
    display: grid;
    place-items: center;
    color: var(--texte-attenue);
    font-size: 12px;
    border: 1px dashed var(--bordure);
}

.document {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.document::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--texte-attenue);
}

.document.Valide::before { background: var(--succes); }
.document.ExpireBientot::before { background: #fab219; }
.document.Expire::before { background: var(--critique); }

.document-nom {
    font-weight: 600;
}

.document.Expire .document-etat {
    color: var(--critique);
    font-weight: 600;
}

.plaque {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--texte-secondaire);
    border-radius: 3px;
    background: var(--surface);
    font: 600 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* Marqueurs Leaflet (créés par wwwroot/js/carte.js, hors de la portée CSS des composants). */
.marqueur {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 2px solid var(--c);
    border-radius: 50%;
    background: var(--c);
    color: #fff;
    font: 600 11px/1 system-ui, sans-serif;
    box-shadow: 0 0 0 2px #fff;
}

/* Enlèvement : carré creux, pour ne pas dépendre de la couleur seule. */
.marqueur.enlevement {
    border-radius: 3px;
    background: #fff;
    color: #0b0b0b;
}

.marqueur.retard {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #d03b3b;
}

.marqueur.depot {
    width: 26px;
    height: 26px;
    border-color: #0b0b0b;
    border-radius: 4px;
    background: #0b0b0b;
}

.marqueur.repos {
    width: 18px;
    height: 18px;
    border-color: #52514e;
    border-radius: 3px;
    background: #52514e;
    font-size: 10px;
}

.marqueur.aire.choisie {
    width: 22px;
    height: 22px;
    border: 2px solid #2a78d6;
    color: #2a78d6;
    font-size: 11px;
    box-shadow: 0 0 0 2px #fff;
}

.marqueur.nouvelle {
    width: 22px;
    height: 22px;
    border-color: #2a78d6;
    border-radius: 3px;
    background: #2a78d6;
}

/* Sous-traitance : carré à bordure pointillée, distinct des arrêts de la flotte. */
.marqueur.sous-traitance {
    width: 22px;
    height: 22px;
    border: 2px dashed #52514e;
    border-radius: 3px;
    background: #fff;
    color: #52514e;
    font-size: 9px;
    box-shadow: none;
}

.marqueur.aire {
    width: 16px;
    height: 16px;
    border: 1px solid #77766f;
    border-radius: 3px;
    background: #fff;
    color: #52514e;
    font-size: 9px;
    box-shadow: none;
}

.leaflet-popup-content {
    font: 13px/1.45 system-ui, sans-serif;
}

.leaflet-popup-content strong {
    display: block;
    margin-bottom: 2px;
}

.leaflet-popup-content .retard {
    color: #d03b3b;
    font-weight: 600;
}

@media print {
    .barre, #blazor-error-ui, #components-reconnect-modal {
        display: none !important;
    }

    body, .bloc {
        background: #fff;
    }
}

#blazor-error-ui {
    color-scheme: light only;
    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;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "Une erreur s'est produite.";
}
