/* Contenedor del mapa */

#map-container {
  width: 100%;
  height: calc(100vh - 200px);
  position: relative;
  z-index: 1;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-surface);
  z-index: 1;
}

/* Filtros - reutiliza variables del tema */
.map-filters {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 500;
  background: var(--bg-elevated);
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: calc(100% - 20px);
}

.map-filters select {
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 0.875rem;
}

/* Popups de eventos */
.event-popup {
  min-width: 200px;
}

.event-popup img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.event-popup h6 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a1a;
}

.event-popup p {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: #4a4a4a;
}

.event-popup a {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: #3a3a3a;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s;
}

.event-popup a:hover {
  background: #4a4a4a;
}

/* Clusters de marcadores - usa variables del tema */
.marker-cluster-small { background-color: rgba(36, 36, 36, 0.6) !important; }
.marker-cluster-small div { background-color: var(--bg-elevated) !important; }
.marker-cluster-medium { background-color: rgba(26, 26, 26, 0.6) !important; }
.marker-cluster-medium div { background-color: var(--bg-surface) !important; }
.marker-cluster-large { background-color: rgba(18, 18, 18, 0.6) !important; }
.marker-cluster-large div { background-color: var(--bg-base) !important; }

.marker-cluster {
  border-radius: 50% !important;
}

.marker-cluster div {
  border-radius: 50% !important;
  color: var(--text-primary) !important;
  font-weight: 600 !important;
  text-align: center !important;
  font-size: 14px !important;
}

/* Controles de zoom - tema dark */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-control-zoom a {
  background-color: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 20px !important;
  font-weight: bold !important;
}

.leaflet-control-zoom a:hover {
  background-color: var(--bg-surface) !important;
}

.leaflet-control-zoom a:first-child {
  border-top-left-radius: 6px !important;
  border-top-right-radius: 6px !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom-left-radius: 6px !important;
  border-bottom-right-radius: 6px !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  text-shadow: none !important;
}

/* Loading indicator */
.map-loading {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: var(--bg-elevated);
  padding: 0.75rem 1.5rem;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  display: none;
  color: var(--text-primary);
}

.map-loading.active {
  display: block;
}

/* Lista flotante de eventos - Reutiliza clases de tds2026.css */
.map-events-list {
  position: absolute;
  top: 140px; /* Debajo del filtro de deporte */
  left: 10px;
  z-index: 500;
  background: var(--bg-elevated);
  border-radius: 12px; /* Mismo que .event-card */
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  width: 320px;
  max-width: calc(100% - 20px);
  max-height: calc(100% - 160px); /* Se adapta al contenedor dejando margen inferior */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.events-list-header {
  padding: 0.85rem; /* Mismo que .event-body */
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.events-list-header h6 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.events-list-body {
  overflow-y: auto;
  max-height: calc(100% - 60px); /* Resta la altura del header */
  padding: 0.5rem;
}

/* Items de la lista - Similar a .event-card pero más compacto */
.map-event-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-base);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); /* Mismo easing que .event-card */
}

.map-event-item:hover {
  background: var(--bg-surface);
  border-color: var(--border);
  transform: translateX(2px);
}

.map-event-item:last-child {
  margin-bottom: 0;
}

.map-event-content {
  flex: 1;
  min-width: 0;
}

/* Reutiliza estilos existentes */
.map-event-item .event-name {
  /* Ya definido en tds2026.css - font-size: 0.95rem; font-weight: 600; */
  margin: 0 0 0.25rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-event-item .event-location {
  /* Ya definido en tds2026.css - display: flex; align-items: center; gap: 0.3rem; */
  margin: 0;
  font-size: 0.75rem;
}

.map-event-link {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3a3a3a;
  border: 1px solid #555;
  color: #ddd;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s;
}

.map-event-link:hover {
  background: #4a4a4a;
  border-color: #666;
}

/* Estado vacío */
.events-list-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
}

.events-list-empty i {
  font-size: 2.5rem;
  opacity: 0.3;
  margin-bottom: 0.5rem;
}

.events-list-empty p {
  margin: 0;
  font-size: 0.875rem;
}

/* Scrollbar personalizado */
.events-list-body::-webkit-scrollbar {
  width: 6px;
}

.events-list-body::-webkit-scrollbar-track {
  background: var(--bg-elevated);
}

.events-list-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.events-list-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.5), rgba(59, 130, 246, 0.5));
}

/* Tablet (576px - 768px) */
@media (max-width: 768px) and (min-width: 576px) {
  #map-container {
    height: calc(100vh - 180px);
  }

  .map-filters {
    top: 10px;
    left: 10px;
    right: auto;
    max-width: calc(100% - 100px);
    flex-direction: column;
  }

  .map-filters select {
    width: 100%;
    min-width: 180px;
  }

  .map-events-list {
    top: auto;
    bottom: 20px;
    left: 10px;
    right: auto;
    width: 70%;
    max-width: none;
    max-height: 25vh;
  }

  .events-list-body {
    max-height: calc(25vh - 60px);
  }
}

/* Mobile (<576px) */
@media (max-width: 575px) {
  #map-container {
    height: calc(100vh - 180px);
  }

  .map-filters {
    top: 10px;
    left: 10px;
    right: auto;
    max-width: calc(100% - 100px);
    flex-direction: column;
  }

  .map-filters select {
    width: 100%;
    min-width: 180px;
  }

  .map-events-list {
    top: auto;
    bottom: 20px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    max-height: 20vh;
  }

  .events-list-body {
    max-height: calc(20vh - 60px);
  }
}

/* Custom purple markers for events */
.custom-map-marker {
  background: transparent;
  border: none;
}

.custom-map-marker .marker-dot {
  width: 20px;
  height: 20px;
  background: #7c3aed;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: all 0.2s;
}

.custom-map-marker .marker-dot:hover {
  transform: scale(1.2);
  background: #6d28d9;
}
