/* ============================================================================
   LogiFlotte — page Flotte (carte temps réel).
   ============================================================================ */

.map-container {
    width: 100%;
    height: 70vh;
    min-height: 420px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
    background: var(--color-surface-alt);
}

/* Leaflet s'injecte en absolute/relative ; on s'assure qu'il remplit bien */
.map-container .leaflet-container {
    width: 100%;
    height: 100%;
}

/* Légende au-dessus de la carte */
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}
.map-legend span {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}
.map-legend .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.map-legend .dot--moving  { background: var(--color-success); }
.map-legend .dot--stopped { background: var(--color-text-muted); }
.map-legend .dot--offline { background: var(--color-danger); }

/* ==================== Auto-branchement GPS ===============================
   Pages « Brancher mes GPS » et suivi véhicule. */

.setup-step .card-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.setup-step__num {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.setup-lede {
    color: var(--color-text-muted);
    margin: 0 0 var(--space-4);
    max-width: 72ch;
}

.setup-list {
    margin: 0 0 var(--space-4);
    padding-left: 1.3em;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 72ch;
}
.setup-list li::marker { color: var(--color-text-muted); font-weight: 700; }

/* Commande SMS / URL : monospace, sélectionnable d'un clic. */
.sms-cmd,
.copy-field__value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 4px 8px;
    display: inline-block;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    transition: var(--transition);
}
.sms-cmd.is-copied,
.copy-field__value.is-copied,
.code-pill.is-copied {
    background: var(--color-success-light);
    border-color: var(--color-success);
}

.copy-field {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}
.copy-field .copy-field__value { flex: 1 1 auto; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.toolbar-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

/* ==================== Marqueurs de trajet ================================
   Repères Départ / Arrivée dessinés en HTML (divIcon) : la politique de
   sécurité du site interdit les images externes, donc pas d'icône PNG. */
.map-endpoint {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transform: translate(-7px, -7px);
}
.map-endpoint__dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
    flex: 0 0 auto;
}
.map-endpoint__label {
    background: rgba(255, 255, 255, .92);
    border-radius: var(--radius);
    padding: 1px 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #111;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

/* Popup Leaflet accordée aux jetons du reste de l'interface. */
.leaflet-popup-content {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    line-height: 1.5;
}
.leaflet-popup-content a { color: var(--color-primary); font-weight: 600; }

/* ==================== Pastille véhicule ==================================
   Disque blanc cerclé de la couleur d'état, glyphe véhicule DROIT à
   l'intérieur, et un cône qui pivote autour pour donner le cap.

   Pourquoi le glyphe ne pivote pas : une voiture tournée de 270 degrés se
   retrouve sur le toit. L'icône reste lisible, seul le cône porte la
   direction — c'est la convention des outils de gestion de flotte. */

.vpin-wrap { background: none; border: none; }

.vpin {
    position: relative;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vpin__disc {
    position: relative;
    z-index: 3;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--c);
    border: 2px solid var(--c);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(17, 24, 39, .22);
    transition: transform var(--transition), box-shadow var(--transition);
}

/* Cône de cap : un triangle posé au-dessus du disque, dont le parent pivote
   autour du centre. La pointe indique la direction réelle du déplacement. */
.vpin__dir {
    position: absolute;
    inset: 0;
    z-index: 2;
    transform-origin: 50% 50%;
    transition: transform .6s cubic-bezier(.4, 0, .2, 1);
}
.vpin__dir::before {
    content: "";
    position: absolute;
    top: -3px;
    left: 50%;
    margin-left: -6px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 9px solid var(--c);
    filter: drop-shadow(0 -1px 1px rgba(17, 24, 39, .25));
}

/* Halo pulsé, réservé aux véhicules qui émettent à l'instant. */
.vpin__halo {
    position: absolute;
    inset: 5px;
    z-index: 1;
    border-radius: 50%;
    background: var(--c);
    opacity: .4;
    animation: vpinPulse 2.6s cubic-bezier(.4, 0, .6, 1) infinite;
}
@keyframes vpinPulse {
    0%   { transform: scale(.75); opacity: .45; }
    75%  { transform: scale(2.2); opacity: 0; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* Plaque : capsule sombre sous le disque, lisible sans survoler. */
.vpin__plate {
    position: absolute;
    top: 34px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    background: var(--color-text);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1.35;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(17, 24, 39, .3);
    pointer-events: none;
}

.vpin.is-moving .vpin__disc {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent),
                0 2px 8px rgba(17, 24, 39, .25);
}

.vpin.is-highlight { z-index: 900; }
.vpin.is-highlight .vpin__disc {
    transform: scale(1.22);
    box-shadow: 0 0 0 5px rgba(26, 86, 219, .28), 0 4px 12px rgba(17, 24, 39, .3);
}
.vpin.is-highlight .vpin__plate { background: var(--color-primary); }

.vpin--replay .vpin__plate { font-size: 0.6rem; padding: 1px 6px; }

@media (prefers-reduced-motion: reduce) {
    .vpin__halo { animation: none; opacity: .28; }
    .vpin__dir, .vpin__disc { transition: none; }
}

/* ==================== Carte de survol ====================================
   Une fiche, pas une infobulle : liseré d'état, plaque, vitesse en chiffre
   héros, puis le détail. Toute donnée absente disparaît — une carte pleine
   de tirets donne l'impression d'un logiciel qui ne sait rien. */

.leaflet-tooltip.veh-tip {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    white-space: normal;
}
.leaflet-tooltip.veh-tip::before { display: none; }

.leaflet-tooltip.veh-tip--mini {
    background: var(--color-text);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 5px 9px;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    line-height: 1.5;
    box-shadow: var(--shadow-md);
}

.vcard {
    position: relative;
    width: 264px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 40px -12px rgba(17, 24, 39, .32),
                0 2px 6px rgba(17, 24, 39, .08);
    overflow: hidden;
    font-family: var(--font-sans);
    color: var(--color-text);
}

/* Liseré d'état en tête : signale la fraîcheur sans consommer de place. */
.vcard__accent {
    display: block;
    height: 3px;
    background: var(--s);
}

.vcard__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 11px 14px 0;
}
.vcard__plate {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.2;
}
.vcard__state {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--s);
    white-space: nowrap;
}
.vcard__state::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--s);
}

