/* ── Reset & base ───────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body { margin: 0; padding: 0; font-family: 'Helvetica Neue', Arial, sans-serif; overflow: hidden; background: #e8e8e8; }

/* Carte plein écran */
#map { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 0; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
    position: fixed;
    top: 0;
    left: 18px;
    bottom: 0;
    width: 290px;
    overflow-y: auto;
    overflow-x: hidden;

    /* Force un layer GPU indépendant du canvas WebGL MapLibre */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    isolation: isolate;
    z-index: 9999;

    background: rgba(248, 248, 246, 0.52);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0,0,0,0.10);
    box-shadow: 3px 0 32px rgba(0,0,0,0.15);
    color: #1c2333;

    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.12) transparent;
}
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.14); }

/* ── En-tête sticky ──────────────────────────────────────────────────────── */
#sidebar-header {
    position: sticky;
    top: 0;
    background: rgba(248, 248, 246, 0.65);
    padding: 16px 18px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    z-index: 10;
}

/* ── Identité ────────────────────────────────────────────────────────────── */
#brand { margin-bottom: 16px; }

#app-name {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.28em;
    color: #0d1117;
    line-height: 1;
}

#app-tagline {
    font-size: 8.5px;
    letter-spacing: 0.22em;
    color: rgba(0,0,0,0.36);
    text-transform: uppercase;
    margin-top: 3px;
    font-weight: 400;
}

/* ── Navigation I / II / III ─────────────────────────────────────────────── */
#step-nav {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.step-div {
    width: 1px;
    height: 22px;
    background: rgba(0,0,0,0.10);
    margin-bottom: 14px; /* aligns with button mid */
}

/* Override absolu du rule `button { width:100% }` */
#step-nav .step-btn,
#step-nav .step-btn:hover,
#step-nav .step-btn:focus {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    border: 1.5px solid rgba(0,0,0,0.18) !important;
    background: transparent !important;
    color: rgba(0,0,0,0.28) !important;
    font-size: 10.5px;
    font-weight: 700;
    font-family: Georgia, 'Times New Roman', serif;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    box-shadow: none !important;
    outline: none !important;
}
#step-nav .step-btn.active {
    border-color: #0d1117 !important;
    color: #0d1117 !important;
    background: rgba(0,0,0,0.06) !important;
}
#step-nav .step-btn:hover:not(.active) {
    border-color: rgba(0,0,0,0.45) !important;
    color: rgba(0,0,0,0.55) !important;
}

.step-lbl {
    font-size: 7.5px;
    letter-spacing: 0.14em;
    color: rgba(0,0,0,0.28);
    font-weight: 600;
    text-transform: uppercase;
}
.step-item:has(.active) .step-lbl { color: #0d1117; }

/* ── Panneaux ────────────────────────────────────────────────────────────── */
.step-panel          { display: none !important; padding: 16px 18px 8px; }
.step-panel.active   { display: block !important; }

/* ── Composants ──────────────────────────────────────────────────────────── */
#surface-monitor {
    background: transparent;
    color: #1c2333;
    padding: 8px 0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-align: left;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

/* ── Recherche adresse ───────────────────────────────────────────────────── */
#address-search {
    position: relative;
    margin-bottom: 12px;
}

#search-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 11px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-weight: 400;
    letter-spacing: 0.03em;
    color: #1c2333;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(0,0,0,0.14);
    border-radius: 0;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}
#search-input:focus {
    border-color: rgba(0,0,0,0.35);
    background: rgba(255,255,255,0.85);
}
#search-input::placeholder {
    color: rgba(0,0,0,0.28);
    font-style: italic;
}

#search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    background: rgba(248,248,246,0.97);
    border: 1px solid rgba(0,0,0,0.12);
    border-top: none;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}
#search-suggestions:empty { display: none; }

#search-suggestions li {
    padding: 7px 10px;
    font-size: 10.5px;
    color: #1c2333;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    line-height: 1.35;
}
#search-suggestions li:last-child { border-bottom: none; }
#search-suggestions li:hover { background: rgba(0,0,0,0.05); }

/* ── Infos parcelle groupées ─────────────────────────────────────────────── */
#parcel-info {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}


