/**
 * Stylesheet: Visor 3D de Rutas GPX y Relieve Topográfico
 * Fijate Tools - Estándar con sidebar de AdSense y botón Fullscreen.
 */

:root {
  --bg-app: #0b0f17;
  --bg-panel: rgba(15, 23, 42, 0.86);
  --bg-panel-solid: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --border-panel: rgba(255, 255, 255, 0.12);
  --border-focus: #ff8507;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-accent: #ff8507;

  --accent-color: #ff8507;
  --accent-hover: #e07400;
  --accent-glow: rgba(255, 133, 7, 0.35);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-panel: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-panel: rgba(255, 255, 255, 0.88);
  --bg-panel-solid: #ffffff;
  --bg-card: rgba(241, 245, 249, 0.85);
  --border-panel: rgba(0, 0, 0, 0.1);
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-panel: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Contenedor central estándar Fijate */
.main-wrapper {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 16px 40px 16px;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.tool-main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* Escenario del Visor 3D */
.stage-3d-wrapper {
  position: relative;
  width: 100%;
  height: 580px;
  background: #050811;
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.stage-3d-wrapper.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
  border: none !important;
}

#map-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Paneles Flotantes HUD dentro del Escenario */
.hud-panel {
  position: absolute;
  z-index: 10;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  transition: all 0.25s ease;
}

.hud-sidebar {
  top: 14px;
  left: 14px;
  width: 310px;
  max-height: calc(100% - 170px);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud-sidebar::-webkit-scrollbar { width: 4px; }
.hud-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }

.route-summary-card {
  border-bottom: 1px solid var(--border-panel);
  padding-bottom: 8px;
}

.route-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 133, 7, 0.15);
  color: var(--accent-color);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
}

.route-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.metric-box {
  background: var(--bg-card);
  padding: 6px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-panel);
}

.metric-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-val {
  font-size: 13.5px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}

.metric-val.gain { color: #22c55e; }
.metric-val.loss { color: #38bdf8; }

.sports-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.sports-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.btn-sport-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 4px 2px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
}

.btn-sport-chip:hover {
  border-color: rgba(255, 133, 7, 0.4);
  color: var(--text-main);
}

.btn-sport-chip.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #0b0f17;
  font-weight: 700;
}

.import-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drop-zone {
  border: 1.5px dashed var(--border-panel);
  border-radius: var(--radius-md);
  padding: 8px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-card);
  transition: all 0.2s ease;
}

.drop-zone:hover, .drop-zone.drag-active {
  border-color: var(--accent-color);
  background: rgba(255, 133, 7, 0.08);
}

.drop-zone-text {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.drop-zone-text strong {
  color: var(--accent-color);
}

.select-control {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.select-control:focus {
  border-color: var(--accent-color);
}

/* Panel Inferior: Reproductor y Perfil */
.hud-bottom-bar {
  bottom: 12px;
  left: 12px;
  right: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.playback-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.playback-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-play-primary {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--accent-color);
  border: none;
  color: #0b0f17;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.btn-play-primary:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.btn-control-secondary {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-control-secondary:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.camera-modes-group {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-md);
  padding: 2px;
}

.camera-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.camera-label input { display: none; }
.camera-label:has(input:checked) { background: var(--accent-color); color: #0b0f17; }

.live-telemetry-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-full);
  padding: 3px 12px;
  font-size: 11.5px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}

.live-item span {
  color: var(--text-muted);
  font-size: 10px;
  margin-right: 3px;
  font-family: 'Inter', sans-serif;
}

.profile-wrapper {
  position: relative;
  width: 100%;
  height: 100px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-panel);
}

.progress-track-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 5;
}

.progress-fill-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
  transition: width 0.05s linear;
}

#elevation-profile-container {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Marcadores 3D */
.route-athlete-marker {
  width: 26px;
  height: 26px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.marker-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 133, 7, 0.4);
  animation: pulse-ring 1.6s infinite;
}

.marker-core {
  position: relative;
  width: 20px;
  height: 20px;
  background: #ff8507;
  color: #0b0f17;
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.route-hover-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px #38bdf8;
  pointer-events: none;
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Sidebar de AdSense y Didáctico */
.sidebar-gpx-card {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 14px;
}

.sidebar-gpx-title {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-color);
}

.sidebar-gpx-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Sección Didáctica y FAQ Inferior */
.tool-info-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-md);
  padding: 16px;
}

.info-card-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-accent);
}

.info-card-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Modales Nativos */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.app-modal-backdrop.active { display: flex; }

.app-modal-card {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.app-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-modal-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-main); }
.app-modal-body { padding: 20px; font-size: 13px; line-height: 1.6; color: var(--text-muted); }
.app-modal-footer { padding: 12px 20px; border-top: 1px solid var(--border-panel); display: flex; justify-content: flex-end; }

/* Responsividad */
@media (max-width: 1240px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr;
  }
  .tool-ad-sidebar {
    display: none !important;
  }
}

@media (max-width: 860px) {
  .stage-3d-wrapper {
    height: 480px;
  }
  .hud-sidebar {
    width: auto;
    left: 10px;
    right: 10px;
    max-height: 190px;
  }
  .hud-bottom-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 8px;
  }
  .playback-controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .profile-wrapper {
    height: 80px;
  }
}
