/**
 * IRP Patrimonial - Map CSS
 * Estilos específicos para el mapa y sus controles
 */

/* ========================================
   LEAFLET OVERRIDES
   ======================================== */
.leaflet-container {
  background: var(--bg-darker);
  font-family: 'Roboto', sans-serif;
}

/* Ocultar controles de Leaflet por defecto */
.leaflet-control-zoom,
.leaflet-control-attribution {
  display: none !important;
}

/* ========================================
   POPUP DE LEAFLET (tema oscuro)
   ======================================== */
.leaflet-popup-content-wrapper {
  background: var(--bg-panel);
  color: var(--text-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
  margin: 0;
  padding: 0;
}

.leaflet-popup-tip {
  background: var(--bg-panel);
}

.leaflet-popup-close-button {
  color: var(--text-secondary) !important;
  font-size: 20px !important;
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  top: 8px !important;
  right: 8px !important;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
}

.leaflet-popup-close-button:hover {
  background: var(--bg-hover);
  color: var(--text-primary) !important;
}

/* ========================================
   TOOLTIP DE LEAFLET (tema oscuro)
   ======================================== */
.leaflet-tooltip {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
  border-top-color: var(--bg-panel);
}

/* Tooltips permanentes (etiquetas) */
.leaflet-tooltip.permanent-label {
  background: rgba(38, 50, 56, 0.9);
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
}

/* ========================================
   ÍCONOS DE WAYPOINT
   ======================================== */
.waypoint-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
}

.waypoint-icon i {
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
}

/* ========================================
   HANDLES DE EDICIÓN DE VÉRTICES
   ======================================== */
.vertex-handle {
  width: 12px;
  height: 12px;
  background: var(--success);
  border: 2px solid white;
  border-radius: 50%;
  cursor: move;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.vertex-handle:hover {
  transform: scale(1.2);
  background: var(--primary);
}

.mid-handle {
  width: 16px;
  height: 16px;
  background: var(--bg-panel);
  border: 2px solid var(--primary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.mid-handle:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.1);
}

/* ========================================
   GRILLA UTM - Mejorada
   ======================================== */
.leaflet-pane.leaflet-overlay-pane .grid-layer-group {
  z-index: 650 !important;
}

.grid-label {
  pointer-events: none !important;
  background: transparent !important;
  border: none !important;
  z-index: 1000 !important;
  position: relative !important;
}

.grid-label-content {
  display: inline-block;
  background: rgba(0, 0, 0, 0.7);
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  font-family: 'Consolas', 'Monaco', monospace;
  color: rgba(200, 200, 200, 0.9);
  border: 1px solid rgba(180, 180, 180, 0.3);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Asegurar que la grilla esté sobre el mapa */
.leaflet-map-pane {
  z-index: 400;
}

.leaflet-overlay-pane {
  z-index: 450;
}

/* ========================================
   LÍNEA DE PREVIEW (DIBUJO)
   ======================================== */
.preview-line {
  stroke: var(--color-preview);
  stroke-dasharray: 5, 5;
  stroke-width: 2;
}

/* ========================================
   OBJETO EN PARPADEO
   ======================================== */
.leaflet-interactive.blink {
  animation: objectBlink 0.4s ease-in-out 3;
}

@keyframes objectBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ========================================
   CURSOR PERSONALIZADO
   ======================================== */
#map.cursor-crosshair {
  cursor: crosshair;
}

#map.cursor-pointer {
  cursor: pointer;
}

#map.cursor-grab {
  cursor: grab;
}

#map.cursor-grabbing {
  cursor: grabbing;
}

/* ========================================
   COORDENADAS DISPLAY (en status bar)
   ======================================== */
.coords-display {
  font-family: 'Consolas', monospace;
  font-size: 11px;
  display: flex;
  gap: 12px;
}

.coords-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.coords-label {
  color: var(--text-muted);
  font-size: 10px;
}

.coords-value {
  color: var(--text-primary);
}

/* ========================================
   SCALE BAR (opcional)
   ======================================== */
.scale-bar {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(38, 50, 56, 0.9);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  z-index: var(--z-toolbar);
}

/* ========================================
   LAYER SWITCHER BUTTONS
   ======================================== */
#layer-switcher {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-switcher-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-switcher-divider {
  height: 1px;
  background: var(--border-color);
  margin: 3px 0;
}

.layer-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-input);
  border: none;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all var(--transition-fast);
}

.layer-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.layer-btn.active {
  background: var(--primary);
  color: white;
}

/* Botones toggle (límites políticos, SIGDA) - mismo estilo que capas base */
.layer-btn-toggle {
  position: relative;
}

.layer-btn-toggle.active {
  background: var(--primary);
  color: white;
}

