/**
 * Carte Modale — Styles
 *
 * FAB sticky droite (mid-screen) + dialog plein écran + contrôles/légende.
 * Cohérent avec le design system Civic Modern.
 */

/* ──────────────────────────────────────────────────────────────────────
 * FAB sticky (bouton ouvrant la modale)
 * ─────────────────────────────────────────────────────────────────── */
.carte-fab {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 48px;
    height: 64px;
    border-radius: 12px 0 0 12px;
    background: var(--bleu);
    color: #fff;
    border: 0;
    box-shadow: -4px 6px 18px rgba(15, 43, 70, 0.28);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s, width 0.2s;
    z-index: 95;
}
.carte-fab:hover,
.carte-fab:focus-visible {
    background: var(--accent);
    width: 54px;
    box-shadow: -6px 8px 22px rgba(0, 180, 216, 0.35);
    outline: none;
}
.carte-fab svg {
    width: 26px;
    height: 26px;
    display: block;
}
.carte-fab__label {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 43, 70, 0.92);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s;
}
.carte-fab:hover .carte-fab__label,
.carte-fab:focus-visible .carte-fab__label {
    opacity: 1;
}

/* Bouton "expand" — ouvre la modale depuis la carte inline d'une page */
.carte-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-pill, 100px);
    border: 1px solid rgba(15, 43, 70, 0.12);
    background: rgba(255, 255, 255, 0.92);
    color: var(--bleu);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15, 43, 70, 0.08);
    transition: background 0.2s, color 0.2s, transform 0.2s;
}
.carte-expand-btn:hover,
.carte-expand-btn:focus-visible {
    background: var(--bleu);
    color: #fff;
    outline: none;
    transform: translateY(-1px);
}
.carte-expand-btn svg {
    width: 14px;
    height: 14px;
}

/* Variante overlay : positionné absolu sur la carte (ex: mini-carte commune) */
.carte-expand-btn--overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 401;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Variante dans les contrôles d'une carte inline : pousse à droite */
.carte-expand-btn--push {
    margin-left: auto;
}

/* ──────────────────────────────────────────────────────────────────────
 * Dialog plein écran
 * ─────────────────────────────────────────────────────────────────── */
.carte-modale {
    width: min(96vw, 1400px);
    height: min(94vh, 900px);
    max-width: none;
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: var(--radius, 16px);
    box-shadow: 0 24px 60px rgba(15, 43, 70, 0.3);
    background: #fff;
    overflow: hidden;
}
.carte-modale::backdrop {
    background: rgba(15, 43, 70, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
body.carte-modale-open {
    overflow: hidden;
}

.carte-modale__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.carte-modale__header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
    flex-wrap: wrap;
}
.carte-modale__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--bleu);
    flex: 0 0 auto;
}
.carte-modale__controls {
    flex: 1 1 auto;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.carte-modale__close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f2f5;
    color: var(--bleu);
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.carte-modale__close:hover,
.carte-modale__close:focus-visible {
    background: var(--bleu);
    color: #fff;
    outline: none;
}
.carte-modale__close svg {
    width: 18px;
    height: 18px;
}

/* Contrôles dans le header */
.carte-modale__controls-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.carte-modale__control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--bleu);
    font-weight: 600;
}
.carte-modale__control > span {
    white-space: nowrap;
}
.carte-modale__control select,
.carte-modale__control input[type="search"],
.carte-modale__control input[type="text"] {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm, 10px);
    font-size: 0.85rem;
    font-family: inherit;
    background: #fff;
    color: var(--bleu);
    cursor: pointer;
    min-width: 0;
}
.carte-modale__control input[type="search"] {
    cursor: text;
    min-width: 180px;
}
.carte-modale__control--toggle {
    cursor: pointer;
}
.carte-modale__control--toggle input[type="checkbox"] {
    margin: 0;
}

/* Body */
.carte-modale__body {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
    background: #f0f2f5;
}
.carte-modale__map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}
.carte-modale-error {
    padding: 2rem;
    text-align: center;
    color: var(--fonce);
}

/* Footer */
.carte-modale__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 18px;
    border-top: 1px solid #e2e8f0;
    background: #fafbfc;
    font-size: 0.76rem;
    color: var(--fonce);
    flex-wrap: wrap;
}
.carte-modale__legend {
    flex: 1 1 auto;
}
.carte-modale__attribution {
    flex: 0 0 auto;
    color: #94a3b8;
}

/* Légende gradient (utilisée par l'adapter départment) */
.carte-modale__legend-grad {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--bleu);
}
.carte-modale__legend-bar {
    height: 10px;
    width: 160px;
    border-radius: 5px;
    background: linear-gradient(to right, #0f2b46, #00b4d8);
}
.carte-modale__legend-label {
    color: var(--fonce);
    font-weight: 500;
    margin-left: 4px;
}

/* Légende commune (swatches contour + voisines) */
.carte-modale__legend-commune {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--bleu);
    font-weight: 500;
}
.carte-modale__legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}
.carte-modale__legend-swatch--origin {
    background: rgba(0, 180, 216, 0.45);
    border: 2px solid #0f2b46;
}
.carte-modale__legend-swatch--neighbor {
    background: rgba(148, 163, 184, 0.25);
    border: 1px dashed #64748b;
}

/* Labels communes (overlay) */
.carte-modale__commune-label {
    pointer-events: none;
    background: transparent;
    border: 0;
}
.carte-modale__commune-label span {
    display: inline-block;
    padding: 1px 5px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--bleu);
    font-family: Outfit, sans-serif;
    font-size: 10px;
    font-weight: 600;
    border-radius: 3px;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ──────────────────────────────────────────────────────────────────────
 * Responsive
 * ─────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .carte-fab {
        width: 42px;
        height: 56px;
        right: 0;
        border-radius: 10px 0 0 10px;
    }
    .carte-fab:hover,
    .carte-fab:focus-visible {
        width: 46px;
    }
    .carte-fab svg {
        width: 22px;
        height: 22px;
    }
    .carte-fab__label {
        display: none;
    }
    .carte-modale {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    .carte-modale__header {
        padding: 10px 12px;
    }
    .carte-modale__title {
        font-size: 0.95rem;
    }
    .carte-modale__controls-grid {
        gap: 8px;
        width: 100%;
    }
    .carte-modale__control {
        font-size: 0.78rem;
        flex: 1 1 auto;
    }
    .carte-modale__control select,
    .carte-modale__control input[type="search"] {
        flex: 1 1 auto;
        min-width: 0;
    }
    .carte-modale__legend-bar {
        width: 100px;
    }
}

@media (max-width: 480px) {
    .carte-expand-btn span {
        display: none;
    }
    .carte-expand-btn {
        padding: 8px;
    }
}
