/* =============================================================
   style.css — Cartographie électorale NOUS Forez
   Intégré au design system Bauhaus NF :
   crème #F7F5F0 / noir #1F1F1F / rose #F62DAE / vert #63A46C
   Bebas Neue (titres) + Inter (corps)
   ============================================================= */

/* ── Layout global ──────────────────────────────────────────── */

#nf-carto-wrap {
    display: flex;
    position: relative;
    width: 100%;
    height: calc(100vh - 64px); /* 64px = hauteur header NF */
    overflow: hidden;
    background: #F7F5F0;
}

/* ── Panneau gauche ─────────────────────────────────────────── */

#nf-carto-panel {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #1F1F1F;
    color: #F7F5F0;
    border-right: 3px solid #F62DAE;
    z-index: 10;
    overflow-y: auto;
}

#nf-carto-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 14px;
    border-bottom: 1px solid rgba(247,245,240,0.1);
}

#nf-carto-panel-header h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px;
    letter-spacing: 0.06em;
    color: #F7F5F0;
    margin: 0;
}

.nf-carto-logo-dot {
    width: 10px;
    height: 10px;
    background: #F62DAE;
    border-radius: 0;
    flex-shrink: 0;
}

#nf-carto-panel-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#nf-carto-panel-body label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(247,245,240,0.5);
    display: block;
    margin-top: 8px;
}

#nf-carto-panel-body select {
    width: 100%;
    background: rgba(247,245,240,0.06);
    border: 1px solid rgba(247,245,240,0.15);
    color: #F7F5F0;
    font-size: 12px;
    padding: 7px 10px;
    cursor: pointer;
    border-radius: 0;
    appearance: none;
    -webkit-appearance: none;
}

#nf-carto-panel-body select:hover {
    border-color: #F62DAE;
}

#nf-carto-panel-body select optgroup {
    background: #1F1F1F;
    color: rgba(247,245,240,0.5);
    font-size: 10px;
}

#nf-carto-panel-body select option {
    background: #2a2a2a;
    color: #F7F5F0;
}

.nf-carto-help {
    font-size: 10px;
    line-height: 1.5;
    color: rgba(247,245,240,0.35);
    margin-top: 4px;
    border-top: 1px solid rgba(247,245,240,0.08);
    padding-top: 10px;
}

#btnClassement {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    padding: 9px 12px;
    background: transparent;
    border: 1px solid rgba(247,245,240,0.2);
    color: #F7F5F0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.15s, background 0.15s;
    border-radius: 0;
}

#btnClassement:hover {
    border-color: #F62DAE;
    background: rgba(246,45,174,0.08);
}

/* ── Carte Leaflet ──────────────────────────────────────────── */

#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* ── Panneau latéral droit ──────────────────────────────────── */

#sidePanel {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: #F7F5F0;
    border-left: 3px solid #1F1F1F;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 20;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidePanel.open {
    transform: translateX(0);
}

#sidePanelHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #1F1F1F;
    color: #F7F5F0;
    border-bottom: 3px solid #F62DAE;
    flex-shrink: 0;
}

#sidePanelHeader h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 17px;
    letter-spacing: 0.06em;
    color: #F7F5F0;
    margin: 0;
}

#closeSidePanel {
    background: none;
    border: none;
    color: #F7F5F0;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

#closeSidePanel:hover { opacity: 1; }

#sidePanelContent {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ── Sections dans le panneau ───────────────────────────────── */

.info-section {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(31,31,31,0.08);
}

.info-section h3 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #1F1F1F;
    margin: 0 0 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #F62DAE;
    display: inline-block;
}

.commune-title {
    font-family: 'Bebas Neue', sans-serif !important;
    font-size: 22px !important;
    letter-spacing: 0.06em !important;
    margin-bottom: 6px !important;
    border-bottom: none !important;
    display: block !important;
}

.priority {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 8px;
    background: #F62DAE;
    color: #F7F5F0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ── Grille de métriques ────────────────────────────────────── */

.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}

.metric {
    background: #1F1F1F;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric b {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(247,245,240,0.5);
}

.metric span {
    font-size: 15px;
    font-weight: 700;
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.04em;
    color: #F7F5F0;
}

/* ── Tableau historique ─────────────────────────────────────── */

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 8px;
}

