/* ============================================================
   LA MALEÏDA · ROUTE VIEWER
   ------------------------------------------------------------
   Estilo ÚNICO del visualizador de recorrido en 3D (Mapbox +
   perfil de elevación). Lo comparten todas las modalidades
   (full, sprint y las que vengan).

   Basado en el diseño corporativo (navy + lima + rojo).
   Las variables y fuentes vienen de theme.css: cárgalo antes.
   ============================================================ */

* { box-sizing: border-box; }

/* Pantalla completa, sin scroll */
html, body {
  margin: 0; padding: 0;
  height: 100%; overflow: hidden;
  display: flex; flex-direction: column;
  font-family: var(--fb);
  background: var(--color-dark);
  color: var(--white);
}

/* ════════════ NAV — blanco (mismo estilo que el nav principal) ════════════ */
nav {
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,53,115,0.10);
  box-shadow: 0 1px 16px rgba(0,0,0,0.06);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: 64px; flex-shrink: 0; z-index: 1000;
}
.nav-logo { text-decoration: none; display: flex; align-items: center; }
.nav-logo-full { display: flex; align-items: center; }
.nav-logo-full img { height: 50px; width: auto; display: block; }

.nav-center { display: flex; align-items: center; gap: 0.85rem; }
.nav-back {
  font-family: var(--fh); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: rgba(0,53,115,0.45); text-decoration: none; transition: color 0.2s;
}
.nav-back:hover { color: var(--navy); }
.nav-sep { color: rgba(0,53,115,0.2); }
.nav-title {
  font-family: var(--fh); font-size: 0.8rem; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; color: var(--navy);
}

.dist-badge { display: flex; gap: 1.5rem; align-items: center; }
.dist-badge-item {
  font-family: var(--fh); font-size: 0.66rem; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
}
.dist-badge-val   { color: var(--lime2); }
.dist-badge-label { color: rgba(0,53,115,0.38); margin-left: 0.12rem; }

.nav-actions { display: flex; align-items: center; gap: 1rem; }
.btn-download {
  background: var(--ale-red); color: #fff; padding: 0.42rem 1rem;
  font-family: var(--fh); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  text-decoration: none; white-space: nowrap; transition: background 0.2s;
}
.btn-download:hover { background: var(--ale-red2); }

.lang-switcher { display: flex; gap: 0.4rem; }
.lang-btn {
  background: none; border: 1px solid rgba(0,53,115,0.2);
  color: rgba(0,53,115,0.5);
  font-family: var(--fh); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 1px; padding: 0.22rem 0.38rem;
  cursor: pointer; text-transform: uppercase; transition: 0.2s;
}
.lang-btn:hover, .lang-btn.active { border-color: var(--navy); color: var(--navy); }

/* ════════════ LAYOUT ════════════ */
#main-container { display: flex; flex-direction: row; flex: 1; overflow: hidden; min-height: 0; }
#map-wrapper { flex: 1; position: relative; }
#map { height: 100%; width: 100%; }

/* ════════════ PANEL LATERAL ════════════ */
#data-table-container {
  width: 300px; background: var(--color-dark); color: white;
  display: flex; flex-direction: column;
  border-left: 1px solid rgba(164,198,56,0.15); z-index: 5;
}
.table-header {
  background: var(--panel-bg);
  border-bottom: 1px solid rgba(164,198,56,0.15);
  padding: 10px 16px;
  font-family: var(--fh); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 3px; text-transform: uppercase;
  color: rgba(255,255,255,0.38); flex-shrink: 0;
}
#segments-list { flex: 1; overflow-y: auto; }
#segments-list::-webkit-scrollbar { width: 4px; }
#segments-list::-webkit-scrollbar-thumb { background: rgba(164,198,56,0.25); border-radius: 2px; }

