/**
 * mapa.css — Estilos del Mapa Histórico Mundial
 * Enciclopedia Digital
 */

/* ─── Contenedor principal del mapa ─────────────────────── */
.mapa-contenedor {
  height: calc(100vh - 130px);
  min-height: 400px;
  position: relative;
}

/* ─── Panel lateral de eventos ──────────────────────────── */
.mapa-panel-lateral {
  height: calc(100vh - 130px);
  min-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255,255,255,0.1);
  background: #1e2a3a;
  color: #e8eef4;
}

/* ─── Items de la lista lateral ─────────────────────────── */
.mapa-evento-item {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  animation: fadeInItem 0.3s ease forwards;
  opacity: 0;
}

.mapa-evento-item:hover {
  background: rgba(255,255,255,0.08);
  transform: translateX(2px);
}

.mapa-evento-item.activo {
  background: rgba(13, 110, 253, 0.25);
  border-left: 3px solid #4da6ff;
}

.mapa-evento-item .evento-titulo {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.25rem;
  color: #ffffff;
}

.mapa-evento-item .evento-meta {
  font-size: 0.72rem;
  color: #a8c0d6;
}

/* ─── Animación de entrada para items ───────────────────── */
@keyframes fadeInItem {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Delay escalonado para los primeros 10 items */
.mapa-evento-item:nth-child(1)  { animation-delay: 0.00s; }
.mapa-evento-item:nth-child(2)  { animation-delay: 0.04s; }
.mapa-evento-item:nth-child(3)  { animation-delay: 0.08s; }
.mapa-evento-item:nth-child(4)  { animation-delay: 0.12s; }
.mapa-evento-item:nth-child(5)  { animation-delay: 0.16s; }
.mapa-evento-item:nth-child(6)  { animation-delay: 0.20s; }
.mapa-evento-item:nth-child(7)  { animation-delay: 0.24s; }
.mapa-evento-item:nth-child(8)  { animation-delay: 0.28s; }
.mapa-evento-item:nth-child(9)  { animation-delay: 0.32s; }
.mapa-evento-item:nth-child(10) { animation-delay: 0.36s; }

/* ─── Marcadores personalizados ─────────────────────────── */
.marcador-era-precambrico  { background-color: #8B4513; }
.marcador-era-paleozoico   { background-color: #228B22; }
.marcador-era-mesozoico    { background-color: #006400; }
.marcador-era-cenozoico    { background-color: #DAA520; }
.marcador-era-paleolitico  { background-color: #8B7355; }
.marcador-era-neolitico    { background-color: #A0522D; }
.marcador-era-antiguedad   { background-color: #C0392B; }
.marcador-era-media        { background-color: #8E44AD; }
.marcador-era-moderna      { background-color: #2980B9; }
.marcador-era-contemporanea{ background-color: #27AE60; }

/* ─── Marcador de importancia mundial (pulso) ────────────── */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.7);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(13, 110, 253, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0);
    transform: scale(1);
  }
}

.marcador-importancia-mundial {
  animation: pulse 2s infinite;
}

/* ─── Marcadores DivIcon base ────────────────────────────── */
.mapa-marcador-div {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.mapa-marcador-div:hover {
  transform: rotate(-45deg) scale(1.2);
}

.mapa-marcador-div .marcador-icono {
  transform: rotate(45deg);
  font-size: 11px;
  color: #fff;
}

/* ─── Popups del mapa Leaflet ────────────────────────────── */
.leaflet-popup-content {
  max-width: 280px;
  min-width: 200px;
  font-size: 0.85rem;
  color: #212529;
}

.leaflet-popup-content .popup-titulo {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  line-height: 1.3;
  color: #111827;
}

.leaflet-popup-content .popup-anio {
  font-size: 0.78rem;
  color: #6c757d;
  margin-bottom: 0.3rem;
}

.leaflet-popup-content .popup-desc {
  font-size: 0.8rem;
  color: #374151;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.leaflet-popup-content .popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

/* Botón Ver más — texto blanco visible siempre */
.leaflet-popup-content a.btn {
  color: #ffffff !important;
  background-color: #1a56db !important;
  border: none !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}
.leaflet-popup-content a.btn:hover {
  background-color: #1344b0 !important;
  color: #ffffff !important;
}

/* ─── Barra de filtros superior ─────────────────────────── */
.mapa-filtros-bar {
  padding: 0.5rem 0.75rem;
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.375rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.mapa-filtros-bar .form-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--bs-secondary-color, #6c757d);
}

/* ─── Barra de estadísticas ──────────────────────────────── */
.mapa-stats-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.82rem;
}

/* ─── Contador de eventos ────────────────────────────────── */
#mapa-contador-eventos {
  font-size: 0.78rem;
  color: #a8c0d6;
}

/* ─── Slider de línea de tiempo ──────────────────────────── */
.timeline-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #0d6efd, #dee2e6);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0d6efd;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.15s;
}

.timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.timeline-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0d6efd;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ─── Badge de era ───────────────────────────────────────── */
.era-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ─── Mini mapa de formularios ───────────────────────────── */
#mapa-seleccion-coords {
  height: 350px;
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
}

#mini-mapa-evento {
  height: 300px;
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
}

#mini-mapa-home {
  height: 250px;
  width: 100%;
  border-radius: 0.375rem;
  border: none;
}

/* ─── Mapa de rutas ──────────────────────────────────────── */
#mapa-ruta-editor {
  height: 400px;
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
}

/* ─── Tarjeta de evento relacionado ─────────────────────── */
.evento-relacionado-card {
  transition: box-shadow 0.2s, transform 0.15s;
}

.evento-relacionado-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

/* ─── Media queries ──────────────────────────────────────── */
@media (max-width: 991.98px) {
  /* En móvil/tablet: panel lateral pasa a debajo del mapa */
  .mapa-panel-lateral {
    height: auto;
    max-height: 300px;
    border-right: none;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    order: 2;
  }

  #mapa-mundial {
    order: 1;
    min-height: 350px;
  }

  .mapa-filtros-bar .row {
    flex-wrap: wrap;
  }

  .mapa-filtros-bar .col-auto {
    flex: 1 1 auto;
    min-width: 130px;
  }
}

@media (max-width: 575.98px) {
  .mapa-filtros-bar {
    padding: 0.4rem;
  }

  .leaflet-popup-content {
    max-width: 220px;
    min-width: 160px;
  }
}

/* ─── Estado de carga ────────────────────────────────────── */
.mapa-loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 0.375rem;
}

/* ─── Leyenda del mapa ───────────────────────────────────── */
.mapa-leyenda {
  background: rgba(255,255,255,0.92);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  max-width: 180px;
}

.mapa-leyenda .leyenda-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.mapa-leyenda .leyenda-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Mapa offline: fondo oceánico ───────────────────────── */
.leaflet-container {
  background: #1a3a5c !important;
}

/* ─── Tooltip de nombre de país ─────────────────────────── */
.pais-tooltip {
  background: rgba(0, 0, 0, 0.75);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.pais-tooltip::before {
  display: none;
}

/* ─── Marcador SVG inline (offline) ─────────────────────── */
.mapa-marcador-svg {
  display: block;
  line-height: 0;
  cursor: pointer;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  transition: transform 0.2s ease;
}

.mapa-marcador-svg:hover {
  transform: scale(1.15);
}

.mapa-marcador-svg.marcador-importancia-mundial {
  animation: pulse 2s infinite;
}

/* ─── Leyenda de continentes ─────────────────────────────── */
.leaflet-control.mapa-leyenda-continentes {
  background: #1e2a3a !important;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.78rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  max-width: 170px;
  line-height: 1.7;
  color: #f0f4f8 !important;
}

.mapa-leyenda-continentes h6 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #ffffff !important;
  margin: 0 0 7px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255,255,255,0.25);
}