.info-group-lbl {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: rgba(0,0,0,0.35);
    text-transform: uppercase;
    margin-bottom: 3px;
}

.info-val-line {
    font-size: 10px;
    color: #1c2333;
    font-weight: 400;
    padding: 1px 0 1px 8px;
    border-left: 1.5px solid rgba(0,0,0,0.10);
    word-break: break-word;
    line-height: 1.4;
}

.info-val-line::before {
    content: attr(data-idx) "  ";
    font-size: 8px;
    color: rgba(0,0,0,0.28);
    font-weight: 600;
}

.info-val-ref {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
/* le span ref prend tout l'espace disponible → aire poussée à droite */
.info-val-ref > span:first-child {
    flex: 1;
}

.ref-aire {
    font-size: 9px;
    color: rgba(0,0,0,0.4);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Ligne espace libre (RÉNO) — atténuée, italique */
.reno-free {
    opacity: 0.5;
    font-style: italic;
}
.reno-free-pct {
    font-style: normal;
}

/* Slider boxes — ligne fine colorée à gauche, sans fond */
.slider-box {
    background: transparent;
    padding: 9px 0 9px 12px;
    border-radius: 0;
    margin-bottom: 6px;
    border-left: 2px solid #ccc; /* overridden via JS via data-color → CSS var */
}
/* Couleurs des bords via attribut data-color — set inline dans les éléments */
.slider-box[data-color="#c8a800"] { border-left-color: #c8a800; }
.slider-box[data-color="#c0392b"] { border-left-color: #c0392b; }
.slider-box[data-color="#27ae60"] { border-left-color: #27ae60; }
.slider-box[data-color="#e67e22"] { border-left-color: #e67e22; }
.slider-box[data-color="#2980b9"] { border-left-color: #2980b9; }

.sub-group {
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-top: 8px;
    padding-top: 7px;
}

label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #1c2333;
    text-transform: uppercase;
    gap: 6px;
}
/* Valeur numérique dans le label */
label span[id^="v-"] {
    font-weight: 400;
    color: #555;
    letter-spacing: 0;
    min-width: 24px;
    text-align: right;
}

.toggle-off {
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 400;
    font-size: 9px;
    color: rgba(0,0,0,0.35);
    text-transform: none;
    letter-spacing: 0;
    flex-shrink: 0;
}

/* ── Sliders custom (piste fine → épaisse) ───────────────────────────────── */
.range-wrap {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    margin-top: 6px;
    width: 100%;
}

/* Input natif invisible — conserve l'interaction native (drag, keyboard, touch) */
.range-wrap input[type=range] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    z-index: 2;
}

/* Piste fine (toute la largeur) */
.range-track {
    position: absolute;
    left: 0; right: 0;
    height: 1px;
    background: rgba(0,0,0,0.13);
    pointer-events: none;
}

/* Remplissage épais (partie gauche du curseur) */
.range-fill {
    position: absolute;
    left: 0;
    height: 3px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    border-radius: 1px;
    min-width: 0;
}

/* Poignée ronde */
.range-thumb {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* Boutons généraux */
button {
    width: 100%;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 0;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    margin-top: 6px;
    border: none;
    background: #1c2333;
    color: #fff;
    transition: background 0.15s;
}
button:hover { background: #2c3e50; }
button:disabled { background: rgba(0,0,0,0.12); color: rgba(0,0,0,0.3); cursor: default; }

/* ── Toggle 2D/3D dans panel II ─────────────────────────────────────────── */
#view-toggle-row,
#projet-toggle-row {
    display: flex;
    gap: 0;
    margin-bottom: 10px;
    border: 1px solid rgba(0,0,0,0.15);
}

.view-toggle-btn {
    flex: 1;
    padding: 5px 0 !important;
    margin: 0 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.12em !important;
    width: auto !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: rgba(0,0,0,0.35) !important;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.view-toggle-btn:hover {
    background: rgba(0,0,0,0.05) !important;
    color: #1c2333 !important;
}
.view-toggle-btn.active {
    background: #1c2333 !important;
    color: #fff !important;
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(0,0,0,0.18);
    color: rgba(0,0,0,0.5);
}
.btn-secondary:hover {
    background: rgba(0,0,0,0.05);
    color: #1c2333;
}

.hint {
    font-size: 9.5px;
    color: rgba(0,0,0,0.35);
    font-style: italic;
    text-align: left;
    margin-bottom: 12px;
    line-height: 1.6;
    letter-spacing: 0.03em;
}
.hint-plu {
    font-size: 15px;
    font-weight: 700;
    font-style: normal;
    color: #1c2333;
    margin-bottom: 10px;
    letter-spacing: 0.08em;
    text-align: center;
}

/* ── HUD Nord — haut droite ──────────────────────────────────────────────── */
#hud-nord {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9000;
    pointer-events: auto;
    cursor: pointer;
}
#hud-nord svg {
    width: 70px;
    height: 95px;
    display: block;
}
.hud-n {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 22px;
    font-weight: 900;
    fill: #1c2333;
    text-anchor: middle;
    dominant-baseline: auto;
    letter-spacing: 0.10em;
}

/* ── HUD Échelle — barre gauche + numéro droite, même ligne, bas écran ───── */
#hud-scale {
    position: fixed;
    bottom: 24px;
    left: 336px;   /* après sidebar */
    right: 24px;
    z-index: 9000;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    pointer-events: none;
    gap: 16px;
}

#hud-scale-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
}

#hud-scale-line {
    height: 7px;
    min-width: 200px;
    box-sizing: border-box;
    border: 1.5px solid #1c2333;
    background: repeating-linear-gradient(
        to right,
        #1c2333 0%, #1c2333 50%,
        #fff    50%, #fff    100%
    );
}

#hud-scale-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-weight: 600;
    color: #1c2333;
    letter-spacing: 0.04em;
}

#hud-scale-num {
    font-size: 15px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-weight: 700;
    color: #1c2333;
    letter-spacing: 0.04em;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Résultat calculé sous un slider ────────────────────────────────────── */
.slider-result {
    font-size: 9.5px;
    color: rgba(0,0,0,0.45);
    margin-top: 4px;
    letter-spacing: 0.04em;
    min-height: 12px;
}

/* ── Légende espaces inconstructibles (sidebar) ──────────────────────────── */
#inconstructible-legend {
    display: none;
    align-items: center;
    gap: 10px;
    margin: 4px 0 6px;
    flex-wrap: wrap;
}
.inc-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.inc-lbl {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1c2333;
    margin-right: 6px;
}

