/* ==========================================================================
   VARIABLES DE DISEÑO - PALETA MONTAÑERA Y NATURALEZA
   ========================================================================== */
:root {
  --color-bosque-oscuro: #14532d;
  --color-bosque: #15803d;
  --color-bosque-hover: #166534;
  --color-acento-tierra: #d97706;
  --color-strava: #fc4c02;
  --color-wikiloc: #359830;
  --color-fondo: #f8fafc;
  --color-blanco: #ffffff;
  --color-texto: #0f172a;
  --color-texto-suave: #64748b;
  --color-borde: #e2e8f0;
  
  /* Etiquetas de Dificultad */
  --badge-facil-bg: #dcfce7;
  --badge-facil-texto: #15803d;
  --badge-moderada-bg: #fef3c7;
  --badge-moderada-texto: #b45309;
  --badge-exigente-bg: #fee2e2;
  --badge-exigente-texto: #b91c1c;

  --sombra-tarjeta: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --sombra-hover: 0 12px 20px -3px rgba(0, 0, 0, 0.12);
  --radio-borde: 14px;
  --radio-pequeno: 8px;
  --transicion: all 0.25s ease-in-out;
}

/* Reset y tipografía global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--color-texto);
  background-color: var(--color-fondo);
}

body {
  line-height: 1.6;
}

.contenedor {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
}

/* ==========================================================================
   BARRA DE NAVEGACIÓN
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-borde);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-bosque-oscuro);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  list-style: none;
  align-items: center;
  gap: 1.8rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--color-texto);
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transicion);
}

.nav-links a:hover {
  color: var(--color-bosque);
}

.btn-nav {
  background-color: var(--color-bosque);
  color: var(--color-blanco) !important;
  padding: 0.5rem 1rem;
  border-radius: var(--radio-pequeno);
}

.btn-nav:hover {
  background-color: var(--color-bosque-hover);
  transform: translateY(-1px);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
}

/* ==========================================================================
   SECCIÓN HERO / PORTADA
   ========================================================================== */
.hero {
  position: relative;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 1.5rem;
  background: linear-gradient(135deg, rgba(20, 83, 45, 0.92) 0%, rgba(15, 23, 42, 0.92) 100%),
              url('https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?auto=format&fit=crop&w=1600&q=80') center/cover no-repeat;
  color: var(--color-blanco);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 780px;
}

.badge-aventura {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.35rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 1.2rem;
}

.badge-pill {
  display: inline-block;
  background: #dcfce7;
  color: var(--color-bosque-oscuro);
  border: 1px solid #bbf7d0;
  padding: 0.3rem 0.9rem;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1.2rem;
}

.hero p {
  font-size: 1.25rem;
  color: #e2e8f0;
  margin-bottom: 2.2rem;
  font-weight: 300;
}

.hero-acciones {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Botones universales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.8rem;
  border-radius: var(--radio-pequeno);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: var(--transicion);
}

.btn-primario {
  background-color: var(--color-bosque);
  color: white;
}

.btn-primario:hover {
  background-color: var(--color-bosque-hover);
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.4);
}

.btn-secundario {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(5px);
}

.btn-secundario:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-ancho {
  width: 100%;
  margin-top: 1rem;
}

/* ==========================================================================
   ESTADÍSTICAS RÁPIDAS
   ========================================================================== */
.seccion-stats {
  margin-top: -3.5rem;
  position: relative;
  z-index: 10;
  margin-bottom: 3rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  background: var(--color-blanco);
  padding: 1.8rem;
  border-radius: var(--radio-borde);
  box-shadow: var(--sombra-tarjeta);
  border: 1px solid var(--color-borde);
  text-align: center;
}

.stat-numero {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-bosque);
}

.stat-etiqueta {
  font-size: 0.9rem;
  color: var(--color-texto-suave);
  font-weight: 600;
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   SECCIÓN MAPA INTERACTIVO (LEAFLET + OPENSTREETMAP)
   ========================================================================== */
.mapa-marco {
  background: var(--color-blanco);
  border-radius: var(--radio-borde);
  padding: 0.8rem;
  box-shadow: var(--sombra-tarjeta);
  border: 1px solid var(--color-borde);
}

.mapa-elemento {
  width: 100%;
  height: 480px;
  border-radius: calc(var(--radio-borde) - 4px);
  z-index: 10;
}

.mapa-leyenda {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-texto-suave);
}

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

