/* ============================================
   ServiCam — Page Carte
   ============================================ */

.carte-main {
  background: var(--bg);
  padding-bottom: 32px;
}
.carte-wrap {
  position: relative;
  /* Confine les z-index internes de Leaflet (panes, contrôles, pins jusqu'à
     ~1000) dans un contexte d'empilement à z-index 1 → toujours SOUS le header
     fixe (z-index 100) quand on scrolle. */
  z-index: 1;
  display: flex;
  width: calc(100% - 32px);
  max-width: 1400px;
  margin: 0 auto 8px;
  height: 580px;
  max-height: calc(100vh - 200px);
  min-height: 440px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}
.carte-map-col {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
}
.carte-map {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--secondary);
}
#map { height: 100% !important; }

/* ── Panneau : liste synchronisée + rayon ── */
.carte-panel {
  order: -1;                       /* à gauche de la carte sur desktop */
  flex: 0 0 340px;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--card-border);
}
.cp-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}
.cp-modes {
  display: flex;
  background: var(--secondary, rgba(127,127,127,0.08));
  border-radius: 10px;
  padding: 3px;
  flex: 1;
}
.cp-mode {
  flex: 1;
  border: 0; background: transparent;
  padding: 7px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  font-family: var(--font); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cp-mode.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(15,23,42,0.1); }
.cp-toggle {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border: 1px solid var(--card-border); background: var(--card);
  border-radius: 8px; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cp-toggle svg { width: 18px; height: 18px; transition: transform 0.2s; }
.carte-panel.collapsed .cp-toggle svg { transform: rotate(180deg); }

/* Contrôle rayon */
.cp-radius {
  padding: 12px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}
.cp-radius-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cp-radius-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.cp-seg { display: flex; gap: 6px; flex: 1; }
.cp-center {
  flex: 1;
  border: 1px solid var(--card-border); background: var(--card);
  padding: 6px 8px; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--fg);
  font-family: var(--font); cursor: pointer;
  white-space: nowrap;
}
.cp-center.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.cp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cp-chip {
  border: 1px solid var(--card-border); background: var(--card);
  padding: 6px 12px; border-radius: 100px;
  font-size: 12.5px; font-weight: 600; color: var(--fg);
  font-family: var(--font); cursor: pointer;
  transition: all 0.15s;
}
.cp-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.cp-count {
  padding: 10px 14px 6px;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  flex-shrink: 0;
}
.cp-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 8px 10px;
}

