/* public/css/survey-map.css */

.survey-map-card {
  position: relative;
  overflow: hidden;
  background-color: #ffffff;
  transition: box-shadow 0.2s ease-in-out;
}

.map-container-wrapper {
  position: relative;
  width: 100%;
  height: 480px;
  min-height: 380px;
  background-color: #e9ecef;
  border-radius: 0.75rem;
  overflow: hidden;
}

@media (max-width: 768px) {
  .map-container-wrapper {
    height: 380px;
    min-height: 320px;
  }
}

#mapa-coropletico {
  width: 100%;
  height: 100%;
}

/* Spinner y Overlay de Carga */
.map-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease-in-out;
}

.map-loading-overlay.d-none {
  display: none !important;
}

/* Fallback de error */
.map-error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

/* Leyenda Cartográfica Flotante */
.map-legend-box {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
  z-index: 5;
  max-width: 280px;
  font-size: 0.8125rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.legend-color-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.legend-color-item:last-child {
  margin-bottom: 0;
}

.legend-color-badge {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* Botón de Control Cartográfico Personalizado */
.map-custom-controls {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-map-control {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #333333;
  transition: all 0.15s ease-in-out;
}

.btn-map-control:hover {
  background: #f8f9fa;
  color: #0d6efd;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

/* Estilos de Tooltips Flotantes Simplificados en Hover */
.maplibregl-popup {
  z-index: 20;
  pointer-events: none; /* No interceptar el puntero para fluidez total */
}

.maplibregl-popup-content {
  padding: 0.6rem 0.85rem;
  border-radius: 0.6rem;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(4px);
}

.map-tooltip-box {
  min-width: 150px;
  line-height: 1.35;
}

.map-tooltip-title {
  font-weight: 700;
  font-size: 0.875rem;
  color: #1a1e21;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.map-tooltip-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.45rem;
  border-radius: 0.35rem;
  font-size: 0.775rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.map-tooltip-votes {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Adaptabilidad móvil para la leyenda */
@media (max-width: 576px) {
  .map-legend-box {
    bottom: 0.5rem;
    left: 0.5rem;
    padding: 0.5rem 0.75rem;
    max-width: 200px;
    font-size: 0.725rem;
  }
  
  .legend-color-badge {
    width: 10px;
    height: 10px;
  }

  .map-custom-controls {
    top: 0.5rem;
    left: 0.5rem;
  }

  .btn-map-control {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }
}