.punto-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.punto-color.verde { background-color: #16a34a; }
.punto-color.naranja { background-color: #f59e0b; }
.punto-color.rojo { background-color: #dc2626; }

.mapa-ayuda {
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  color: var(--color-texto-suave);
  background-color: #f8fafc;
  border-top: 1px solid var(--color-borde);
  margin-top: 0.8rem;
  border-radius: var(--radio-pequeno);
}

/* Popups de Leaflet */
.leaflet-popup-content-wrapper {
  border-radius: var(--radio-pequeno);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  padding: 0.4rem;
}

.popup-contenido {
  font-family: inherit;
  min-width: 200px;
}

.popup-titulo {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.3rem;
}

.popup-ubicacion {
  font-size: 0.8rem;
  color: var(--color-bosque);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.popup-stats {
  display: flex;
  gap: 0.8rem;
  background: #f1f5f9;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

/* ==========================================================================
   SECCIÓN RUTAS Y FILTROS
   ========================================================================== */
.seccion {
  padding: 4rem 0;
}

.seccion-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.seccion-cabecera h2 {
  font-size: 2.2rem;
  font-weight: 800;
  color: #0f172a;
}

.subtitulo {
  color: var(--color-texto-suave);
  font-size: 1.05rem;
  margin-top: 0.3rem;
}

.filtros-container {
  display: flex;
  gap: 0.5rem;
  background: #e2e8f0;
  padding: 0.35rem;
  border-radius: var(--radio-pequeno);
}

.filtro-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: var(--transicion);
}

.filtro-btn.activo, .filtro-btn:hover {
  background: var(--color-blanco);
  color: var(--color-bosque-oscuro);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Cuadrícula de tarjetas de rutas */
.rutas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

.ruta-card {
  background: var(--color-blanco);
  border-radius: var(--radio-borde);
  overflow: hidden;
  box-shadow: var(--sombra-tarjeta);
  border: 1px solid var(--color-borde);
  display: flex;
  flex-direction: column;
  transition: var(--transicion);
}

.ruta-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--sombra-hover);
}

.ruta-img-contenedor {
  position: relative;
  height: 200px;
  overflow: hidden;
}

.ruta-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.ruta-card:hover .ruta-img {
  transform: scale(1.05);
}

.badge-dificultad {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.3rem 0.8rem;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-facil {
  background: var(--badge-facil-bg);
  color: var(--badge-facil-texto);
}

.badge-moderada {
  background: var(--badge-moderada-bg);
  color: var(--badge-moderada-texto);
}

.badge-exigente {
  background: var(--badge-exigente-bg);
  color: var(--badge-exigente-texto);
}

.ruta-cuerpo {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.ruta-ubicacion {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-bosque);
  margin-bottom: 0.4rem;
}

.ruta-titulo {
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.8rem;
}

.ruta-descripcion {
  font-size: 0.92rem;
  color: var(--color-texto-suave);
  margin-bottom: 1.2rem;
  flex-grow: 1;
}

.ruta-metricas {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--color-borde);
  padding-top: 1rem;
  margin-top: auto;
}

.metrica {
  text-align: center;
}

.metrica-valor {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

.metrica-nombre {
  font-size: 0.75rem;
  color: var(--color-texto-suave);
  text-transform: uppercase;
}

/* BOTONES DE ACCIÓN EN CADA TARJETA */
.ruta-botones-principales {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn-ver-mapa {
  flex: 1;
  background: #f8fafc;
  border: 1px solid var(--color-borde);
  color: var(--color-bosque-oscuro);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radio-pequeno);
  cursor: pointer;
  transition: var(--transicion);
  text-align: center;
}

.btn-ver-mapa:hover {
  background: #f0fdf4;
  border-color: var(--color-bosque);
}

/* Botón especial para abrir track de Wikiloc o Strava */
.btn-ver-track {
  flex: 1;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radio-pequeno);
  cursor: pointer;
  transition: var(--transicion);
  text-align: center;
  color: white;
}

.btn-ver-track.btn-wikiloc {
  background-color: var(--color-wikiloc);
}

.btn-ver-track.btn-wikiloc:hover {
  background-color: #2b7a27;
  box-shadow: 0 4px 10px rgba(53, 152, 48, 0.3);
}

.btn-ver-track.btn-strava {
  background-color: var(--color-strava);
}

.btn-ver-track.btn-strava:hover {
  background-color: #e03e00;
  box-shadow: 0 4px 10px rgba(252, 76, 2, 0.3);
}

.ruta-acciones {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.8rem;
}

.btn-eliminar {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: var(--transicion);
}

.btn-eliminar:hover {
  background: #fee2e2;
}

/* ==========================================================================
   MODAL FLOTANTE (VISOR WIKILOC / STRAVA EMBEDS)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.abierto {
  display: flex;
  opacity: 1;
}

.modal-dialog {
  background: var(--color-blanco);
  width: 100%;
  max-width: 900px;
  border-radius: var(--radio-borde);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: modalEntrada 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

@keyframes modalEntrada {
  from {
    transform: translateY(20px) scale(0.97);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-header {
  padding: 1.2rem 1.8rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--color-borde);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.modal-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  color: white;
}

.modal-badge.wikiloc { background-color: var(--color-wikiloc); }
.modal-badge.strava { background-color: var(--color-strava); }

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  transition: var(--transicion);
}

.modal-close:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.modal-body {
  position: relative;
  background-color: #000;
  min-height: 500px;
}

.modal-cargando {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #94a3b8;
  font-size: 0.95rem;
  z-index: 1;
}

.iframe-embed {
  width: 100%;
  height: 520px;
  border: none;
  display: block;
  position: relative;
  z-index: 2;
  background: white;
}

/* ==========================================================================
   SECCIÓN FORMULARIO
   ========================================================================== */
.seccion-formulario {
  background-color: #f1f5f9;
}

.contenedor-form {
  max-width: 750px;
}

.form-card {
  background: var(--color-blanco);
  padding: 2.5rem;
  border-radius: var(--radio-borde);
  box-shadow: var(--sombra-tarjeta);
  border: 1px solid var(--color-borde);
}

.form-header {
  margin-bottom: 2rem;
  text-align: center;
}

.form-header h2 {
  font-size: 1.8rem;
  color: #0f172a;
}

.form-header p {
  color: var(--color-texto-suave);
  margin-top: 0.4rem;
}

.campo-grupo {
  margin-bottom: 1.4rem;
}

.campo-ayuda {
  display: block;
  font-size: 0.82rem;
  color: var(--color-texto-suave);
  margin-top: 0.35rem;
}

.form-fila {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.2rem;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-borde);
  border-radius: var(--radio-pequeno);
  font-size: 0.95rem;
  color: var(--color-texto);
  background-color: #ffffff;
  transition: var(--transicion);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-bosque);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.15);
}

/* ==========================================================================
   PIE DE PÁGINA (FOOTER)
   ========================================================================== */
.footer {
  background-color: #092e18;
  color: #cbd5e1;
  padding-top: 4rem;
  padding-bottom: 2rem;
}

.footer-contenido {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 2rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-info h3 {
  color: var(--color-blanco);
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.footer-enlaces h4 {
  color: var(--color-blanco);
  font-size: 1rem;
  margin-bottom: 0.8rem;
}

.social-tags {
  display: flex;
  gap: 0.8rem;
}

.tag-link {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.35rem 0.9rem;
  border-radius: 50px;
  font-size: 0.85rem;
  color: #e2e8f0;
}

.footer-bottom {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MÓVILES Y PANTALLAS PEQUEÑAS)
   ========================================================================== */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.2rem;
  }
  
  .hero p {
    font-size: 1.05rem;
  }

  .mapa-elemento {
    height: 380px;
  }

  .iframe-embed {
    height: 420px;
  }

  .menu-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-blanco);
    flex-direction: column;
    padding: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--color-borde);
  }

  .nav-links.activo {
    display: flex;
  }

  .form-card {
    padding: 1.5rem;
  }
}
