/**
 * GO-MAP.CSS - Carte Interactive Guide Online
 * Dark moderne, cohérent avec l'UI existante
 */

/* ============================================
   SECTION CARTE PRINCIPALE
   ============================================ */

.go-map-section-wrapper {
  grid-column: 1 / -1; /* Prend toute la largeur du grid */
  width: 100%;
}

.go-map-section {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  border-radius: 24px;
  padding: 24px;
  margin: 32px 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  position: relative;
}

/* ============================================
   TOOLBAR
   ============================================ */

.go-map-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.go-map-title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
}

.go-map-title i {
  font-size: 24px;
  color: #3b82f6;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
}

.go-map-title h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.go-map-count {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   FILTRES
   ============================================ */

.go-map-filters {
  display: flex;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.go-map-filters::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.go-filter-group {
  display: flex;
  gap: 6px;
}

.go-filter-toggle {
  padding: 8px 16px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  color: #60a5fa;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.go-filter-toggle:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.go-filter-toggle.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.go-filter-toggle i {
  font-size: 14px;
}

/* Bouton fullscreen */
.go-map-fullscreen {
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.go-map-fullscreen:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* ============================================
   CONTENEUR CARTE
   ============================================ */

.go-map-container {
  position: relative;
  height: 56vh;
  min-height: 400px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

#goMap {
  width: 100%;
  height: 100%;
}

/* ============================================
   LÉGENDE
   ============================================ */

.go-map-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.go-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 500;
}

.go-pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.go-pin-exact {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.6),
              inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.go-pin-jitter {
  background: transparent;
  border: 2px solid #a855f7;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

/* ============================================
   LEAFLET CUSTOM (STYLE CLAIR)
   ============================================ */

.leaflet-container {
  background: #e5e7eb;
  font-family: inherit;
}

/* Pas de filtre - laisser les tiles naturelles pour meilleure lisibilité */
.leaflet-tile-pane {
  /* Pas de filtre */
}

/* Controls */
.leaflet-control-zoom a {
  background: rgba(15, 23, 42, 0.9) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(30, 41, 59, 0.95) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* Attribution */
.leaflet-control-attribution {
  background: rgba(15, 23, 42, 0.8) !important;
  color: rgba(255, 255, 255, 0.6) !important;
  font-size: 11px !important;
}

.leaflet-control-attribution a {
  color: #60a5fa !important;
}

/* ============================================
   MARKERS CUSTOM
   ============================================ */

/* Supprimer les ombres Leaflet par défaut qui peuvent apparaître */
.leaflet-marker-shadow {
  display: none !important;
}

.leaflet-marker-icon {
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

.go-custom-marker {
  width: 40px !important;
  height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  transition: all 0.2s ease;
  background-clip: padding-box !important;
  outline: none !important; /* Supprimer outline navigateur */
  -webkit-tap-highlight-color: transparent !important; /* Supprimer highlight iOS */
}

.go-marker-exact {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  border: 3px solid rgba(255, 255, 255, 1) !important; /* Bordure 100% opaque */
  box-shadow: 0 0 20px rgba(59, 130, 246, 1),
              0 6px 16px rgba(0, 0, 0, 0.6) !important;
  color: #ffffff !important;
  font-size: 18px !important;
  opacity: 1 !important; /* Force opacité complète */
}

.go-custom-marker i {
  display: block !important;
  line-height: 1 !important;
}

.go-marker-jitter {
  background: rgba(168, 85, 247, 0.2);
  border: 2px solid #a855f7;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.6),
              0 4px 12px rgba(0, 0, 0, 0.3);
  color: #c084fc;
  font-size: 16px;
}

.go-custom-marker:hover {
  transform: scale(1.2);
  z-index: 1000 !important;
}

/* ============================================
   POPUPS LEAFLET
   ============================================ */

.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 1) !important; /* 100% opaque */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 16px !important;
  padding: 0 !important;
  color: #ffffff !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  padding: 20px !important;
  max-width: 320px !important;
}

.leaflet-popup-tip {
  background: rgba(15, 23, 42, 1) !important; /* 100% opaque */
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.leaflet-popup-close-button {
  color: rgba(255, 255, 255, 0.7) !important;
  font-size: 20px !important;
  font-weight: 300 !important;
  line-height: 1 !important;
  padding: 0 !important;
  width: 28px !important;
  height: 28px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
}

.leaflet-popup-close-button:hover {
  color: #ffffff !important;
  background: rgba(255, 59, 48, 0.9) !important;
  transform: scale(1.1) !important;
}

/* ============================================
   CONTENU POPUP
   ============================================ */

.go-popup-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.go-popup-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.go-popup-title-group {
  flex: 1;
  min-width: 0;
}

.go-popup-name {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  line-height: 1.3;
}

.go-popup-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.go-popup-badge {
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #60a5fa;
}

.go-popup-badge.badge-community {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  color: #fbbf24;
}

.go-popup-badge.badge-discovery {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.go-popup-stats {
  display: flex;
  gap: 16px;
  margin: 12px 0;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

.go-popup-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.go-popup-stat i {
  color: #3b82f6;
  font-size: 14px;
}

/* Message info pour pro mobile */
.go-popup-stat-info {
  width: 100%;
  background: rgba(59, 130, 246, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  font-size: 12px;
}

.go-popup-stat-info i {
  color: #60a5fa;
}

.go-popup-summary {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 16px;
}

.go-popup-cta {
  width: 100%;
  padding: 12px 20px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.go-popup-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5);
}

.go-popup-cta i {
  font-size: 14px;
  transition: transform 0.2s ease;
}

.go-popup-cta:hover i {
  transform: translateX(3px);
}

/* ============================================
   CLUSTER MARKERS
   ============================================ */

.marker-cluster {
  background: rgba(59, 130, 246, 0.2) !important;
  border: 2px solid #3b82f6 !important;
  border-radius: 50% !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.6) !important;
}

.marker-cluster div {
  background: rgba(59, 130, 246, 0.6) !important;
  border-radius: 50% !important;
}

/* ============================================
   FULLSCREEN (API NATIVE)
   ============================================ */

/* Section en mode fullscreen natif */
.go-map-section:fullscreen,
.go-map-section:-webkit-full-screen {
  background: #1a202c;
  padding: 0;
  margin: 0;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  z-index: 999997 !important; /* En dessous des sheets (999999) */
}

.go-map-section.go-map-fullscreen-active {
  display: flex;
  flex-direction: column;
}

/* Toolbar en fullscreen */
.go-map-section:fullscreen .go-map-toolbar,
.go-map-section:-webkit-full-screen .go-map-toolbar,
.go-map-section.go-map-fullscreen-active .go-map-toolbar {
  padding: 16px 24px;
  background: rgba(26, 32, 44, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  margin: 0;
}

/* Container carte en fullscreen */
.go-map-section:fullscreen .go-map-container,
.go-map-section:-webkit-full-screen .go-map-container,
.go-map-section.go-map-fullscreen-active .go-map-container {
  flex: 1;
  height: 100% !important; /* Force 100% de hauteur */
  border-radius: 0;
  border: none;
  margin: 0;
  min-height: 0;
}

/* La div #goMap doit aussi prendre 100% */
.go-map-section:fullscreen #goMap,
.go-map-section:-webkit-full-screen #goMap,
.go-map-section.go-map-fullscreen-active #goMap {
  height: 100% !important;
  width: 100% !important;
}

/* Masquer la légende en fullscreen pour plus d'espace */
.go-map-section:fullscreen .go-map-legend,
.go-map-section:-webkit-full-screen .go-map-legend {
  display: none;
}

/* ============================================
   RESPONSIVE MOBILE
   ============================================ */

@media (max-width: 767px) {
  .go-map-section-wrapper {
    margin: 24px 0; /* Pas de marge négative pour éviter débordement */
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .go-map-section {
    padding: 12px;
    margin: 0;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .go-map-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .go-map-title {
    width: 100%;
  }

  .go-map-filters {
    width: 100%;
    padding-bottom: 8px;
  }

  .go-map-fullscreen {
    width: 100%;
    justify-content: center;
  }

  .go-map-container {
    height: 60vh;
    min-height: 300px;
    border-radius: 12px;
  }

  /* MARKERS MOBILE - Plus gros et plus visibles */
  .go-custom-marker {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    font-size: 22px !important;
    aspect-ratio: 1 / 1 !important; /* Force ratio carré */
    will-change: transform !important; /* Optimiser les transforms */
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
  }

  .go-marker-exact {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important; /* Force gradient bleu */
    border: 4px solid rgba(255, 255, 255, 1) !important;
    box-shadow: 0 0 24px rgba(59, 130, 246, 1),
                0 8px 20px rgba(0, 0, 0, 0.5) !important;
    opacity: 1 !important;
  }

  /* Bloquer les icônes internes aussi */
  .go-custom-marker i {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* CLUSTERS MOBILE - Forcer forme ronde */
  .marker-cluster {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    aspect-ratio: 1 / 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
  }

  .marker-cluster div {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    max-width: 38px !important;
    max-height: 38px !important;
    aspect-ratio: 1 / 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .marker-cluster div span {
    font-size: 16px !important;
    line-height: 1 !important;
  }

  /* POPUPS MOBILE - Styling complet avec spécificité maximale */
  #goMap .leaflet-popup,
  .leaflet-container .leaflet-popup {
    pointer-events: auto !important;
  }

  #goMap .leaflet-popup-content-wrapper,
  .leaflet-container .leaflet-popup-content-wrapper {
    max-width: 90vw !important;
    pointer-events: auto !important;
    background-color: #0f172a !important; /* Background SOLIDE */
    background: #0f172a !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-radius: 16px !important; /* Border radius */
    border: 1px solid rgba(255, 255, 255, 0.1) !important; /* Bordure subtile */
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8) !important; /* Shadow forte */
    overflow: hidden !important; /* Pour que le border-radius fonctionne */
  }

  #goMap .leaflet-popup-tip,
  .leaflet-container .leaflet-popup-tip {
    background: #0f172a !important;
    background-color: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
  }

  #goMap .leaflet-popup-content,
  .leaflet-container .leaflet-popup-content {
    padding: 16px !important;
    max-width: calc(90vw - 32px) !important;
    min-width: 280px !important;
    pointer-events: auto !important;
    background: transparent !important; /* Transparent car wrapper a déjà le background */
    background-color: transparent !important;
    color: #ffffff !important;
  }

  /* Empêcher le close automatique au tap */
  .leaflet-container {
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
  }

  #goMap .leaflet-popup-close-button,
  .leaflet-container .leaflet-popup-close-button {
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 22px !important;
    font-weight: 300 !important;
    line-height: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 36px !important; /* Plus gros sur mobile pour toucher facilement */
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
  }

  #goMap .leaflet-popup-close-button:active,
  .leaflet-container .leaflet-popup-close-button:active {
    color: #ffffff !important;
    background: rgba(255, 59, 48, 0.9) !important;
    background-color: rgba(255, 59, 48, 0.9) !important;
    transform: scale(1.1) !important;
  }

  .go-popup-header {
    gap: 10px;
  }

  .go-popup-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .go-popup-name {
    font-size: 16px;
  }

  .go-popup-stats {
    gap: 12px;
    font-size: 12px;
  }

  .go-popup-cta {
    padding: 14px 20px !important;
    font-size: 16px !important;
    min-height: 48px !important;
  }

  /* Fullscreen mobile: même comportement que desktop */
  #goMapFullscreenOverlay {
    z-index: 999999;
  }

  #goMapFullscreenOverlay .go-map-toolbar {
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .go-map-title h3 {
    font-size: 18px;
  }

  .go-map-count {
    font-size: 12px;
    padding: 3px 10px;
  }

  .go-filter-toggle {
    font-size: 13px;
    padding: 6px 12px;
  }

  .go-map-container {
    height: 50vh;
    min-height: 280px;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes marker-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.go-custom-marker.pulse {
  animation: marker-pulse 2s ease-in-out infinite;
}

/* Loading state */
.go-map-loading {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  border-radius: 16px;
}

.go-map-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.go-map-loading-text {
  position: absolute;
  top: 60%;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 500;
}