.segment-row {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  cursor: pointer; transition: background 0.2s, border-left-color 0.2s;
  border-left: 4px solid transparent;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.segment-row:hover { background: rgba(255,255,255,0.04); }
.segment-row.active-run  { border-left-color: var(--neon-run);  background: rgba(193,53,26,0.1); }
.segment-row.active-swim { border-left-color: var(--neon-swim); background: rgba(26,94,168,0.12); }

.seg-main { display: flex; flex-direction: column; }
.seg-label {
  font-family: var(--fh); font-size: 9px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: rgba(255,255,255,0.32); display: block; margin-bottom: 3px;
}
.seg-val {
  font-family: var(--fd); font-size: 1.3rem; font-weight: 700;
  letter-spacing: -0.01em; line-height: 1;
}
.seg-gain {
  font-family: var(--fh); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.5px; color: rgba(164,198,56,0.85);
  text-align: right; white-space: nowrap;
}
.seg-gain span {
  display: block; font-size: 0.5rem; letter-spacing: 1.5px;
  text-transform: uppercase; color: rgba(255,255,255,0.28);
}

.panel-footer { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
.btn-gpx-panel {
  display: block; background: transparent;
  border: 1px solid rgba(164,198,56,0.3); color: var(--lime); padding: 9px;
  font-family: var(--fh); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  text-decoration: none; text-align: center;
  transition: background 0.2s, border-color 0.2s;
}
.btn-gpx-panel:hover { background: rgba(164,198,56,0.08); border-color: var(--lime); }

/* ════════════ PERFIL DE ELEVACIÓN — mismo estilo que la home ════════════ */
#elevation-container {
  touch-action: none;
  height: 160px;
  background: #071526;
  padding: 12px 18px 10px;
  border-top: 1px solid rgba(164,198,56,0.18);
  flex-shrink: 0;
}
#elevationChart { width: 100% !important; height: 100% !important; }

/* ════════════ POPUP MAPBOX ════════════ */
.mapboxgl-popup-content {
  background: rgba(0,28,60,0.95) !important;
  backdrop-filter: blur(8px);
  color: white !important;
  border: 1px solid rgba(164,198,56,0.3) !important;
  border-radius: 2px !important;
  font-size: 12px; padding: 10px 13px !important;
  font-family: var(--fh) !important; letter-spacing: 0.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5) !important;
}
.mapboxgl-popup-content strong {
  font-family: var(--fd) !important;
  font-size: 13px !important; font-weight: 700 !important;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--lime); display: block; margin-bottom: 3px;
}
.mapboxgl-popup-tip { border-top-color: rgba(0,28,60,0.95) !important; }

.mapboxgl-ctrl-group {
  background: rgba(0,28,60,0.9) !important;
  border: 1px solid rgba(164,198,56,0.18) !important;
  border-radius: 2px !important;
}
.mapboxgl-ctrl-group button { background-color: transparent !important; }
.mapboxgl-ctrl-group button .mapboxgl-ctrl-icon { filter: invert(1) brightness(0.6); }

/* ════════════ FOOTER ════════════ */
footer {
  background: var(--color-dark);
  border-top: 1px solid rgba(164,198,56,0.15);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 2rem; height: 30px; flex-shrink: 0;
  font-family: var(--fh); font-size: 0.55rem; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,0.2);
}
footer a { color: rgba(164,198,56,0.5); text-decoration: none; }
footer a:hover { color: var(--lime); }
.footer-lime { color: var(--lime); }

/* ════════════ RESPONSIVE — Tablet ════════════ */
@media (max-width: 900px) {
  nav { padding: 0 1rem; }
  .dist-badge, .nav-back, .nav-sep { display: none; }

  #main-container { flex-direction: column; }
  #map-wrapper { flex: 1; min-height: 0; }
  #data-table-container {
    width: 100%; height: 190px; flex-direction: row;
    border-left: none; border-top: 1px solid rgba(164,198,56,0.15); flex-shrink: 0;
  }
  .table-header { writing-mode: vertical-lr; width: 36px; padding: 12px 8px; letter-spacing: 2px; }
  #segments-list { flex: 1; display: flex; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .segment-row {
    flex-direction: column; align-items: flex-start; min-width: 100px; gap: 4px;
    border-bottom: none; border-right: 1px solid rgba(255,255,255,0.07);
    border-left: none; border-top: 4px solid transparent;
  }
  .segment-row.active-run  { border-top-color: var(--neon-run);  border-left-color: transparent; }
  .segment-row.active-swim { border-top-color: var(--neon-swim); border-left-color: transparent; }
  .panel-footer { display: none; }
  #elevation-container { height: 120px; }
}

/* ════════════ RESPONSIVE — Móvil ════════════ */
@media (max-width: 600px) {
  nav { height: 52px; padding: 0 0.75rem; }
  .nav-logo { height: 36px; }
  .nav-logo svg { height: 32px; }
  .nav-center { gap: 0.5rem; }
  .nav-title { font-size: 0.68rem; letter-spacing: 1px; }
  .nav-actions { gap: 0.5rem; }
  .btn-download { padding: 0.35rem 0.6rem; font-size: 0.6rem; letter-spacing: 1px; }
  .lang-switcher { display: none; }

  #data-table-container { height: 170px; }
  .segment-row { min-width: 88px; padding: 9px 11px; }
  .seg-val { font-size: 1.1rem; }
  .seg-gain { font-size: 0.62rem; }

  #elevation-container { height: 100px; padding: 7px 12px 6px; }
  footer { padding: 0 0.75rem; font-size: 0.48rem; }
}