/* Capas KML MinCul - colores propios al activar */
#btn-kml-pmar.active {
  background: #F59E0B;
  color: #1a1a1a;
}

#btn-kml-bienes-nd.active {
  background: #EF4444;
}

#btn-kml-bienes-d.active {
  background: #10B981;
  color: #1a1a1a;
}

#btn-kml-ciras.active {
  background: #8B5CF6;
}

/* ========================================
   BASEMAP PROVIDER FLYOUT
   ======================================== */
.basemap-flyout {
  position: absolute;
  top: 6px;
  right: 46px; /* ajustado dinámicamente por JS */
  background: var(--bg-dark);
  border-radius: var(--border-radius);
  padding: 4px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: right 0.2s ease;
}

.basemap-flyout-btns {
  display: flex;
  flex-direction: row;
  gap: 3px;
}

.flyout-provider-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-input);
  border: none;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all var(--transition-fast);
  position: relative;
}

.flyout-provider-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.flyout-provider-btn.active {
  background: var(--primary);
  color: white;
}

/* ========================================
   HILLSHADE OVERLAY CONTROL
   ======================================== */
.hillshade-control {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: var(--bg-dark);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  width: 210px;
  border: 1px solid var(--border-color);
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
}

.hillshade-control.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.hillshade-control-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.hillshade-control-header .btn-icon {
  width: 16px;
  height: 16px;
  font-size: 8px;
  min-width: 16px;
}

.hillshade-control-body {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.hillshade-control-body input[type="range"] {
  flex: 1;
  height: 3px;
  min-width: 0;
}

.hillshade-control-body span {
  font-size: 9px;
  color: var(--text-secondary);
  min-width: 22px;
  text-align: right;
}

/* ========================================
   ZOOM CONTROLS CUSTOM
   ======================================== */
.zoom-controls {
  position: absolute;
  bottom: 50px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1000;
}

.zoom-controls .btn-icon {
  background: var(--bg-dark);
  box-shadow: var(--shadow-md);
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.zoom-level {
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-dark);
  padding: 3px;
  border-radius: var(--border-radius);
}

/* ========================================
   MARKER CLUSTER (si se usa)
   ======================================== */
.marker-cluster {
  background: rgba(250, 92, 0, 0.4);
  border-radius: 50%;
}

.marker-cluster div {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================================
   MEDICIÓN TOOLTIP
   ======================================== */
.measurement-tooltip {
  background: var(--bg-panel);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--border-radius);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--primary);
}

.measurement-tooltip .value {
  color: var(--primary);
  font-family: 'Consolas', monospace;
}

/* ========================================
   SIGDA POPUP STYLES
   ======================================== */
.sigda-popup {
  min-width: 320px;
}

.sigda-popup .leaflet-popup-content-wrapper {
  padding: 0;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
}

.sigda-popup .leaflet-popup-content {
  margin: 0;
  width: 350px !important;
  max-width: 90vw;
}

.sigda-popup-content {
  font-family: 'Roboto', sans-serif;
}

.sigda-popup-header {
  background: linear-gradient(135deg, var(--primary) 0%, #c44500 100%);
  color: white;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.sigda-popup-header i {
  font-size: 18px;
  flex-shrink: 0;
}

.sigda-popup-header span {
  word-break: break-word;
  line-height: 1.3;
}

.sigda-popup-body {
  max-height: 300px;
  overflow-y: auto;
  padding: 0;
}

.sigda-popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.sigda-popup-table tr {
  border-bottom: 1px solid var(--border-color);
}

.sigda-popup-table tr:last-child {
  border-bottom: none;
}

.sigda-popup-table tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.15);
}

.sigda-popup-table td {
  padding: 8px 12px;
  vertical-align: top;
}

.sigda-popup-table td.field-name {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding-bottom: 2px;
}

.sigda-popup-table td.field-value {
  color: var(--text-primary);
  word-break: break-word;
  font-size: 13px;
  padding-top: 2px;
}

/* Layout vertical: nombre arriba, valor abajo */
.sigda-popup-table tr {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
}

.sigda-popup-table td {
  padding: 0;
  display: block;
  width: 100%;
}

.sigda-popup-footer {
  padding: 12px 15px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.sigda-popup-footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  border-radius: var(--border-radius);
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sigda-popup-footer .btn:hover {
  background: #ff6b1a;
  transform: translateY(-1px);
}

/* ========================================
   TRACK INFO MODAL
   ======================================== */
.track-info-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.track-info-modal.show {
  opacity: 1;
}

.track-info-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
}

.track-info-panel {
  position: relative;
  background: #1e2530;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-normal);
  border: 1px solid var(--border-color);
}

.track-info-modal.show .track-info-panel {
  transform: scale(1) translateY(0);
}