/* Élément de liste (pro) */
.cp-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--card-border);
}
.cp-item:last-child { border-bottom: 0; }
.cp-item:hover { background: var(--primary-light); }
.cp-avatar {
  width: 42px; height: 42px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0;
  background: var(--secondary);
}
.cp-avatar-default { object-fit: contain; padding: 7px; }
.cp-info { flex: 1; min-width: 0; }
.cp-name {
  font-size: 13.5px; font-weight: 700; color: var(--fg);
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cp-cert { width: 13px; height: 13px; flex-shrink: 0; }
.cp-toppro { color: #5a49b5; font-size: 11px; }
.dark .cp-toppro { color: #b9a6ff; }
.cp-meta {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.cp-dist {
  flex-shrink: 0;
  font-size: 11.5px; font-weight: 700; color: var(--primary);
  background: var(--primary-light);
  padding: 3px 8px; border-radius: 100px;
}
.cp-empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* Replié */
.carte-panel.collapsed { align-self: flex-start; flex-basis: auto; height: auto; }
.carte-panel.collapsed .cp-radius,
.carte-panel.collapsed .cp-count,
.carte-panel.collapsed .cp-list { display: none; }

/* ── Modal autorisation géolocalisation ── */
.geo-overlay {
  position: fixed; inset: 0;
  z-index: 9500;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.geo-overlay.open {
  display: flex;
  animation: geoFadeIn 0.25s ease forwards;
}
@keyframes geoFadeIn { to { opacity: 1; } }

.geo-modal {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 32px 28px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md, 0 20px 60px rgba(15, 23, 42, 0.2));
  text-align: center;
  transform: scale(0.94);
  opacity: 0;
  animation: geoModalIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) 0.05s forwards;
}
@keyframes geoModalIn { to { transform: scale(1); opacity: 1; } }

.geo-illu {
  display: block;
  width: 120px;
  height: auto;
  margin: 0 auto 18px;
  object-fit: contain;
}
@media (max-width: 640px) {
  .geo-illu { width: 96px; }
}
.geo-title {
  font-size: 20px; font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.geo-text {
  font-size: 14px; line-height: 1.55;
  color: var(--muted);
  margin: 0 0 24px;
}
.geo-actions {
  display: flex; gap: 10px;
  justify-content: center; flex-wrap: wrap;
}
.geo-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px; font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
  border: 1px solid transparent;
  flex: 1; min-width: 140px;
}
.geo-btn-primary {
  background: var(--primary, #7033ff);
  color: #fff;
}
.geo-btn-primary:hover {
  background: var(--primary-dark, #5a22d9);
}
.geo-btn-secondary {
  background: var(--secondary);
  color: var(--fg);
  border-color: var(--card-border);
}
.geo-btn-secondary:hover {
  background: var(--card-border);
  color: var(--fg);
  border-color: var(--card-border);
}

/* ── Barre de recherche (au-dessus de la carte) ── */
.carte-search-container {
  padding-top: 16px;
  padding-bottom: 14px;
  position: relative;
  /* Contexte d'empilement SOUS le header (z-index 100) : la barre + son
     dropdown passent sous le menu au scroll, tout en restant au-dessus de la
     carte (.carte-wrap = z-index 1). */
  z-index: 40;
}
.carte-search {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  font-family: var(--font);
  z-index: 1500;
}
.carte-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0 12px 0 42px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.carte-search-box:focus-within {
  border-color: var(--primary, #7033ff);
  box-shadow: 0 4px 14px rgba(112, 51, 255, 0.2);
}
.carte-search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--muted);
  pointer-events: none;
}
.carte-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 0;
  font-size: 14px;
  font-family: inherit;
  color: var(--fg);
  min-width: 0;
}
.carte-search input::placeholder { color: var(--muted); }
.carte-search-clear {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: none;
  transition: background 0.15s, color 0.15s;
}
.carte-search-clear:hover { background: var(--secondary); color: var(--fg); }
.carte-search.has-value .carte-search-clear { display: inline-flex; }

.carte-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 1600;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  display: none;
}
.carte-search-results.open { display: block; }

.carte-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--card-border);
  transition: background 0.15s;
}
.carte-search-item:last-child { border-bottom: none; }
.carte-search-item:hover,
.carte-search-item.active {
  background: rgba(112, 51, 255, 0.06);
}
.carte-search-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--secondary);
  flex-shrink: 0;
}
.carte-search-avatar-default {
  padding: 8px;
  background: #eef2f7;
  object-fit: contain;
}
.dark .carte-search-avatar-default {
  background: #1a1d27;
  filter: invert(0.88) hue-rotate(180deg);
}
.carte-search-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.carte-search-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -0.01em;
}
.carte-search-meta {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.carte-search-cert {
  width: 13px; height: 13px;
  vertical-align: -2px;
  margin-left: 4px;
  filter: invert(52%) sepia(89%) saturate(380%) hue-rotate(110deg) brightness(92%) contrast(88%);
}
.carte-search-dist {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary, #7033ff);
  background: rgba(112, 51, 255, 0.1);
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
  margin-left: 8px;
}
.carte-search-group-title {
  padding: 10px 14px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.02);
  border-bottom: 1px solid var(--card-border);
}
.dark .carte-search-group-title { background: rgba(255, 255, 255, 0.03); }
.carte-search-place-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(112, 51, 255, 0.08);
  color: var(--primary, #7033ff);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.carte-search-place-icon svg { width: 18px; height: 18px; }
.carte-search-empty {
  padding: 22px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ── FAB "Me localiser" ── */
.carte-fab-locate {
  position: absolute;
  bottom: 24px; right: 16px;
  z-index: 1000;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--card);
  color: var(--primary, #7033ff);
  border: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.15);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
}
.carte-fab-locate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(112, 51, 255, 0.35);
  background: var(--primary, #7033ff);
  color: #fff;
}
.carte-fab-locate.loading svg { animation: fabSpin 1s linear infinite; }
@keyframes fabSpin { to { transform: rotate(360deg); } }

/* ── Marqueur pro : pin pointu violet ── */
.pro-pin-wrap { background: transparent !important; border: none !important; }
.pro-pin {
  width: 30px; height: 42px;
  filter: drop-shadow(0 3px 6px rgba(112, 51, 255, 0.4));
  transition: transform 0.2s;
}
.pro-pin:hover { transform: scale(1.15); }
.pro-pin svg { width: 100%; height: 100%; display: block; }

/* ── Marqueur utilisateur : pin pointu rouge ── */
.user-pin-wrap { background: transparent !important; border: none !important; }
.user-pin {
  width: 32px; height: 44px;
  filter: drop-shadow(0 3px 8px rgba(239, 68, 68, 0.5));
  animation: userBounce 2s ease-in-out infinite;
}
.user-pin svg { width: 100%; height: 100%; display: block; }
@keyframes userBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ── Popup Leaflet pro : style ServiCam ── */
.leaflet-popup-content-wrapper {
  border-radius: 14px !important;
  padding: 0 !important;
  overflow: hidden;
  background: var(--card) !important;
  color: var(--fg);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.2) !important;
}
.leaflet-popup-content {
  margin: 0 !important;
  width: 270px !important;
  font-family: var(--font);
}
.leaflet-popup-tip { background: var(--card) !important; }
.leaflet-container a.leaflet-popup-close-button {
  color: var(--muted);
  font-size: 22px;
  padding: 6px 8px 0 0;
}
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--fg); }

