/* Carte interactive CPTS Agly */
.cpts-carte {
    --navy: #0d1b42;
    --rose: #bc7d9a;
    --rose-d: #9f5f7d;
    --muted: #5d647a;
    --line: #e6e8ef;
    --panel-w: 360px;
    position: relative;
    display: grid;
    grid-template-columns: var(--panel-w) minmax(0, 1fr);
    height: var(--cpts-carte-h, 640px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 30px rgba(13, 27, 66, .12);
    background: #fff;
    font-family: inherit;
    transition: grid-template-columns .3s cubic-bezier(.2, .8, .2, 1);
}
.cpts-carte.is-list-closed { grid-template-columns: 0 minmax(0, 1fr); }

/* Panneau gauche : titre + liste pleine hauteur */
.cpts-carte__panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    min-height: 0;
    padding: 24px 20px 0;
    overflow: hidden;
    border-right: 1px solid var(--line);
    background: #fff;
    z-index: 2;
}
.cpts-carte.is-list-closed .cpts-carte__panel { visibility: hidden; padding-inline: 0; border: 0; }
.cpts-carte__head { width: calc(var(--panel-w) - 40px); }
.cpts-carte__head h1 { margin: 0 0 6px; padding: 0; font: 400 28px/1.1 'Avant Garde CPTS', 'Poppins', sans-serif; color: var(--navy); letter-spacing: -.01em; }
.cpts-carte__head p { margin: 0; padding: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.cpts-carte__listhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.cpts-carte__count { margin: 0 !important; padding: 0 !important; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.cpts-carte__count strong { font-size: 15px; color: var(--navy); }
.cpts-carte__reset { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--rose-d); font: 600 12.5px/1 inherit; cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.cpts-carte__reset::before { content: "↺ "; }
.cpts-carte__reset:hover { background: var(--rose-d); border-color: var(--rose-d); color: #fff; }
.cpts-carte__reset[hidden], .cpts-carte__tags[hidden] { display: none; }
.cpts-carte__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.cpts-tag { --chip: var(--navy); display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--chip) 14%, #fff); color: var(--navy); font: 500 12px/1.2 inherit; cursor: pointer; }
.cpts-tag b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--chip); color: #fff; font-size: 13px; line-height: 1; }
.cpts-tag:hover b { filter: brightness(.85); }

.cpts-carte__list { flex: 1; min-height: 0; margin: 0 -8px 0 0 !important; padding: 0 8px 20px 0 !important; list-style: none; overflow-y: auto; }
.cpts-carte__list li { margin: 0 0 6px; padding: 0; list-style: none; }
.cpts-carte__list button {
    --chip: var(--navy);
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f6f7fa;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: var(--navy);
    transition: background .2s, border-color .2s;
}
.cpts-carte__list button:hover { background: #fff; border-color: color-mix(in srgb, var(--chip) 45%, #fff); }
.cpts-carte__list button img { flex: none; width: 26px; height: 32px; object-fit: contain; }
.cpts-carte__list button span { display: grid; gap: 2px; min-width: 0; }
.cpts-carte__list strong { font-size: 14px; font-weight: 600; line-height: 1.3; }
.cpts-carte__list small { font-size: 12px; color: var(--muted); }
.cpts-carte__empty { padding: 20px 4px !important; font-size: 14px; line-height: 1.6; color: var(--muted); text-align: center; }
.cpts-carte__empty button { display: inline-block; width: auto; margin-top: 10px; padding: 8px 16px; border-radius: 999px; background: var(--navy); color: #fff; font-weight: 600; }
.cpts-carte__empty button:hover { background: var(--rose-d); color: #fff; }

/* Zone carte + barre de filtres flottante centrée en haut */
.cpts-carte__stage { position: relative; min-width: 0; min-height: 0; }
.cpts-carte__map { position: absolute; inset: 0; z-index: 0; background: #f2f2f0; }
.cpts-carte__bar {
    position: absolute;
    top: 16px;
    left: 50%;
    z-index: 500;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 10px 34px rgba(13, 27, 66, .16);
    backdrop-filter: blur(8px);
    transform: translateX(-50%);
}
.cpts-carte__filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.cpts-chip {
    --chip: var(--navy);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 5px 6px;
    border: 1.5px solid color-mix(in srgb, var(--chip) 40%, #fff);
    border-radius: 999px;
    background: #fff;
    color: var(--navy);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background .2s, border-color .2s, color .2s;
}
.cpts-chip:hover { border-color: var(--chip); }
.cpts-chip.is-on { border-color: var(--chip); background: var(--chip); color: #fff; }
.cpts-chip img { width: 18px; height: 22px; object-fit: contain; }
.cpts-chip.is-on img { filter: drop-shadow(0 0 1px #fff); }
.cpts-chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--chip); margin-left: 4px; }
.cpts-chip:focus-visible, .cpts-carte__list button:focus-visible, .cpts-carte__toggle:focus-visible, .cpts-tag:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.cpts-carte__select { margin: 0; }
.cpts-carte__select select { height: 32px; padding: 0 30px 0 12px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; color: var(--navy); font: 500 12.5px/1 inherit; cursor: pointer; }

/* Bouton d'ouverture / fermeture de la liste */
.cpts-carte__toggle {
    position: absolute;
    bottom: 24px;
    left: 16px;
    z-index: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px 0 12px;
    border: 0;
    border-radius: 999px;
    background: var(--navy);
    color: #fff;
    font: 600 13px/1 inherit;
    box-shadow: 0 6px 20px rgba(13, 27, 66, .25);
    cursor: pointer;
    transition: background .2s;
}
.cpts-carte__toggle:hover { background: var(--rose-d); }
.cpts-carte__chev { width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-left: 3px; transition: transform .3s; }
.cpts-carte.is-list-closed .cpts-carte__chev { transform: rotate(-135deg); margin: 0 3px 0 0; }

/* Fond de carte en nuances de gris */
.cpts-carte.is-raster .leaflet-tile-pane { filter: url(#cpts-carte-tiles); }

/* Marqueurs */
.cpts-marker { filter: drop-shadow(0 3px 4px rgba(13, 27, 66, .3)); transition: filter .2s; }
.cpts-marker:hover { filter: drop-shadow(0 5px 8px rgba(13, 27, 66, .45)); }
.cpts-pin span { display: block; width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.cpts-carte .leaflet-bottom.leaflet-right .leaflet-control-zoom { margin: 0 16px 28px 0; border: 0; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 20px rgba(13, 27, 66, .18); }
.cpts-carte .leaflet-control-zoom a { width: 38px; height: 38px; line-height: 38px; color: var(--navy); }

.cpts-popup { font-size: 13.5px; line-height: 1.45; }
.cpts-popup h3 { font-size: 16px; margin: 0 0 4px; padding: 0; }
.cpts-popup h4 { font-size: 14px; margin: 0 0 4px; padding: 0; }
.cpts-popup p { margin: 0 0 4px; padding: 0; }
.leaflet-popup-content-wrapper { border-radius: 12px; }


/* Mobile : carte plein écran, barre de filtres défilante, liste en panneau du bas */
@media (max-width: 900px) {
    .cpts-carte, .cpts-carte.is-list-closed { display: flex; flex-direction: column; grid-template-columns: none; }
    .cpts-carte__stage { flex: 1; order: 1; min-height: 60vh; }
    .cpts-carte__panel { order: 2; flex: 0 0 auto; max-height: 55%; padding: 16px 16px 0; border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(13, 27, 66, .12); }
    .cpts-carte.is-list-closed .cpts-carte__panel { display: none; }
    .cpts-carte__head { width: auto; }
    .cpts-carte__head h1 { font-size: 20px; margin: 0; }
    .cpts-carte__head p { display: none; }
    .cpts-carte__listhead { padding-top: 10px; }
    .cpts-carte__bar { top: 10px; left: 10px; right: 10px; width: auto; max-width: none; flex-wrap: nowrap; justify-content: flex-start; padding: 8px; border-radius: 14px; overflow-x: auto; transform: none; scrollbar-width: none; }
    .cpts-carte__bar::-webkit-scrollbar { display: none; }
    .cpts-carte__filters { flex-wrap: nowrap; }
    .cpts-carte__toggle { bottom: 16px; left: 50%; transform: translateX(-50%); }
    .cpts-carte .leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-bottom: 70px; }
}
@media (max-width: 900px) {
    .cpts-carte--plein .cpts-carte__stage { min-height: 0; }
}

/* Moteur v2 : 1re ligne vignettes illustrées, 2e ligne listes déroulantes + Effacer */
.cpts-carte__bar { flex-direction: column; flex-wrap: nowrap; gap: 10px; padding: 10px 12px 12px; }
.cpts-carte__filters { display: flex; flex-wrap: nowrap; justify-content: center; gap: 4px; max-width: 100%; }
.cpts-chip--picto { flex: none; width: 104px; height: 84px; padding: 4px; border: 0; border-radius: 12px; background: transparent; opacity: 1; box-shadow: none; transition: background .2s, box-shadow .2s, transform .2s; }
.cpts-chip--picto img { display: block; width: 100%; height: 100%; object-fit: contain; filter: none !important; }
.cpts-chip--picto:hover { background: #f3f4f8; border: 0; }
.cpts-chip--picto.is-on { background: color-mix(in srgb, var(--chip) 16%, #fff); box-shadow: inset 0 -3px 0 var(--chip); color: inherit; }
.cpts-carte__selects { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; width: 100%; }
.cpts-carte__selects .cpts-carte__select select {
    width: 100%; height: 40px; padding: 0 38px 0 18px; border: 0; border-radius: 999px;
    background: var(--rose) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 16px center / 12px 8px;
    color: #fff; font: 600 14px/1 inherit; text-align: center; text-align-last: center; -webkit-appearance: none; appearance: none; cursor: pointer; transition: background-color .2s;
}
.cpts-carte__selects .cpts-carte__select select:hover, .cpts-carte__selects .cpts-carte__select select.is-on { background-color: var(--rose-d); }
.cpts-carte__selects select option { color: var(--navy); background: #fff; text-align: left; }
.cpts-carte__clear { height: 40px; padding: 0 22px; border: 1.5px solid var(--rose); border-radius: 999px; background: #fff; color: var(--rose-d); font: 600 14px/1 inherit; cursor: pointer; transition: background .2s, color .2s, opacity .2s; }
.cpts-carte__clear:hover:not(:disabled) { background: var(--rose-d); border-color: var(--rose-d); color: #fff; }
.cpts-carte__clear:disabled { opacity: .45; cursor: default; }
@media (max-width: 1280px) { .cpts-chip--picto { width: 88px; height: 72px; } }
@media (max-width: 900px) {
    .cpts-carte__bar { flex-direction: column; overflow: visible; padding: 8px; gap: 8px; }
    .cpts-carte__filters { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 8px; max-width: none; width: calc(100% + 16px); }
    .cpts-carte__filters::-webkit-scrollbar { display: none; }
    .cpts-chip--picto { width: 76px; height: 62px; }
    .cpts-carte__selects { grid-template-columns: 1fr 1fr; }
    .cpts-carte__selects .cpts-carte__select select { height: 36px; padding: 0 28px 0 12px; font-size: 12.5px; background-position: right 11px center; }
    .cpts-carte__clear { display: none; }
}
/* Les vignettes d'origine ont beaucoup de marge blanche : on zoome dedans */
.cpts-chip--picto { overflow: hidden; }
.cpts-chip--picto img { transform: scale(1.45); }
@media (max-width: 900px) { .cpts-carte__selects .cpts-carte__select select { font-size: 12px; padding: 0 24px 0 10px; background-position: right 9px center; } }
.cpts-chip--picto { width: 112px; }
.cpts-chip--picto img { transform: scale(1.3); }
@media (max-width: 1280px) { .cpts-chip--picto { width: 94px; height: 74px; } }
@media (max-width: 900px) { .cpts-chip--picto { width: 80px; height: 64px; } }

/* Groupes de marqueurs : nombre au centre, anneau aux couleurs des dispositifs */
.cpts-cluster { background: none; border: 0; }
.cpts-cluster span { display: grid; place-items: center; width: 100%; height: 100%; padding: 4px; border-radius: 50%; box-shadow: 0 4px 14px rgba(13, 27, 66, .3); transition: transform .2s; }
.cpts-cluster b { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; background: var(--navy, #0d1b42); border: 2px solid #fff; color: #fff; font: 700 15px/1 'Poppins', sans-serif; }
.cpts-cluster:hover span { transform: scale(1.08); }
.leaflet-cluster-spider-leg { stroke: #0d1b42; stroke-opacity: .5; }
.cpts-commune-tip { padding: 4px 10px; border: 0; border-radius: 999px; background: #0d1b42; color: #fff; font: 600 12.5px/1.2 Poppins, sans-serif; box-shadow: 0 4px 14px rgba(13, 27, 66, .25); }
.cpts-commune-tip::before { display: none; }

/* Carte du territoire : recherche de commune + marqueurs MSP */
.cpts-carte__bar [hidden] { display: none !important; }
.cpts-carte__search { position: relative; display: flex; align-items: center; width: min(520px, 100%); }
.cpts-carte__search .cpts-ico { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.cpts-carte__commune { width: 100%; height: 46px; padding: 0 18px 0 44px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; color: var(--navy); font: 500 14.5px/1 inherit; }
.cpts-carte__commune:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 4px rgba(188, 125, 154, .15); }
.cpts-carte__result { margin: 0 !important; padding: 8px 14px !important; border-radius: 999px; font-size: 13.5px; font-weight: 600; text-align: center; }
.cpts-carte__result.is-in { background: #eef6dc; color: #4d6b0c; }
.cpts-carte__result.is-out { background: #fdecef; color: #a33a52; }
.cpts-msp-pin { background: none; border: 0; filter: drop-shadow(0 4px 6px rgba(13, 27, 66, .35)); transition: transform .2s; }
.cpts-msp-pin svg { display: block; width: 100%; height: 100%; }
.cpts-msp-pin:hover { transform: translateY(-3px); }
@media (max-width: 900px) { .cpts-carte__search { width: 100%; } .cpts-carte__commune { height: 42px; font-size: 14px; } }
@media (min-width: 901px) { .cpts-carte__search { width: 440px; } }
