/* 
  VISTA MAPA - QuVi 
  Exploración por Red de Prestadores
*/

:root {
  /* QuVi Brand Canon (OKLCH para máxima vibrancia) */
  --map-bg: #0f172a;
  --map-glass: rgba(15, 23, 42, 0.82);
  --map-text: #ffffff;
  --map-subtext: rgba(255, 255, 255, 0.7);
  --map-accent: oklch(0.62 0.19 252);
  /* Azul QuVi Real */
  --map-accent-glow: color-mix(in oklch, var(--map-accent) 40%, transparent);
  --map-border: rgba(255, 255, 255, 0.1);
}

/* MODO CLARO (LIGHT THEME) */
.qv-map-explorer.light-theme {
  --map-bg: #f8fafc;
  --map-glass: rgba(255, 255, 255, 0.88);
  --map-text: #0b1220;
  --map-subtext: #475569;
  --map-border: rgba(15, 111, 232, 0.1);
  --map-accent: oklch(0.62 0.19 252);
}

/* Efecto Sonar Scan al abrir */
.qv-map-scan {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--map-accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  animation: qvSonarScan 3s ease-out forwards;
}

@keyframes qvSonarScan {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
    border: 2px solid var(--map-accent);
  }

  100% {
    width: 200vw;
    height: 200vw;
    opacity: 0;
    border: 10px solid var(--map-accent);
  }
}

.qv-map-explorer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--map-bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.qv-map-explorer.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* El contenedor del mapa Mapbox */
#mapbox-container {
  flex: 1;
  width: 100%;
  height: 100%;
}

/* Header flotante */
.map-header {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: min(95%, 500px);
  /* Mucho más contenido y elegante */
  padding: 8px 16px;
  background: var(--map-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--map-border);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.map-brand-overlay {
  position: absolute;
  top: 25px;
  left: 35px;
  /* Un pelín más hacia adentro */
  z-index: 100;
  pointer-events: none;
}

.map-brand-img {
  height: 32px;
  width: auto;
  filter: none;
  /* Eliminamos la sombra */
  transition: transform 0.3s ease;
  pointer-events: auto;
}

.map-brand-img:hover {
  transform: scale(1.05);
}

.map-header h2 {
  margin: 0;
  color: var(--map-text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Marcadores personalizados Pro */
.qv-marker {
  width: 20px !important;
  height: 20px !important;
  background: var(--map-accent) !important;
  border: 2px solid #fff !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
  transition: width 0.2s ease, height 0.2s ease, background 0.2s ease !important;
  z-index: 10;
}

/* Pulso mediante pseudo-elemento */
.qv-marker::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
}

/* Todos los marcadores de clínica son iguales — sin jerarquía visual */

@keyframes qvPulseGold {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(245, 158, 11, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

@keyframes qvPulseBlue {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }

  70% {
    box-shadow: 0 0 0 12px rgba(59, 130, 246, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.qv-marker:hover {
  width: 32px !important;
  height: 32px !important;
  background: #fff !important;
  z-index: 100 !important;
}

/* Buscador en el Mapa */
#map-explorer .map-search-wrap {
  flex: 1;
  margin: 0 15px;
  position: relative;
  max-width: 320px;
}

#map-explorer .map-search-input {
  width: 100% !important;
  background: var(--map-glass) !important;
  border: 1px solid var(--map-border) !important;
  border-radius: 99px !important;
  padding: 10px 16px 10px 40px !important;
  color: var(--map-text) !important;
  font-size: 14px !important;
  height: 40px !important;
  outline: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.map-search-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--map-accent);
}

.map-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--map-subtext);
  pointer-events: none;
}

/* Search visual states */
#map-explorer .map-search-input.search-no-results {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

#map-explorer .map-search-input.search-has-results {
  border-color: oklch(0.62 0.19 252) !important;
  box-shadow: 0 0 0 3px rgba(15, 111, 232, 0.15) !important;
}

/* Empty state when no plans match the clinic */
.map-plans-empty {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  color: var(--map-subtext);
}

.light-theme .map-plans-empty {
  background: #f8fafc;
  border-color: rgba(15, 111, 232, 0.08);
}

.map-plans-empty__title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--map-text);
}

.map-plans-empty__sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--map-subtext);
}

/* Controles de Mapa (Movidos hacia adentro) */
.map-controls {
  position: absolute;
  top: 50%;
  right: 25px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
}