.mapa-leyenda-continentes .leyenda-cont-item {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: #e8eef4 !important;
  font-weight: 500;
}

.mapa-leyenda-continentes .leyenda-cont-color {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.35);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ─── Hover sobre países del GeoJSON ─────────────────────── */
.leaflet-interactive:focus {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

/* ─── Input búsqueda dentro del panel lateral ───────────── */
#mapa-busqueda-local {
  background: rgba(255,255,255,0.1) !important;
  border-color: rgba(255,255,255,0.2) !important;
  color: #ffffff !important;
}
#mapa-busqueda-local::placeholder {
  color: rgba(255,255,255,0.45);
}
#mapa-busqueda-local:focus {
  background: rgba(255,255,255,0.15) !important;
  border-color: #4da6ff !important;
  box-shadow: 0 0 0 0.2rem rgba(77,166,255,0.25);
  color: #ffffff !important;
}

/* ─── Cabecera del panel lateral ────────────────────────── */
.mapa-panel-lateral .p-2 {
  background: #162130;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* ── Notificaciones flotantes del mapa ───────────────────── */
.mapa-notificacion {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 2000;
  animation: slideUp 0.3s ease, fadeOut 0.5s ease 3.5s forwards;
  white-space: nowrap;
  pointer-events: none;
}
.mapa-notif-success { background: #27ae60; color: #fff; }
.mapa-notif-warning { background: #f39c12; color: #fff; }
.mapa-notif-info    { background: #2980b9; color: #fff; }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes fadeOut {
  to { opacity: 0; }
}

/* ── Cursor crosshair en mapa de selección de coords ─────── */
.mapa-selector-coords .leaflet-container {
  cursor: crosshair !important;
}

/* ── FEAT-Q: Panel de línea de tiempo mejorada ─────────────────────── */
.mapa-timeline-panel {
  background: #1e2a3a;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: #e8eef4;
}
.mapa-timeline-panel .form-range::-webkit-slider-thumb {
  background: #4da6ff;
}
.mapa-timeline-panel .badge {
  font-size: .85rem;
}
.tl-eras-marcadores {
  position: relative;
  display: flex;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.4);
  padding-top: 2px;
  height: 1.2rem;
  overflow: hidden;
}