.track-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #171c24;
  border-bottom: 1px solid var(--border-color);
}

.track-info-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.track-info-title i {
  color: var(--primary);
  font-size: 18px;
}

.track-info-group {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: 4px;
}

.track-info-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
}

.track-info-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.track-info-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Grid de estadísticas */
.track-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.track-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #171c24;
  border-radius: var(--border-radius);
}

.stat-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #252d3a;
  border-radius: 6px;
  color: var(--primary);
  font-size: 14px;
  flex-shrink: 0;
}

.stat-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tiempo de registro */
.track-info-time {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 12px;
  background: #171c24;
  border-radius: var(--border-radius);
  font-size: 12px;
  color: var(--text-secondary);
}

.track-info-time i {
  color: var(--primary);
}

/* Footer */
.track-info-footer {
  padding: 12px 20px;
  background: #171c24;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.track-info-footer .btn-secondary {
  background: #252d3a;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.track-info-footer .btn-secondary:hover {
  background: #2d3644;
}

/* Botón de perfil de elevación en modal */
.btn-elevation-profile {
  background: linear-gradient(135deg, #fa5c00 0%, #d94e00 100%);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-elevation-profile:hover {
  background: linear-gradient(135deg, #ff7b2e 0%, #fa5c00 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(250, 92, 0, 0.3);
}

.btn-elevation-profile i {
  font-size: 13px;
}

/* ========================================
   PANEL PERFIL DE ELEVACIÓN
   ======================================== */

.elevation-profile-panel {
  position: fixed;
  bottom: var(--statusbar-height);
  left: var(--panel-width);
  right: var(--panel-width);
  height: 260px;
  background: #1e2530;
  border-top: 2px solid var(--primary);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  z-index: 450;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.elevation-profile-panel.show {
  transform: translateY(0);
}

/* Header del perfil */
.elev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #171c24;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.elev-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
}

.elev-title i {
  color: var(--primary);
  font-size: 13px;
  flex-shrink: 0;
}

.elev-title span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elev-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.elev-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.elev-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all var(--transition-fast);
}

.elev-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
}

.elev-btn.active {
  background: var(--primary);
  color: #fff;
}

.elev-btn span {
  font-size: 10px;
  font-weight: 700;
}

.elev-btn-close:hover {
  background: rgba(231, 76, 60, 0.3);
  color: #e74c3c;
}

.elev-separator {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.1);
  margin: 0 4px;
}

/* Barra de información */
.elev-info-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  overflow-x: auto;
}

.elev-info-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-right: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
  flex-shrink: 0;
}

.elev-info-item:last-child {
  border-right: none;
}

.elev-info-item i {
  color: var(--primary);
  font-size: 10px;
  width: 12px;
  text-align: center;
}

.elev-info-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.elev-info-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Canvas container */
.elev-canvas-container {
  flex: 1;
  min-height: 0;
  position: relative;
  cursor: crosshair;
}

.elev-canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Leyenda de pendiente (debajo del canvas) */
.elev-slope-legend {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 3px 12px;
  background: rgba(0,0,0,0.25);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.elev-slope-legend.show {
  display: flex;
}

.elev-slope-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.elev-slope-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Slider */
.elev-slider-container {
  padding: 2px 12px 6px;
  background: #171c24;
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.elev-slider-container input[type="range"] {
  width: 100%;
  height: 14px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.elev-slider-container input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: #252d3a;
  border-radius: 2px;
}

.elev-slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 2px solid #fff;
  border-radius: 50%;
  margin-top: -5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.1s ease;
}

.elev-slider-container input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.elev-slider-container input[type="range"]::-moz-range-track {
  height: 4px;
  background: #252d3a;
  border-radius: 2px;
  border: none;
}

.elev-slider-container input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--primary);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.elev-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Tooltip del marcador en el mapa */
.elev-marker-tooltip {
  background: rgba(23, 28, 36, 0.92) !important;
  border: 1px solid var(--primary) !important;
  color: var(--text-primary) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 3px 8px !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}

.elev-marker-tooltip::before {
  border-top-color: var(--primary) !important;
}

/* Responsive */
@media (max-width: 480px) {
  .track-info-panel {
    width: 95%;
    max-height: 90vh;
  }
  
  .track-info-grid {
    grid-template-columns: 1fr;
  }
  
  .track-info-difficulty {
    flex-wrap: wrap;
  }
  
  .elevation-profile-panel {
    left: 0 !important;
    right: 0 !important;
    height: 220px;
  }
  
  .elev-info-bar {
    gap: 0;
    padding: 3px 8px;
  }
  
  .elev-info-item {
    padding: 2px 6px;
  }
}


/* ========================================
   WAYBACK PANEL
   ======================================== */