.map-ctrl-btn {
  width: 40px;
  height: 40px;
  background: var(--map-glass);
  border: 1px solid var(--map-border);
  border-radius: 12px;
  color: var(--map-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.map-ctrl-btn:hover {
  background: var(--map-accent);
  border-color: #fff;
  color: #fff;
  /* Icono blanco en hover */
  transform: translateX(-4px);
}

.map-ctrl-btn.is-active:not(#btnMapHeatmap) {
  background: var(--map-accent);
  color: #fff;
  box-shadow: 0 0 20px var(--map-accent-glow);
  border-color: rgba(255, 255, 255, 0.4);
}

#btnMapHeatmap.is-active {
  background: linear-gradient(to bottom, #991b1b 0%, #f97316 50%, #facc15 100%);
  color: #fff;
  border: none;
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.7);
}

.clinic-card {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translate(-50%, 110%);
  width: 90%;
  max-width: 1000px;
  max-height: 40vh;
  background: var(--map-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--map-border);
  border-radius: 24px;
  padding: 24px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  overflow: hidden;
}

.clinic-card.is-visible {
  transform: translate(-50%, 0);
}

.clinic-info {
  border-right: 1px solid var(--map-border);
  /* Separador dinámico */
  padding-right: 20px;
}

.clinic-logo {
  width: 64px;
  height: 64px;
  background: transparent;
  /* Sin relleno */
  border: 2px solid var(--map-accent);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.clinic-name {
  color: var(--map-text);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.clinic-desc {
  color: var(--map-subtext);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.clinic-address {
  margin-top: 0px;
  margin-bottom: 0px;
  color: var(--map-accent);
  /* Azul QuVi Canon */
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  /* Alineado al inicio */
  gap: 8px;
  opacity: 1;
}

.clinic-address::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 3px;
  /* Ajuste fino para centrar con la primera línea */
  /* SVG actualizado con el azul canon %230f6fe8 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%230f6fe8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z'%3E%3C/path%3E%3Ccircle cx='12' cy='10' r='3'%3E%3C/circle%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.clinic-distance {
  margin-top: 8px;
  margin-bottom: 0px;
  color: var(--map-subtext);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  /* Alineado al inicio */
  opacity: 1;
}

.clinic-distance::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-right: 8px;
  /* Separación explícita */
  margin-top: 3px;
  /* Ajuste fino para centrar con la primera línea */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Grid de planes dentro de la tarjeta */
.map-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.map-plan-mini {
  background: rgba(255, 255, 255, 0.05);
  /* Cristal base */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Elevación pro en modo claro */
.light-theme .map-plan-mini {
  background: #ffffff;
  border: 1px solid rgba(15, 111, 232, 0.08);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.map-plan-mini:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--map-accent);
  transform: translateY(-8px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

.light-theme .map-plan-mini:hover {
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

.map-plan-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  width: 100%;
}

.map-plan-logo {
  height: 22px;
  max-width: 100px;
  object-fit: contain;
  filter: none;
  /* Sombra eliminada */
}

.map-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--map-accent);
  color: #fff;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-top: 4px;
  /* Un pelín pelín más abajo */
}

.map-plan-badge .badge-icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.map-plan-name {
  color: var(--map-text);
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.map-plan-coverage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 14px;
}

.cov-box {
  background: var(--map-border);
  border: 1px solid var(--map-border);
  border-radius: 12px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.2s ease;
}

.cov-box i,
.cov-box [data-lucide] {
  width: 15px !important;
  height: 15px !important;
  margin-bottom: 3px !important;
  color: #fff !important;
  /* Blanco en modo oscuro */
  stroke: #fff !important;
  opacity: 1 !important;
}

.light-theme .cov-box i,
.light-theme .cov-box [data-lucide] {
  color: var(--map-accent) !important;
  stroke: var(--map-accent) !important;
}

.cov-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--map-text);
}

.cov-lab {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--map-subtext);
}

/* Hover en .cov-box eliminado */

.map-plan-price {
  color: var(--map-accent);
  font-size: 16px;
  font-weight: 700;
}

/* Botón cerrar vista mapa */
.map-close {
  background: var(--map-border);
  border: 0;
  color: var(--map-text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

@media (max-width: 768px) {
  .clinic-card {
    grid-template-columns: 1fr;
    max-height: 60vh;
    overflow-y: auto;
  }

  .clinic-info {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 16px;
    padding-right: 0;
  }
}

/* TOOLTIPS MAPA */
.qv-map-tooltip {
  z-index: 3000 !important;
  pointer-events: none;
}

.qv-map-tooltip .mapboxgl-popup-content {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.qv-map-tooltip .mapboxgl-popup-tip {
  border-top-color: rgba(15, 23, 42, 0.95) !important;
}

.map-tooltip-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-tooltip-content strong {
  color: var(--map-accent);
  font-weight: 700;
}

.map-heat-legend {
  position: absolute;
  bottom: 40px;
  /* Centrado abajo, separado del borde */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 22px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 12px;
  color: #fff;
  z-index: 1000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: mapLegendFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  cursor: default;
}

/* Tooltip Custom para todo el Badge */
.map-heat-legend::before {
  content: "Este radar muestra dónde tus planes te protegen mejor: los puntos más brillantes indican mayor cobertura y ahorro real en esa clínica.";
  position: absolute;
  bottom: calc(100% + 18px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: 300px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.5;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  font-weight: 400;
}

.map-heat-legend:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.map-heat-legend::after {
  content: "";
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.95);
  opacity: 0;
  transition: all 0.3s ease;
}

.map-heat-legend:hover::after {
  opacity: 1;
}

/* Tooltip Custom para la barra */
.heat-bar {
  position: relative;
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #7f1d1d, #92400e, #ea580c, #facc15, #fff);
  box-shadow: 0 0 10px rgba(234, 88, 12, 0.4);
}

/* Eliminar antiguos estilos de tooltip en heat-bar si quedaban */
.heat-bar::before,
.heat-bar::after {
  display: none !important;
}

@keyframes mapLegendFadeUp {
  from {
    opacity: 0;
    transform: translate(-50%, 15px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.btn-map-route {
  margin-top: 16px;
  background: var(--map-accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--map-accent-glow);
}

.btn-map-route:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--map-accent-glow);
  background: #fff;
  color: var(--map-accent);
}

.btn-map-route i {
  width: 16px;
  height: 16px;
}