.history-table th {
    background: #1F1F1F;
    color: rgba(247,245,240,0.6);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 5px 6px;
    text-align: left;
}

.history-table td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(31,31,31,0.06);
    color: #1F1F1F;
}

.history-table tr:hover td {
    background: rgba(31,31,31,0.04);
}

.history-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Boîte scénario / simulation ────────────────────────────── */

.scenario-box {
    background: rgba(31,31,31,0.04);
    border: 1px solid rgba(31,31,31,0.1);
    padding: 10px 12px;
    margin: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scenario-box label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(31,31,31,0.5);
}

.scenario-box input[type="range"] {
    width: 100%;
    accent-color: #F62DAE;
    cursor: pointer;
}

.scenario-box select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid rgba(31,31,31,0.15);
    background: #F7F5F0;
    font-size: 11px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.scenario-result {
    margin-top: 4px;
}

/* ── Notes et textes secondaires ────────────────────────────── */

.small-note {
    font-size: 10px;
    color: rgba(31,31,31,0.45);
    line-height: 1.5;
    margin-top: 6px;
}

/* ── Graphiques Chart.js ────────────────────────────────────── */

.chart-wrapper {
    margin-top: 4px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.chart-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1F1F1F;
}

.chart-zoom-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #1F1F1F;
    color: #F7F5F0;
    border: none;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 0.15s;
}

.chart-zoom-btn:hover { background: #F62DAE; }

.chartBox {
    height: 200px;
    background: #fff;
    border: 1px solid rgba(31,31,31,0.1);
    padding: 8px;
}

.chart-hint {
    font-size: 9px;
    color: rgba(31,31,31,0.35);
    margin-top: 4px;
    font-style: italic;
}

/* ── Modal zoom graphique ───────────────────────────────────── */

#chartZoomModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

#chartZoomModal.open { display: flex; align-items: center; justify-content: center; }

#chartZoomOverlay {
    position: absolute;
    inset: 0;
    background: rgba(31,31,31,0.7);
}

#chartZoomBox {
    position: relative;
    z-index: 1;
    background: #F7F5F0;
    border: 3px solid #1F1F1F;
    width: 90vw;
    max-width: 900px;
    padding: 16px;
}

#chartZoomHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

#chartZoomTitle {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 18px;
    letter-spacing: 0.06em;
}

#chartZoomClose {
    background: #1F1F1F;
    color: #F7F5F0;
    border: none;
    font-size: 20px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#chartZoomClose:hover { background: #F62DAE; }

#chartZoomCanvas {
    height: 60vh;
    background: #fff;
    border: 1px solid rgba(31,31,31,0.1);
    padding: 10px;
}

#chartZoomCanvas canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── Légende Leaflet ────────────────────────────────────────── */

.leaflet-control.legend {
    background: #F7F5F0;
    border: 2px solid #1F1F1F;
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.8;
    max-width: 200px;
    font-family: 'Inter', sans-serif;
}

.leaflet-control.legend b {
    display: block;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 13px;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.leaflet-control.legend span {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    border: 1px solid rgba(0,0,0,0.15);
    vertical-align: middle;
}

.leaflet-control.legend hr {
    border: none;
    border-top: 1px solid rgba(31,31,31,0.12);
    margin: 6px 0;
}

/* ── Responsive mobile ──────────────────────────────────────── */

@media (max-width: 768px) {

    #nf-carto-wrap {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 56px);
    }

    #nf-carto-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        border-right: none;
        border-bottom: 3px solid #F62DAE;
        overflow-x: auto;
    }

    #nf-carto-panel-header {
        border-bottom: none;
        padding: 12px;
        flex-shrink: 0;
    }

    #nf-carto-panel-body {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
        padding: 8px 12px;
        gap: 8px;
        flex: 1;
    }

    #nf-carto-panel-body label { margin-top: 0; }

    #nf-carto-panel-body select {
        width: auto;
        min-width: 140px;
    }

    .nf-carto-help, #btnClassement { display: none; }

    #map {
        height: 65vw;
        min-height: 320px;
    }

    #sidePanel {
        position: relative;
        transform: none;
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 3px solid #1F1F1F;
        display: none;
    }

    #sidePanel.open { display: flex; }
}
