/* Itinéraires (wayfinding) Mapplic — voir wayfinding.js */
:root {
    --wf-route: #e03a3a;
    --wf-route-halo: rgba(224, 58, 58, 0.22);
    --wf-primary: #004aad;
    --wf-text: #0f172a;
    --wf-muted: #64748b;
    --wf-border: #e2e8f0;
    --wf-surface: #ffffff;
    --wf-soft: #f1f5f9;
}

.wf-sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* ----- Panneau ----- */
.wf-panel {
    background: var(--wf-surface);
    border-bottom: 1px solid var(--wf-border);
    padding: 14px 16px;
    color: var(--wf-text);
    font-size: 0.95rem;
}
.wf-head { margin-bottom: 10px; }
.wf-title { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.wf-title i { color: var(--wf-route); }

.wf-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.wf-field {
    flex: 1 1 260px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--wf-soft);
    border-radius: 10px;
    padding: 4px 10px;
    min-width: 0;
}
.wf-badge {
    flex: none;
    width: 24px; height: 24px;
    border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem;
    background: #e2e8f0; color: var(--wf-muted);
}
.wf-badge-b { background: var(--wf-route); color: #fff; }

.wf-input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 6px 0;
    font: inherit;
    color: inherit;
}
.wf-input:focus { outline: none; }
.wf-field:focus-within { box-shadow: 0 0 0 2px var(--wf-primary); background: var(--wf-surface); }