.wayback-panel {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  min-width: 260px;
  max-width: 360px;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.wayback-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

.wayback-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: move;
}

.wayback-panel-header i {
  color: var(--primary);
  margin-right: 5px;
}

.wayback-panel-actions {
  display: flex;
  gap: 2px;
}

.wayback-panel-actions .btn-icon.active {
  background: var(--primary);
  color: white;
}

.wayback-panel-actions .btn-icon.active i {
  color: white;
}

.wayback-panel-body {
  padding: 5px 10px 4px;
}

.wayback-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px;
}

.wayback-loading i {
  margin-right: 5px;
}

.wayback-date-display {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.wayback-date-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.wayback-step-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 10px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
}

.wayback-step-btn:hover {
  color: var(--primary);
  background: var(--bg-input);
}

.wayback-version-count {
  font-size: 9px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Slider */
.wayback-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--bg-input);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.wayback-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: grab;
  transition: transform 0.1s ease;
}

.wayback-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.wayback-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: grab;
}

.wayback-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 1px;
  font-size: 9px;
  color: var(--text-muted);
}

/* Swipe config */
.wayback-swipe-config {
  padding: 4px 10px 5px;
  border-top: 1px solid var(--border-color);
}

.wayback-swipe-config.hidden {
  display: none;
}

.wayback-swipe-row {
  display: flex;
  gap: 8px;
}

.wayback-swipe-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wayback-swipe-side:last-child label {
  text-align: right;
}

.wayback-swipe-side label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wayback-swipe-side label i {
  color: var(--primary);
}

.wayback-select {
  width: 100%;
  padding: 3px 6px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 11px;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  outline: none;
}

.wayback-select:focus {
  border-color: var(--primary);
}


/* ========================================
   SWIPE DIVIDER
   ======================================== */
.swipe-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  z-index: 1050;
  pointer-events: none;
  transition: left 0.05s linear;
}

.swipe-divider.hidden {
  display: none;
}

.swipe-divider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 3px;
  background: white;
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
  pointer-events: auto;
  cursor: col-resize;
}

.swipe-divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 44px;
  background: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: background 0.15s ease;
}

.swipe-divider-handle i {
  color: #333;
  font-size: 14px;
}

.swipe-divider-handle:hover {
  background: var(--primary);
}

.swipe-divider-handle:hover i {
  color: white;
}

/* Labels */
.swipe-label {
  position: absolute;
  top: 10px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 11px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.swipe-label-left {
  right: 12px;
}

.swipe-label-right {
  left: 12px;
}


/* ========================================
   WAYBACK RESPONSIVE
   ======================================== */
@media (max-width: 600px) {
  .wayback-panel {
    min-width: 280px;
    max-width: 95vw;
    bottom: 30px;
  }
}

/* ========================================
   ESCALA GRÁFICA
   ======================================== */
.map-scale {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 1000;
  background: var(--bg-dark);
  border: 1px solid rgba(250, 92, 0, 0.35);
  border-radius: var(--border-radius);
  padding: 5px 8px 4px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  user-select: none;
}

.map-scale-inner {
  display: flex;
  align-items: center;
  gap: 5px;
}

.map-scale-tick {
  font-family: 'Roboto', sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

.map-scale-bar {
  height: 6px;
  background: var(--primary);
  border-radius: 2px;
  border-left: 2px solid var(--primary-light);
  border-right: 2px solid var(--primary-light);
  transition: width 0.2s ease;
  flex-shrink: 0;
}

.map-scale-value {
  font-family: 'Roboto', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  white-space: nowrap;
}

/* ========================================
   LOGO TECK (esquina inferior izquierda)
   Visible solo cuando cliente activo es Teck / Zafranal.
   Se posiciona ~10px sobre la escala gráfica.
   ======================================== */
#teck-corner-logo {
  position: absolute;
  left: 10px;
  bottom: 50px; /* escala (~30px alto + 10px bottom) + 10px de gap */
  z-index: 1000;
  height: 76px;
  width: auto;
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
  display: none; /* oculto por defecto, JS lo activa */
}

#teck-corner-logo.active {
  display: block;
}

#riotinto-corner-logo,
#unused-corner-logo {
  position: absolute;
  left: 10px;
  bottom: 50px;
  z-index: 1000;
  height: 76px;
  width: auto;
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
  display: none; /* oculto por defecto, JS lo activa */
}

#riotinto-corner-logo.active,
#unused-corner-logo.active {
  display: block;
}

.sigda-popup-section {
  border-bottom: 1px solid var(--border-color);
}

.sigda-popup-section:last-child {
  border-bottom: none;
}

.sigda-popup-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sigda-popup-feature-name {
  padding: 0 12px 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.sigda-popup-extra {
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border-color);
}

.sigda-popup-source {
  justify-content: flex-start;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}
