/* ══════════════════════════════════════════
   France Map – Layout & Structure
   Mobile-first · Vanilla CSS · No framework
   ══════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

/* ── Racine du composant ── */
.fm {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ══════════════════════════════════════════
   ZONE CARTE
   ══════════════════════════════════════════ */
.fm-map-panel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden; /* confine overlay + sheet dans la zone carte */
}

.fm-map {
  width: 100%;
  height: 100%;
  min-height: 60vh; /* repli si le conteneur parent n'a pas de hauteur explicite */
  /* Isole les z-index internes de Leaflet (200–1000) dans ce contexte
     d'empilement. Nos overlays, sheet et liste s'empilent au-dessus sans
     conflit avec .leaflet-top (z-index 1000) etc. */
  isolation: isolate;
}

/* ── Bouton « Me localiser » (contrôle Leaflet custom) ── */
.fm-locate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}

/* Animation pendant la recherche GPS */
.fm-locate-btn.is-loading svg {
  animation: fm-spin 1s linear infinite;
}
@keyframes fm-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── FAB – bouton flottant (mobile + tablette) ── */
.fm-fab {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  border: none;
  border-radius: 24px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  font-family: inherit;
}
.fm-fab:active { opacity: 0.85; }

/* ══════════════════════════════════════════
   OVERLAY (confiné dans .fm-map-panel)
   ══════════════════════════════════════════ */
.fm-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 900;
}
.fm-overlay.is-open { display: block; }

/* ══════════════════════════════════════════
   BOTTOM SHEET (confiné dans .fm-map-panel)
   ══════════════════════════════════════════ */
.fm-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: var(--fm-radius-lg) var(--fm-radius-lg) 0 0;
  z-index: 901;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 100%;
  overflow-y: auto;
  padding: 0 20px 40px;
}
.fm-sheet.is-open { transform: translateY(0); height: 100%; }

.fm-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  margin: 12px auto 20px;
}

.fm-sheet__close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

/* ══════════════════════════════════════════
   ZONE LISTE
   ══════════════════════════════════════════ */
.fm-list-panel {
  display: flex;
  flex-direction: column;
}

/* Header sticky */
.fm-list-header {
  position: sticky;
  top: 0;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--fm-border);
  z-index: 5;
}

/* Bouton ← Carte (mobile uniquement) */
.fm-back-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  min-height: 44px;
  margin-bottom: 8px;
  font-family: inherit;
}

/* Champ de recherche */
.fm-search-wrap { position: relative; }

.fm-search {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--fm-border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  font-family: inherit;
}

.fm-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  pointer-events: none;
}

.fm-count {
  font-size: 12px;
  margin-top: 6px;
  padding: 0 2px;
}

/* Items de la liste */
.fm-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  margin: 0;
  padding: 0;
  padding-left: 0 !important; /* override Divi ul styles */
}

.fm-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--fm-border);
  cursor: pointer;
  min-height: 64px;
  transition: background 0.15s;
  list-style: none;     /* override Divi li styles */
}
.fm-list__item::before,
.fm-list__item::after  { display: none; content: none; } /* supprime les puces Divi */
.fm-list__item.is-active {
  border-left: 3px solid var(--fm-active);
}

.fm-list__name  { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.fm-list__meta  { font-size: 12px; }
.fm-list__arrow { font-size: 20px; flex-shrink: 0; }

/* ── Détail inline dans la liste (mobile + tablette) ── */
.fm-list-detail {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

.fm-list-detail__back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--fm-border);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 14px 16px;
  min-height: 48px;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.fm-list-detail__body { padding: 20px 16px; }

/* Quand le panneau liste est en mode "détail" */
.fm-list-panel.show-detail .fm-list        { display: none; }
.fm-list-panel.show-detail .fm-list-detail { display: flex; }

/* ══════════════════════════════════════════
   ZONE DÉTAIL (desktop)
   ══════════════════════════════════════════ */
.fm-detail-panel {
  border-left: 1px solid var(--fm-border);
  padding: 24px 20px;
  display: none; /* visible uniquement sur desktop */
  flex-direction: column;
}

.fm-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 40px 0;
}
.fm-detail-empty__icon { }
.fm-detail-empty__text { font-size: 14px; line-height: 1.5; }

.fm-detail-content { display: none; }

/* ── Contenu de la fiche (partagé sheet + list-detail + desktop) ── */
.fm-detail__name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}
.fm-detail__city {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 14px;
}
.fm-detail__address {
  font-style: normal;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--fm-border);
}
.fm-detail__services {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.fm-detail__services:empty { display: none; }

.fm-detail__actions { display: flex; flex-direction: column; gap: 10px; }

.fm-detail__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
}
.fm-detail__link:hover { opacity: 0.85; }
.fm-detail__link--hidden { display: none; }

/* ══════════════════════════════════════════
   RESPONSIVE — TABLETTE (768–1023px)
   ══════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1023px) {
  .fm-map { height: 100%; }

  .fm-list-panel {
    display: flex !important;
    position: static !important;
    max-height: 380px;
    border-top: 1px solid var(--fm-border);
  }

  .fm-back-btn { display: none !important; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — DESKTOP (≥ 1024px)
   ══════════════════════════════════════════ */
@media (min-width: 1024px) {
  /* Grille 3 colonnes — SANS overflow:hidden ni align-items:stretch
     → indispensable pour que position:sticky fonctionne */
  .fm {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 280px) minmax(240px, 280px);
    align-items: start;
  }

  /* Carte sticky */
  .fm-map-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
  }

  .fm-map {
    height: 100%;
    min-height: unset;
  }

  /* FAB + sheet + overlay : masqués sur desktop */
  .fm-fab     { display: none !important; }
  .fm-sheet   { display: none !important; }
  .fm-overlay { display: none !important; }

  /* Liste : défile naturellement avec la page */
  .fm-list-panel {
    display: flex !important;
    position: static !important;
    min-height: 100vh;
  }

  .fm-list     { max-height: none; flex: 1; }
  .fm-back-btn { display: none !important; }

  /* Détail sticky */
  .fm-detail-panel {
    display: flex;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

/* ══════════════════════════════════════════
   MOBILE UNIQUEMENT (< 768px)
   ══════════════════════════════════════════ */
@media (max-width: 767px) {
  .fm-list-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000; /* doit couvrir le FAB (800) et l'overlay (900) */
  }
  .fm-list-panel.is-open { display: flex; }
  .fm-back-btn            { display: flex; }
  .fm-detail-panel        { display: none; }
}