.pop-card { display: flex; flex-direction: column; }
.pop-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 10px;
}
.pop-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--secondary);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}
.pop-avatar-default {
  padding: 12px;
  background: #eef2f7;
  object-fit: contain;
}
.dark .pop-avatar-default {
  background: #1a1d27;
  filter: invert(0.88) hue-rotate(180deg);
}
.pop-info { flex: 1; min-width: 0; }
.pop-name {
  font-size: 14.5px; font-weight: 800;
  color: var(--fg);
  line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -0.01em;
}
.pop-toppro {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary, #7033ff);
  background: transparent;
  border: none;
  padding: 0;
  margin-top: 4px;
}
.pop-toppro i { color: var(--primary, #7033ff); font-size: 11px; }
.pop-trade {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pop-meta {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px 10px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.pop-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.pop-meta-item svg { width: 11px; height: 11px; flex-shrink: 0; }
.pop-rating { color: #f59e0b; font-weight: 700; }
.pop-distance {
  color: var(--primary, #7033ff);
  font-weight: 700;
}
.pop-distance svg { color: var(--primary, #7033ff); }
.pop-rating-count { color: var(--muted); font-weight: 500; margin-left: 2px; }
.pop-cta {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  margin: 0 16px 16px;
  padding: 10px;
  background: var(--primary, #7033ff);
  color: #fff !important;
  font-size: 13px; font-weight: 700;
  border-radius: 10px;
  text-decoration: none !important;
  transition: background 0.2s, transform 0.15s;
}
.pop-cta:hover {
  background: var(--primary-dark, #5a2fd9);
  transform: translateY(-1px);
  text-decoration: none !important;
}
.pop-cta svg { width: 14px; height: 14px; }

.leaflet-popup-content .user-pop {
  padding: 14px 16px;
  font-size: 13.5px; font-weight: 600;
  color: var(--fg);
  text-align: center;
}

/* ── Cluster : couleurs harmonisées avec --primary ── */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(112, 51, 255, 0.18) !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: var(--primary, #7033ff) !important;
  color: #fff !important;
  font-weight: 700 !important;
}
.marker-cluster { font-family: var(--font); }

/* ── Contrôle layers ── */
.leaflet-control-layers {
  border-radius: 12px !important;
  border: 1px solid var(--card-border) !important;
  background: var(--card) !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12) !important;
}
.leaflet-control-layers-expanded {
  padding: 10px 14px !important;
  color: var(--fg) !important;
  font-family: var(--font);
}
.leaflet-control-layers label {
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.leaflet-control-layers-toggle { width: 36px !important; height: 36px !important; }
.leaflet-control-zoom a {
  background: var(--card) !important;
  color: var(--fg) !important;
  border-color: var(--card-border) !important;
}
.leaflet-control-zoom a:hover {
  background: var(--primary, #7033ff) !important;
  color: #fff !important;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.85) !important;
  font-size: 10px !important;
}
.dark .leaflet-control-attribution {
  background: rgba(20, 20, 30, 0.85) !important;
  color: var(--muted) !important;
}
.dark .leaflet-control-attribution a { color: var(--primary, #7033ff) !important; }

/* ── Responsive mobile ── */
@media (max-width: 640px) {
  .carte-wrap {
    flex-direction: column;
    width: calc(100% - 24px);
    margin: 0 12px 12px;
    height: calc(100dvh - 130px);
    max-height: none;
    min-height: 400px;
    border-radius: 14px;
  }
  .carte-map-col { flex: 1; min-height: 200px; }
  /* Panneau sous la carte (bottom sheet intégré) */
  .carte-panel {
    order: 0;                       /* après la carte (DOM : carte puis panel) */
    flex: 0 0 44vh;
    height: 44vh;
    border-right: 0;
    border-top: 1px solid var(--card-border);
  }
  .carte-panel.collapsed { flex-basis: auto; height: auto; }
  .carte-search-container { padding-top: 8px; padding-bottom: 8px; }
  .geo-modal {
    margin: 0 16px;
    padding: 28px 20px 20px;
  }
  .geo-icon { width: 56px; height: 56px; margin-bottom: 14px; }
  .geo-title { font-size: 18px; }
  .geo-text { font-size: 13.5px; }
  .geo-btn { padding: 11px 14px; min-width: 0; }
  .carte-fab-locate {
    bottom: 18px; right: 12px;
    width: 44px; height: 44px;
  }
  .leaflet-popup-content { width: 240px !important; }
}