.vcard__sub {
    margin: 3px 0 0;
    padding: 0 14px;
    font-size: 0.74rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 7px;
}
.vcard__sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--color-border-strong);
    flex: 0 0 auto;
}

/* Bandeau héros : la vitesse est la première chose qu'on regarde. */
.vcard__hero {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin: 11px 14px 0;
    padding: 9px 12px;
    border-radius: var(--radius);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
}
.vcard__hero.is-moving {
    background: var(--color-success-light);
    border-color: color-mix(in srgb, var(--color-success) 30%, transparent);
}
.vcard__speed {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
}
.vcard__unit {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-left: 4px;
    letter-spacing: 0;
}
.vcard__motion {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
}
.vcard__hero.is-moving .vcard__motion { color: #15803d; }

.vcard__grid {
    margin: 0;
    padding: 11px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.vcard__row {
    display: grid;
    grid-template-columns: 4.9rem 1fr;
    gap: var(--space-2);
    align-items: center;
}
.vcard__row dt {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-text-muted);
}
.vcard__row dd {
    margin: 0;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.vcard__row dd strong { font-weight: 650; }

.vcard__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-border-strong);
    flex: 0 0 auto;
}
.vcard__dot.is-on { background: var(--color-success); }

.vcard__batt { display: inline-flex; align-items: center; gap: 7px; }
.vcard__gauge {
    width: 38px;
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--color-border);
    overflow: hidden;
    flex: 0 0 auto;
}
.vcard__gauge i {
    display: block;
    height: 100%;
    background: var(--color-success);
    border-radius: inherit;
}
.vcard__num { font-variant-numeric: tabular-nums; font-weight: 650; }
.vcard__num small { font-weight: 500; color: var(--color-text-muted); margin-left: 1px; }

.vcard__muted { color: var(--color-text-muted); }

.vcard__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-alt);
    font-size: 0.7rem;
    font-weight: 650;
    color: var(--color-primary);
}
.vcard__arrow { transition: transform var(--transition); }
.vcard:hover .vcard__arrow { transform: translateX(3px); }

/* Variante « plusieurs véhicules ici » */
.vcard--list { width: 238px; }
.vcard__list {
    list-style: none;
    margin: 0;
    padding: 10px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 0.78rem;
}
.vcard__list li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vcard__bullet { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.vcard__li-plate { font-weight: 650; }
.vcard__list .vcard__muted {
    margin-left: auto;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 8.5rem;
}

/* ==================== Regroupement ======================================= */

.veh-cluster-wrap { background: none; border: none; }

.veh-cluster {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    border: 3px solid var(--color-surface);
    box-shadow: 0 4px 12px rgba(17, 24, 39, .3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: transform var(--transition), box-shadow var(--transition);
}
.veh-cluster:hover {
    transform: scale(1.09);
    box-shadow: 0 6px 18px rgba(17, 24, 39, .38);
}
.veh-cluster.has-live { background: var(--color-success); }
.veh-cluster__count { font-size: 0.98rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.veh-cluster__live {
    font-size: 0.46rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: .92;
    margin-top: 1px;
}

/* Ligne de tableau liée au marqueur survolé. */
.table tr[data-veh-id] { cursor: pointer; }
.table tr[data-veh-id]:hover > td,
.table tr.is-highlight > td { background: var(--color-primary-light); }

/* Pastille « en direct » près de la note d'actualisation. */
.map-refresh-note {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    margin: var(--space-2) 0 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}
.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 0 3px var(--color-success-light);
}

/* ==================== Rejeu de journée ================================== */

.replay {
    margin-top: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.replay__bar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.replay__play { min-width: 108px; gap: var(--space-2); }

.replay__slider {
    flex: 1 1 320px;
    min-width: 220px;
    position: relative;
    padding-bottom: 16px;
}
.replay__slider input[type="range"] {
    width: 100%;
    accent-color: var(--color-primary);
    cursor: pointer;
}
.replay__scale {
    position: relative;
    height: 12px;
    margin-top: 2px;
}
.replay__tick {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.62rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.replay__clock {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
    padding: 4px 10px;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    min-width: 100px;
    text-align: center;
}

.replay__speed {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
}

.replay__legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.replay__veh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    opacity: .45;
    transition: var(--transition);
}
.replay__veh.is-on { opacity: 1; border-color: var(--color-border-strong); }
.replay__veh:hover { border-color: var(--color-primary); }
.replay__veh small { font-weight: 400; color: var(--color-text-muted); }
.replay__swatch {
    width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto;
}

.veh-pin--replay .veh-pin__body { border-width: 2px; }

@media (prefers-reduced-motion: reduce) {
    .live-dot { animation: none; }
    .veh-cluster:hover { transform: none; }
}
