/* Explorateur loyers - layout carte + panneau, style ActusDocs sombre */
.explorer {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid #1e293b;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    color: #e2e8f0;
    box-sizing: border-box;
}

@media (max-width: 959px) {
    .explorer {
        overflow-x: hidden;
        overflow-y: visible;
        max-width: 100%;
    }
}

.explorer-topbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #334155;
    background: rgba(17, 24, 39, 0.55);
}

.explorer-topbar-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    width: 100%;
}

.explorer-legend-bar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid #334155;
    overflow: hidden;
}
.explorer-legend-bar--map {
    display: none;
}
@media (min-width: 960px) {
    .explorer-legend-bar--topbar { display: none; }
    .explorer-legend-bar--map {
        display: block;
        position: absolute;
        bottom: 12px;
        left: 12px;
        z-index: 11;
        width: min(280px, calc(100% - 24px));
        max-width: 280px;
        background: rgba(15, 23, 42, 0.88);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
        pointer-events: none;
    }
    .explorer-legend-bar--map .explorer-legend-scale,
    .explorer-legend-bar--map .explorer-legend-label {
        pointer-events: auto;
    }
}
.explorer-legend-label {
    display: block;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #c4b5fd;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.explorer-legend-scale { width: 100%; min-width: 0; }
.explorer-legend-scale .legend-gradient {
    height: 10px;
    margin: 0 0 4px;
    width: 100%;
}
.explorer-legend-scale .legend-gradient-labels {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-size: 10px;
    min-width: 0;
}
.explorer-legend-scale .legend-gradient-labels span {
    min-width: 0;
    white-space: nowrap;
}
.explorer-legend-scale .legend-gradient-labels span:last-child {
    text-align: right;
}

@media (min-width: 960px) {
    .explorer-topbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .explorer-topbar-main { flex: 1 1 100%; }
}

.explorer-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 280px;
    justify-content: center;
}