/* ----- Champ de recherche à suggestions ----- */
.wf-search { position: relative; }
.wf-field-clear {
    flex: none;
    border: 0; background: none;
    width: 24px; height: 24px; border-radius: 50%;
    color: var(--wf-muted); font-size: 1.1rem; line-height: 1;
    cursor: pointer;
}
.wf-field-clear:hover { background: #e2e8f0; color: var(--wf-text); }
.wf-field-clear[hidden] { display: none; }

.wf-results {
    position: absolute;
    top: calc(100% + 6px); left: 0; right: 0;
    z-index: 1000;
    margin: 0; padding: 6px;
    list-style: none;
    max-height: 320px;
    overflow-y: auto;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}
.wf-results[hidden] { display: none; }
.wf-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}
.wf-result:hover, .wf-result.wf-active { background: var(--wf-soft); }
.wf-result.wf-active { box-shadow: inset 3px 0 0 var(--wf-primary); }
.wf-result-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wf-result-title { font-weight: 600; }
.wf-result-sub {
    color: var(--wf-muted);
    font-size: 0.82rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wf-result-level {
    flex: none;
    font-size: 0.72rem; font-weight: 600;
    color: var(--wf-primary);
    background: #e8f0fb;
    border-radius: 999px;
    padding: 2px 8px;
}
.wf-no-result { padding: 10px; color: var(--wf-muted); font-size: 0.9rem; }

.wf-icon-btn {
    flex: none;
    width: 34px; height: 34px;
    border: 1px solid var(--wf-border);
    border-radius: 8px;
    background: var(--wf-surface);
    color: var(--wf-muted);
    font-size: 1rem;
    cursor: pointer;
}
.wf-icon-btn:hover { color: var(--wf-text); background: var(--wf-soft); }

.wf-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wf-btn {
    border: 1px solid var(--wf-border);
    background: var(--wf-surface);
    color: var(--wf-text);
    border-radius: 8px;
    padding: 7px 14px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.2;
}
.wf-btn:hover { background: var(--wf-soft); }
.wf-btn-primary { background: var(--wf-primary); border-color: var(--wf-primary); color: #fff; display: inline-flex; align-items: center; gap: 8px; }
.wf-btn-primary:hover { background: #003a88; }
.wf-btn:focus-visible, .wf-icon-btn:focus-visible { outline: 2px solid var(--wf-primary); outline-offset: 2px; }

.wf-status:empty, .wf-editor-status:empty { display: none; }
.wf-status, .wf-editor-status { margin-top: 8px; color: var(--wf-muted); font-size: 0.88rem; }
.wf-error { color: #b91c1c; }

/* ----- Étapes ----- */
.wf-steps:empty { display: none; }
.wf-steps { margin-top: 12px; }
.wf-steps-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: wf; }
.wf-steps-list > li { counter-increment: wf; display: flex; gap: 10px; align-items: flex-start; }
.wf-steps-list > li::before {
    content: counter(wf);
    flex: none;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--wf-soft); color: var(--wf-muted);
    font-size: 0.75rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    margin-top: 2px;
}
.wf-step {
    border: 0; background: none; padding: 0; text-align: left;
    font: inherit; color: inherit; cursor: pointer;
    display: flex; flex-direction: column; gap: 2px;
}
.wf-step:hover span:last-child { text-decoration: underline; }
.wf-step-level { font-size: 0.75rem; font-weight: 600; color: var(--wf-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.wf-step-floor { color: var(--wf-muted); font-style: italic; padding-top: 2px; }

/* ----- Tracé sur la carte ----- */
.wf-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 2;
}
.wf-route path { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.wf-route-halo { stroke: var(--wf-route-halo); stroke-width: 12; }
.wf-route-line {
    stroke: var(--wf-route);
    stroke-width: 4;
    stroke-dasharray: 9 7;
    animation: wf-dash 1s linear infinite;
}
@keyframes wf-dash { to { stroke-dashoffset: -16; } }
@media (prefers-reduced-motion: reduce) { .wf-route-line { animation: none; } }

.wf-marker {
    position: absolute;
    z-index: 3;
    width: 26px; height: 26px;
    margin: -13px 0 0 -13px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
}
.wf-marker-start { background: #fff; color: var(--wf-text); border: 3px solid var(--wf-route); }
.wf-marker-end { background: var(--wf-route); color: #fff; border: 3px solid #fff; }
.wf-marker-floor { background: var(--wf-primary); color: #fff; border: 2px solid #fff; width: 24px; height: 24px; margin: -12px 0 0 -12px; }

/* ----- Boutons dans la popup Mapplic ----- */
.wf-tooltip-actions { display: flex; gap: 8px; margin-top: 10px; }
.wf-tooltip-actions .wf-btn { padding: 5px 10px; font-size: 0.85rem; }

/* ----- Éditeur ----- */
.wf-editor { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--wf-border); }
.wf-edit-toggle.wf-active { background: #fef3c7; border-color: #f59e0b; }
.wf-editor-tools { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.wf-editor-tools[hidden], .wf-node-props[hidden] { display: none; }
.wf-help { margin: 0; color: var(--wf-muted); font-size: 0.85rem; line-height: 1.5; }
.wf-node-props { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.wf-node-props label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--wf-muted); }
.wf-node-props .wf-input { border: 1px solid var(--wf-border); border-radius: 8px; padding: 6px 10px; min-width: 220px; color: var(--wf-text); }

.wf-editing .wf-overlay { pointer-events: none; }
.wf-editing .mapplic-map-image { cursor: crosshair !important; }
.wf-edit circle, .wf-edit line { vector-effect: non-scaling-stroke; }
.wf-edge { pointer-events: stroke; cursor: pointer; }
.wf-edge-hit { stroke: transparent; stroke-width: 14; }
.wf-edge-line { stroke: #2563eb; stroke-width: 3; }
.wf-edge.wf-selected .wf-edge-line { stroke: #f59e0b; stroke-width: 4; }
.wf-node { fill: #2563eb; stroke: #fff; stroke-width: 2; pointer-events: all; cursor: move; }
.wf-node-connector { fill: #7c3aed; }
.wf-node.wf-selected { fill: #f59e0b; }
.wf-auto-connector { fill: rgba(124, 58, 237, 0.15); stroke: #7c3aed; stroke-width: 2; stroke-dasharray: 4 3; pointer-events: none; }

@media (max-width: 575px) {
    .wf-panel { padding: 12px; }
    .wf-field { flex-basis: 100%; }
    .wf-swap { margin-left: auto; }
}

/* ----- En-tête : indicateur hors ligne ----- */
.wf-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.wf-offline {
    font-size: 0.8rem; font-weight: 600;
    color: #92400e; background: #fef3c7;
    border-radius: 999px; padding: 3px 10px;
}
.wf-offline[hidden] { display: none; }

/* ----- Options : PMR et départs rapides ----- */
.wf-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 10px; }
.wf-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; cursor: pointer; margin: 0; }
.wf-check input { width: 16px; height: 16px; accent-color: var(--wf-primary); }
.wf-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.wf-quick[hidden] { display: none; }
.wf-quick-label { font-size: 0.85rem; color: var(--wf-muted); }
.wf-chip {
    border: 1px solid var(--wf-border); background: var(--wf-surface); color: var(--wf-text);
    border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.wf-chip:hover { border-color: var(--wf-primary); color: var(--wf-primary); }
.wf-chip:focus-visible { outline: 2px solid var(--wf-primary); outline-offset: 2px; }

/* ----- Fermetures temporaires ----- */
.wf-closures {
    margin-top: 10px; padding: 10px 12px;
    background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px;
    color: #9a3412; font-size: 0.88rem;
}
.wf-closures[hidden] { display: none; }
.wf-closures ul { margin: 4px 0 0; padding-left: 20px; }
.wf-closure-line { stroke: #dc2626; stroke-width: 5; stroke-dasharray: 3 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.wf-closure-node { fill: #fff; stroke: #dc2626; stroke-width: 3; vector-effect: non-scaling-stroke; }

/* ----- Résultat : résumé, actions ----- */
.wf-result-box { margin-top: 12px; }
.wf-result-box[hidden] { display: none; }
.wf-result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.wf-summary { font-weight: 600; color: var(--wf-text); }
.wf-route-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wf-route-actions .wf-btn { display: inline-flex; align-items: center; gap: 6px; }
.wf-start-guide[hidden] { display: none; }

.wf-step-details { list-style: disc; margin: 4px 0 0; padding-left: 18px; color: var(--wf-muted); font-size: 0.85rem; }
.wf-steps-list > li { flex-wrap: wrap; }
.wf-steps-list > li > .wf-step-details { flex-basis: 100%; margin-left: 32px; }
.wf-step-active .wf-step-title { color: var(--wf-primary); font-weight: 600; }
.wf-steps[hidden] { display: none; }

/* ----- Guidage pas à pas : carte flottante sur la carte ----- */
.wf-guide {
    --wf-g-accent: var(--wf-primary);
    position: absolute;
    z-index: 120;
    bottom: 18px;
    /* à droite de la barre latérale Mapplic (30 %), à gauche des boutons de zoom */
    left: calc(30% + 18px);
    right: 72px;
    max-width: 520px;
    margin: 0 auto;
    font-size: 15px;                 /* .mapplic-element impose font-size: 0 */
    line-height: 1.45;
    color: var(--wf-text);
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22), 0 2px 6px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    animation: wf-guide-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.wf-guide[hidden] { display: none; }
.mapplic-hidden-sidebar .wf-guide { left: 18px; }
@keyframes wf-guide-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }

/* progression : un segment par étape */
.wf-guide-progress { display: flex; gap: 4px; padding: 12px 18px 0; }
.wf-guide-progress span { flex: 1; height: 4px; border-radius: 999px; background: #e2e8f0; transition: background 0.3s; }
.wf-guide-progress span.wf-done { background: #93b4e4; }
.wf-guide-progress span.wf-now { background: var(--wf-g-accent); }

.wf-guide-body { padding: 12px 18px 4px; }
.wf-guide-top { display: flex; align-items: center; gap: 12px; }
.wf-guide-icon {
    flex: none;
    width: 46px; height: 46px; border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff;
    background: linear-gradient(135deg, #2563eb, var(--wf-primary));
    box-shadow: 0 6px 16px rgba(0, 74, 173, 0.3);
}
.wf-guide-icon[data-kind="elevator"], .wf-guide-icon[data-kind="stairs"] { background: linear-gradient(135deg, #8b5cf6, #6d28d9); box-shadow: 0 6px 16px rgba(109, 40, 217, 0.3); }
.wf-guide-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wf-guide-count { font-size: 12px; font-weight: 600; color: var(--wf-muted); letter-spacing: 0.02em; }
.wf-guide-level { font-size: 12px; font-weight: 700; color: var(--wf-g-accent); text-transform: uppercase; letter-spacing: 0.06em; }
.wf-guide-close {
    flex: none;
    width: 34px; height: 34px; border-radius: 50%;
    border: 0; background: #f1f5f9; color: var(--wf-muted);
    font-size: 15px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.wf-guide-close:hover { background: #e2e8f0; color: var(--wf-text); }

.wf-guide-title { font-size: 19px; font-weight: 700; line-height: 1.3; margin: 12px 0 8px; letter-spacing: -0.01em; }
.wf-guide-details { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wf-guide-details:empty { display: none; }
.wf-guide-details li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #334155; }
.wf-turn {
    flex: none;
    width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #eef4fd; color: var(--wf-g-accent); font-size: 13px;
}
.wf-turn[data-icon="arrive"] { background: #fdecec; color: #e03a3a; }
.wf-turn[data-icon="elevator"], .wf-turn[data-icon="stairs"] { background: #f3edff; color: #6d28d9; }
.wf-rot-r { transform: rotate(45deg); }
.wf-rot-l { transform: rotate(-45deg); }
.wf-guide-remaining { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--wf-muted); }
.wf-guide-remaining:empty { display: none; }
.wf-guide-content.wf-enter { animation: wf-step-in 0.28s ease-out; }
@keyframes wf-step-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

.wf-guide-nav { display: flex; align-items: center; gap: 10px; padding: 12px 18px 16px; }
.wf-round {
    flex: none;
    width: 46px; height: 46px; border-radius: 50%;
    border: 1px solid var(--wf-border); background: #fff; color: var(--wf-text);
    font-size: 16px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.wf-round:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.wf-round:active:not(:disabled), .wf-pill:active { transform: scale(0.96); }
.wf-round:disabled { opacity: 0.35; cursor: default; }
.wf-guide-voice.wf-active { background: #eef4fd; border-color: var(--wf-g-accent); color: var(--wf-g-accent); }
.wf-pill {
    flex: 1;
    height: 46px; border-radius: 999px;
    border: 0; background: var(--wf-g-accent); color: #fff;
    font-size: 15px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 8px 20px rgba(0, 74, 173, 0.28);
    transition: background 0.15s, transform 0.1s;
}
.wf-pill:hover { background: #003a88; }
.wf-pill.wf-pill-finish { background: #16a34a; box-shadow: 0 8px 20px rgba(22, 163, 74, 0.28); }
.wf-pill.wf-pill-finish:hover { background: #15803d; }

/* écran d'arrivée */
.wf-guide-done .wf-guide-icon { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 6px 16px rgba(22, 163, 74, 0.3); }
.wf-guide-done .wf-guide-level { color: #16a34a; }
.wf-guide-done .wf-guide-progress span { background: #16a34a; }

/* focus visible malgré les styles Mapplic (outline: none sur ses boutons) */
.mapplic-element .wf-guide button:focus-visible { outline: 3px solid #93b4e4 !important; outline-offset: 2px; }

@media (max-width: 767px) {
    /* feuille en bas d'écran */
    /* fixée en bas de l'écran : Mapplic empile sa liste de lieux sous la carte en mode portrait */
    .wf-guide {
        position: fixed;
        left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        max-width: none; border-radius: 18px;
        z-index: 1050;
    }
    .wf-guide-title { font-size: 17px; }
    /* la carte flottante porte les consignes : la liste du panneau repousserait la carte hors écran */
    .wf-panel-guiding .wf-steps { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .wf-guide, .wf-guide-content.wf-enter { animation: none; }
}

.wf-route.wf-dim { opacity: 0.3; }
.wf-route.wf-current .wf-route-line { stroke-width: 5; }

.wf-dot {
    position: absolute; z-index: 4;
    width: 16px; height: 16px; margin: -8px 0 0 -8px;
    border-radius: 50%; background: var(--wf-primary); border: 3px solid #fff;
    box-shadow: 0 0 0 4px rgba(0, 74, 173, 0.25), 0 2px 6px rgba(15, 23, 42, 0.3);
    pointer-events: none;
}

/* ----- « Vous êtes ici » ----- */
.wf-here {
    position: absolute; z-index: 4;
    width: 18px; height: 18px; margin: -9px 0 0 -9px;
    border-radius: 50%; background: var(--wf-primary); border: 3px solid #fff;
    box-shadow: 0 0 0 0 rgba(0, 74, 173, 0.5);
    animation: wf-pulse 2s ease-out infinite;
    pointer-events: none;
}
.wf-here span {
    position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
    white-space: nowrap; background: var(--wf-primary); color: #fff;
    font-size: 0.75rem; font-weight: 700; padding: 3px 8px; border-radius: 6px;
}
@keyframes wf-pulse { 70% { box-shadow: 0 0 0 14px rgba(0, 74, 173, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 74, 173, 0); } }
@media (prefers-reduced-motion: reduce) { .wf-here { animation: none; } }

/* ----- Éditeur : escaliers et fermetures ----- */
.wf-node-stairs { fill: #0d9488; }
.wf-node-closed { stroke: #dc2626; stroke-width: 3; }
.wf-edge-closed .wf-edge-line { stroke: #dc2626; stroke-dasharray: 4 4; }
.wf-node-props .wf-check { color: var(--wf-text); }

/* ----- Impression de l'itinéraire ----- */
.wf-print { display: none; }
@media print {
    body > *:not(.wf-print) { display: none !important; }
    .wf-print { display: block !important; color: #000; font-family: system-ui, sans-serif; }
    .wf-print h1 { font-size: 18pt; margin: 0 0 4pt; }
    .wf-print-meta { color: #444; margin: 0 0 12pt; }
    .wf-print-step { break-inside: avoid; page-break-inside: avoid; margin-bottom: 14pt; }
    .wf-print-step h2 { font-size: 12pt; margin: 0 0 4pt; }
    .wf-print-step ul { margin: 0 0 6pt; padding-left: 16pt; }
    .wf-print-map { width: 100%; max-height: 120mm; border: 1px solid #ccc; }
}

/* ----- Plein écran Mapplic : panneau en bandeau fixe au-dessus de la carte ----- */
.wf-panel-fullscreen {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 99981;               /* au-dessus de .mapplic-fullscreen (99980) */
    border-bottom: 1px solid var(--wf-border);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
}
/* carte sous le bandeau ; spécificité > .mapplic-fullscreen (height: 100% !important) */
.mapplic-element.mapplic-fullscreen.wf-fs-offset {
    top: var(--wf-fs-top, 0px) !important;
    height: calc(100% - var(--wf-fs-top, 0px)) !important;
    max-height: calc(100% - var(--wf-fs-top, 0px)) !important;
}
/* bandeau sans défilement (les suggestions débordent sur la carte) : seule la liste d'étapes défile */
.wf-panel-fullscreen .wf-steps { max-height: 18vh; overflow-y: auto; }
.wf-panel-fullscreen .wf-results { max-height: 40vh; }