/* ── Toggle couche zones PLU — intégré dans panel I ─────────────────────── */
#plu-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
    padding: 9px 14px;
    background: #ffffff;
    border: 1.5px solid #1c2333;
    border-radius: 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #1c2333;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s, transform 0.08s;
}
#plu-toggle:hover { background: #f3f3f3; }
#plu-toggle:active { transform: translateY(1px); }
#plu-toggle.active {
    background: #1c2333;
    color: #ffffff;
}
#plu-toggle.active svg rect { stroke: #ffffff; }

/* ── Légende couche PLU ──────────────────────────────────────────────────── */
#plu-legend {
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #1c2333;
    border-radius: 6px;
    padding: 10px 12px 8px 12px;
    font-family: inherit;
    font-size: 11px;
    color: #1c2333;
}
#plu-legend[hidden] { display: none; }
.plu-legend-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    margin-bottom: 6px;
    color: #1c2333;
}
.plu-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    font-weight: 500;
}
.plu-dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #1c2333;
    display: inline-block;
}
.plu-legend-sub {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e0e0e0;
    font-size: 9px;
    color: #888;
    letter-spacing: 0.04em;
}

/* ── Tooltip zones PLU au survol ─────────────────────────────────────────── */
.maplibregl-popup.plu-popup .maplibregl-popup-content {
    background: #1c2333;
    color: #ffffff;
    border-radius: 4px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 11px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    line-height: 1.35;
}
.maplibregl-popup.plu-popup .maplibregl-popup-tip {
    border-top-color: #1c2333;
    border-bottom-color: #1c2333;
}
.plu-popup-libelle {
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.03em;
}
.plu-popup-code {
    margin-top: 2px;
    font-family: 'Courier New', monospace;
    color: #f1c40f;
    letter-spacing: 0.06em;
}
.plu-popup-sub {
    margin-top: 3px;
    color: #b0b8c5;
    font-size: 10px;
}