.filter-chip {
    border: 1px solid #334155;
    background: rgba(17, 24, 39, 0.85);
    color: #cbd5e1;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.filter-chip:hover { border-color: #a78bfa; color: #fff; }
.filter-chip.is-active {
    background: rgba(139, 92, 246, 0.22);
    border-color: #a78bfa;
    color: #fff;
}

.explorer-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.explorer-actions .btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #334155;
    background: rgba(17, 24, 39, 0.85);
    color: #cbd5e1;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.explorer-actions .btn-action:hover { border-color: #a78bfa; color: #fff; }

.explorer-body {
    display: grid;
    grid-template-columns: 1fr;
    min-height: min(72vh, 620px);
}
@media (min-width: 960px) {
    .explorer-body { grid-template-columns: 1fr; min-height: 0; }
}

.explorer-map-col {
    position: relative;
    background: #0b0f19;
    border-bottom: 1px solid #334155;
}

.explorer-map-block {
    position: relative;
    width: 100%;
}

.map-wrap-explorer {
    position: absolute;
    inset: 0;
    border-radius: 0;
}

@media (max-width: 959px) {
    .explorer-map-col {
        position: relative;
        display: block;
        height: min(58vh, 480px);
        min-height: 300px;
        flex-shrink: 0;
        overflow: hidden;
        border-bottom: 1px solid #334155;
    }
    .explorer-map-block {
        position: absolute;
        inset: 0;
        height: 100%;
        min-height: 0;
    }
    .map-search-float {
        position: absolute;
        top: 8px;
        left: 8px;
        right: 8px;
        z-index: 12;
        max-width: none;
    }
}

@media (min-width: 960px) {
    .explorer-map-col {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        border-bottom: 0;
    }
    .explorer-map-block {
        position: relative;
        flex: 0 0 auto;
        height: min(52vh, 520px);
        min-height: 420px;
    }
    .map-wrap-explorer {
        position: absolute;
        inset: 0;
    }
}

#loyers-map { width: 100%; height: 100%; background: #0b0f19; }

.map-search-float {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 12;
    max-width: 380px;
}
@media (min-width: 960px) { .map-search-float { right: auto; width: 320px; } }

.map-search-float .commune-search-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 12px 10px 36px;
    font-size: 14px;
    color: #e2e8f0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.map-search-float .commune-search-input::placeholder { color: #64748b; }
.map-search-float .commune-search-input:focus {
    outline: none;
    border-color: #a78bfa;
}
.map-search-wrap { position: relative; }
.map-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
.commune-search-results {
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.commune-search-results[hidden] { display: none; }
.commune-search-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid #1e293b;
    background: transparent;
    color: #e2e8f0;
    padding: 10px 12px;
    cursor: pointer;
}
.commune-search-item:last-child { border-bottom: 0; }
.commune-search-item:hover,
.commune-search-item:focus { background: #1e293b; outline: none; }
.commune-search-item strong { display: block; font-size: 14px; margin-bottom: 2px; }
.commune-search-item span { font-size: 12px; color: #94a3b8; }
.commune-search-empty { padding: 12px; font-size: 13px; color: #94a3b8; }

.legend-gradient {
    height: 10px;
    border-radius: 4px;
    margin: 6px 0 4px;
    background: linear-gradient(90deg, #22c55e, #86efac, #eab308, #f97316, #ef4444, #dc2626, #991b1b);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.legend-gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #94a3b8;
}

.loyers-map-hint {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 24px;
    pointer-events: none;
    background: rgba(11, 15, 25, 0.48);
    color: rgba(255, 255, 255, 0.95);
    text-align: center;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.loyers-map-hint__text {
    margin: 0;
    max-width: 26em;
    font-size: 14px;
    line-height: 1.55;
    font-weight: 500;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}
.loyers-map-hint.is-hidden { opacity: 0; visibility: hidden; }

.map-loading {
    position: absolute;
    inset: 0;
    z-index: 9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(11, 15, 25, 0.82);
    color: #e2e8f0;
    font-size: 14px;
}
.map-loading.hidden { display: none; }
.map-loading i { font-size: 28px; color: #a78bfa; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.explorer-sidebar {
    background: rgba(17, 24, 39, 0.75);
    display: flex;
    flex-direction: column;
    max-height: none;
    border-top: 1px solid #334155;
}
@media (min-width: 960px) {
    .explorer-sidebar {
        border-left: 0;
        border-top: 1px solid #334155;
        max-height: none;
    }
    .explorer-map-block {
        height: min(62vh, 560px);
        min-height: 380px;
    }
    .sidebar-kpis {
        grid-template-columns: repeat(4, 1fr);
    }
    .sidebar-scroll {
        max-height: 320px;
    }
}

.sidebar-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #334155;
    border-bottom: 1px solid #334155;
}
.sidebar-kpi {
    background: rgba(15, 23, 42, 0.85);
    padding: 12px 14px;
}
.sidebar-kpi strong {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: #c4b5fd;
    line-height: 1.2;
}
.sidebar-kpi span {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
    line-height: 1.35;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid #334155;
}
.sidebar-tab {
    flex: 1;
    border: 0;
    background: rgba(15, 23, 42, 0.55);
    color: #94a3b8;
    padding: 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.sidebar-tab:hover { color: #e2e8f0; }
.sidebar-tab.is-active {
    background: rgba(17, 24, 39, 0.75);
    color: #c4b5fd;
    border-bottom-color: #a78bfa;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px 18px;
}

.sidebar-panel[hidden] { display: none; }

.sidebar-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.sidebar-sub {
    margin: 0 0 12px;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.45;
}

.sidebar-price {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 8px;
    line-height: 1.1;
}
.sidebar-price-label {
    margin: 0 0 2px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #a78bfa;
}

.sidebar-meta {
    margin: 0 0 8px;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.5;
}
.sidebar-meta strong { color: #cbd5e1; }

.sidebar-types {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}
.sidebar-type-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 8px;
    font-size: 13px;
    background: rgba(15, 23, 42, 0.55);
}
.sidebar-type-row.is-active {
    border-color: #a78bfa;
    background: rgba(139, 92, 246, 0.12);
}
.sidebar-type-row span:first-child { color: #94a3b8; font-size: 11px; }
.sidebar-type-row .sidebar-type-val { text-align: right; }
.sidebar-type-row .sidebar-type-val strong { display: block; color: #f8fafc; white-space: nowrap; }
.sidebar-type-row .sidebar-type-val small { display: block; font-size: 10px; color: #64748b; margin-top: 2px; }

.rank-list-light {
    list-style: none;
    margin: 0;
    padding: 0;
}
.rank-list-light li {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #1e293b;
    font-size: 13px;
    color: #e2e8f0;
}
.rank-list-light li:last-child { border-bottom: 0; }
.rank-list-light .rank-name { flex: 1; min-width: 0; }
.rank-list-light .rank-dept { color: #64748b; font-size: 11px; }
.rank-list-light .rank-val { font-weight: 700; color: #c4b5fd; white-space: nowrap; }

.sidebar-note {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(167, 139, 250, 0.25);
    border-radius: 8px;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
}
.sidebar-note strong { color: #c4b5fd; }

.sidebar-facts {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
}
.sidebar-facts li {
    padding: 6px 0;
    border-bottom: 1px solid #1e293b;
    font-size: 12px;
    color: #cbd5e1;
}
.sidebar-facts li:last-child { border-bottom: 0; }

.rank-pct {
    display: block;
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    margin-top: 2px;
}

.sidebar-type-row small {
    display: block;
    font-size: 10px;
    color: #64748b;
    margin-top: 2px;
}

.loyers-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
}
.loyers-badge--ok { background: rgba(34, 197, 94, 0.15); color: #4ade80; border-color: rgba(34, 197, 94, 0.35); }
.loyers-badge--warn { background: rgba(234, 179, 8, 0.15); color: #facc15; border-color: rgba(234, 179, 8, 0.35); }
.loyers-badge--epci { background: rgba(249, 115, 22, 0.15); color: #fb923c; border-color: rgba(249, 115, 22, 0.35); }

.loyers-chart-block {
    padding: 10px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid #334155;
    border-radius: 10px;
}
.loyers-chart-title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
}
.loyers-chart-caption {
    margin: -4px 0 8px;
    font-size: 11px;
    color: #64748b;
    line-height: 1.45;
}
.loyers-chart {
    min-height: 180px;
}
.loyers-chart .apexcharts-canvas { margin: 0 auto; }

.loyers-stats-panel {
    display: block;
    padding: 12px 14px 14px;
    background: rgba(15, 23, 42, 0.55);
    border-top: 1px solid #334155;
}
.loyers-stats-intro {
    margin: 0 0 12px;
    font-size: 12px;
    color: #94a3b8;
}
.loyers-stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.accueil-tool-seo-article .loyers-stats-panel {
    margin: 8px 0 28px;
    padding: 0;
    background: transparent;
    border: 0;
}
.accueil-tool-seo-article .loyers-stats-intro {
    margin: 0 0 14px;
}
.accueil-tool-seo-article .loyers-stats-grid {
    margin: 0 0 8px;
}
.accueil-tool-seo-article .loyers-chart-block {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 14px;
}
.accueil-tool-seo-article .loyers-stats-panel > h3,
.accueil-tool-seo-article .loyers-stats-panel > p {
    margin-top: 28px;
}
@media (min-width: 900px) {
    .accueil-tool-seo-article .loyers-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}
@media (max-width: 959px) {
    .sidebar-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sidebar-tabs::-webkit-scrollbar { display: none; }
    .sidebar-tab {
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 6px;
        font-size: 11px;
        white-space: nowrap;
    }
}
@media (min-width: 960px) {
    .loyers-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.maplibregl-popup-content {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.maplibregl-popup-close-button { color: #94a3b8; font-size: 18px; }
.loyers-popup { padding: 12px 14px; font-size: 13px; }
.loyers-popup h3 { margin: 0 0 6px; font-size: 15px; color: #f8fafc; }
.loyers-popup-price { margin: 6px 0; font-size: 18px; font-weight: 800; }
.loyers-popup-meta { margin: 0; color: #94a3b8; font-size: 12px; }

.map-error {
    margin: 8px 14px 14px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    display: none;
    text-align: center;
}
.map-error.visible { display: block; }

/* Mobile : infos sous la carte, légende dans la barre du haut */
@media (max-width: 959px) {
    .explorer-topbar {
        padding: 10px;
        gap: 8px;
    }

    .explorer-topbar-main {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .explorer-filters {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .explorer-filters::-webkit-scrollbar { display: none; }

    .filter-chip {
        flex-shrink: 0;
        padding: 6px 12px;
        font-size: 11px;
    }

    .explorer-actions {
        flex-shrink: 0;
        margin-left: 0;
    }
    .explorer-actions .btn-action { padding: 7px 9px; }

    .map-search-float .commune-search-input {
        padding: 8px 10px 8px 34px;
        font-size: 13px;
    }

    .loyers-map-hint { padding: 16px; }
    .loyers-map-hint__text { font-size: 13px; max-width: 20em; }

    .explorer-legend-bar {
        padding: 8px 10px;
    }
    .explorer-legend-label {
        font-size: 10px;
        margin-bottom: 6px;
        letter-spacing: 0.04em;
    }
    .explorer-legend-scale .legend-gradient {
        height: 10px;
    }
    .explorer-legend-scale .legend-gradient-labels {
        font-size: 9px;
        gap: 4px;
    }

    .explorer-body {
        display: flex;
        flex-direction: column;
        min-height: 0;
        width: 100%;
        max-width: 100%;
    }

    .explorer-sidebar {
        position: static;
        max-height: none;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        border-radius: 0;
        transform: none;
        box-shadow: none;
        border-top: 0;
    }

    .sidebar-kpi strong { font-size: 17px; }
    .sidebar-kpi { padding: 10px 12px; }
    .sidebar-scroll {
        max-height: none;
        overflow-x: hidden;
        overflow-y: visible;
    }
}

@media (max-width: 959px) and (max-height: 640px) {
    .explorer-map-col {
        height: min(52vh, 420px);
        min-height: 260px;
    }
}
