/* ==========================================
   CAVETRACKER - SYSTEMA DE ESTILOS PREMIUM
   ========================================== */

/* Variables del Sistema */
:root {
  --bg-primary: #040714;        /* Azul oscuro-negro */
  --bg-secondary: #08112d;      /* Azul real oscuro */
  --bg-glass: rgba(8, 17, 45, 0.75);
  --bg-glass-hover: rgba(20, 35, 75, 0.85);
  
  --accent-color: #0033cc;      /* Azul Real C.E.G. */
  --accent-light: #ffeb3b;      /* Amarillo C.E.G. */
  --accent-glow: rgba(255, 235, 59, 0.15);
  
  --text-primary: #f8fafc;     /* Slate 50 */
  --text-secondary: #94a3b8;   /* Slate 400 */
  --text-muted: #5e6d8c;       /* Slate 500 */
  
  --border-color: rgba(94, 109, 140, 0.3);
  --border-focus: rgba(255, 235, 59, 0.5); /* Amarillo foco */
  
  /* Dificultades */
  --diff-low: #10b981;         /* Verde */
  --diff-medium: #ff9800;      /* Naranja */
  --diff-high: #ef5350;        /* Rojo espeleólogo */
  --diff-expert: #b388ff;      /* Violeta */

  --font-family: 'Outfit', sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 16px;
}

/* Reset y Estilos Globales */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

/* Scrollbar Personalizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* ==========================================
   ESTADOS DE PANTALLA (SPA)
   ========================================== */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

/* ==========================================
   PANTALLA DE LOGIN
   ========================================== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 10% 20%, rgba(0, 51, 204, 0.15) 0%, transparent 45%),
              radial-gradient(circle at 90% 80%, rgba(255, 235, 59, 0.06) 0%, transparent 45%),
              linear-gradient(to bottom, #040816, #02030a);
}

.cavern-bg-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(rgba(255, 235, 59, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.login-container {
  width: 100%;
  max-width: 440px;
  padding: 38px 40px 30px;
  background: rgba(8, 14, 35, 0.78);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.07);
  text-align: center;
  z-index: 5;
  animation: floatUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes floatUp {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Partículas flotantes de fondo */
.login-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.login-particles span {
  position: absolute;
  display: block;
  border-radius: 50%;
  animation: particle-float linear infinite;
  opacity: 0;
}
.login-particles span:nth-child(1) { width:6px;  height:6px;  left:15%;  background:rgba(255,235,59,.35); animation-duration:14s; animation-delay:0s;   top:80%; }
.login-particles span:nth-child(2) { width:4px;  height:4px;  left:32%;  background:rgba(0,51,204,.4);   animation-duration:18s; animation-delay:2s;   top:90%; }
.login-particles span:nth-child(3) { width:8px;  height:8px;  left:55%;  background:rgba(255,235,59,.2); animation-duration:12s; animation-delay:4s;   top:75%; }
.login-particles span:nth-child(4) { width:3px;  height:3px;  left:72%;  background:rgba(255,255,255,.2);animation-duration:20s; animation-delay:1s;   top:85%; }
.login-particles span:nth-child(5) { width:5px;  height:5px;  left:88%;  background:rgba(0,51,204,.3);   animation-duration:16s; animation-delay:3s;   top:92%; }
.login-particles span:nth-child(6) { width:4px;  height:4px;  left:8%;   background:rgba(255,255,255,.15);animation-duration:22s; animation-delay:5s;  top:70%; }
.login-particles span:nth-child(7) { width:6px;  height:6px;  left:44%;  background:rgba(255,235,59,.25);animation-duration:17s; animation-delay:0.5s; top:88%; }
.login-particles span:nth-child(8) { width:3px;  height:3px;  left:65%;  background:rgba(0,51,204,.25);  animation-duration:19s; animation-delay:6s;   top:82%; }
@keyframes particle-float {
  0%   { transform: translateY(0)    rotate(0deg);   opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.4; }
  100% { transform: translateY(-120vh) rotate(720deg); opacity: 0; }
}

/* Logo ring */
.login-logo-ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 18px;
  border: 2.5px solid transparent;
  background: linear-gradient(var(--bg-dark), var(--bg-dark)) padding-box,
              linear-gradient(135deg, var(--accent-color), #ffeb3b, var(--accent-color)) border-box;
  box-shadow: 0 0 30px rgba(0, 51, 204, 0.4), 0 8px 24px rgba(0,0,0,0.5);
  animation: logo-glow 4s ease-in-out infinite alternate;
}
.login-logo-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
@keyframes logo-glow {
  from { box-shadow: 0 0 20px rgba(0,51,204,0.3), 0 8px 24px rgba(0,0,0,0.5); }
  to   { box-shadow: 0 0 40px rgba(255,235,59,0.25), 0 8px 24px rgba(0,0,0,0.5); }
}

.login-brand {
  margin-bottom: 26px;
}

.login-brand h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.login-brand p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
  font-weight: 300;
}
.login-brand p strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Pestañas de Login/Registro */
.login-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  gap: 4px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent-color), #001f80);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 51, 204, 0.35);
}

/* Formularios */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.auth-form.active {
  display: flex;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.input-group label {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.input-group input, 
.input-group select, 
.input-group textarea {
  width: 100%;
  min-width: 0; /* Permite encoger en flexbox y evita desbordamientos */
  padding: 12px 16px;
  background: rgba(31, 41, 55, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
  color: var(--text-muted);
}

.input-group input:focus, 
.input-group select:focus, 
.input-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: rgba(31, 41, 55, 0.5);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Botones Submit */
.submit-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  background: linear-gradient(135deg, var(--accent-color), #001f80);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 51, 204, 0.35);
  transition: var(--transition-smooth);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 51, 204, 0.45);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn.register-variant {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.35);
}

.submit-btn.register-variant:hover {
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.45);
}

/* Wrapper con ojo de contraseña */
.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon-wrap input {
  width: 100%;
  padding-right: 42px !important;
}
.input-eye-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color 0.2s;
  flex-shrink: 0;
}
.input-eye-btn:hover { color: var(--text-primary); }

/* Barra de fortaleza de contraseña */
.password-strength-bar {
  height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  margin-top: 6px;
}
#pwd-strength-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  transition: width 0.4s ease, background 0.4s ease;
}
.password-strength-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  text-align: left;
  margin-top: 4px;
  min-height: 1em;
  transition: color 0.3s;
}

/* Nota pie de página de login */
.login-footer-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 24px;
  opacity: 0.7;
}

/* Efecto de Brillo en Botones */
.btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: 0.6s;
}

.submit-btn:hover .btn-shine {
  left: 100%;
}

/* Banner de Mensajes */
.message-banner {
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  display: none;
  margin-top: 10px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.message-banner.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.message-banner.success {
  display: block;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

/* === Estilos sociales removidos (OAuth pendiente) === */
.social-divider, .social-buttons, .social-btn,
.google-btn, .facebook-btn { display: none !important; }

/* ==========================================
   PANTALLA DE MAPA (PRINCIPAL)
   ========================================== */
#map-screen {
  display: flex;
  flex-direction: column;
}

/* Cabecera */
.app-header {
  height: 64px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  touch-action: none;
}

/* Deshabilitar gestos y zoom en los logos */
.header-logo img,
.login-brand img,
.login-logo-ring img {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-light);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  white-space: nowrap;
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 0 10px var(--accent-glow);
  border: 2px solid var(--accent-light);
  background-size: cover;
  background-position: center;
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.welcome-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.username-display {
  font-size: 0.85rem;
  font-weight: 600;
}

.logout-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.logout-btn:hover {
  color: #f87171; /* Rojo */
  background: rgba(239, 68, 68, 0.08);
}

/* Cuerpo de la aplicación */
.app-body {
  flex: 1;
  display: flex;
  height: calc(100vh - 64px);
  position: relative;
}

/* Panel Lateral (Sidebar) */
.sidebar {
  width: 450px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: var(--transition-smooth);
}

.sidebar.resizing {
  transition: none !important;
}

/* Tirador táctil para móvil */
.mobile-drag-handle {
  display: none;
}

/* Redimensionador de barra lateral */
.sidebar-resizer {
  width: 6px;
  background: var(--border-color);
  cursor: col-resize;
  position: relative;
  z-index: 100;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.sidebar-resizer:hover,
.sidebar-resizer.resizing {
  background: var(--accent-light);
  box-shadow: 0 0 8px var(--accent-light);
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: rgba(7, 11, 18, 0.4);
  overflow: hidden; /* Evita scrolls o desbordamientos en PC */
}

.sidebar-tab {
  flex: 1 1 0%; /* Reparto equitativo en PC */
  min-width: 0;
  padding: 12px 4px; /* Padding reducido en PC */
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.86rem; /* Fuente más compacta en PC */
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  white-space: normal; /* Permite saltos de línea para textos largos como 'Registrar Cueva' */
  word-wrap: break-word;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.sidebar-tab:hover {
  color: var(--text-primary);
}

.sidebar-tab.active {
  color: var(--accent-light);
}

.sidebar-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent-light);
  box-shadow: 0 -2px 10px var(--accent-light);
}

.sidebar-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  flex-direction: column;
}

.sidebar-content.active {
  display: flex;
}

/* Anclar buscador arriba en el listado de explorar */
#sidebar-list {
  overflow-y: hidden;
  padding-bottom: 0;
}

#sidebar-list .caves-list {
  overflow-y: auto;
  padding-bottom: 20px;
  padding-right: 4px;
}

/* Buscador de Cuevas */
.search-box {
  position: relative;
  margin-bottom: 15px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  background: rgba(7, 11, 18, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-family);
  transition: var(--transition-smooth);
}

.search-box input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Lista de Cuevas */
.caves-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.caves-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.caves-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-weight: 300;
}

.cave-item {
  padding: 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.cave-item:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent-color);
  transform: translateX(4px);
}

.cave-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.cave-item-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cave-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cave-badge.low {
  background: rgba(16, 185, 129, 0.12);
  color: var(--diff-low);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cave-badge.medium {
  background: rgba(245, 158, 11, 0.12);
  color: var(--diff-medium);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.cave-badge.high {
  background: rgba(239, 68, 68, 0.12);
  color: var(--diff-high);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.cave-badge.expert {
  background: rgba(139, 92, 246, 0.12);
  color: var(--diff-expert);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.cave-item-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cave-item-meta {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 8px;
  margin-top: 4px;
}

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

/* Indicación de Formulario */
.form-tip {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 10px;
  margin-bottom: 20px;
  color: var(--accent-light);
}

.form-tip svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.form-tip p {
  font-size: 0.8rem;
  line-height: 1.3;
}

/* Filas combinadas en Form */
.coords-row {
  display: flex;
  gap: 12px;
}

.coords-row .input-group {
  flex: 1;
}

.add-cave-btn {
  margin-top: 15px;
}

/* Mapa */
.map-wrapper {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

.map-overlay-coordinates {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   ELEMENTOS DE MAPA LEAFLET PERSONALIZADOS
   ========================================== */
.leaflet-bar {
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-bar a {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  transition: var(--transition-smooth);
}

.leaflet-bar a:hover {
  background-color: var(--accent-color) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color);
  border-radius: 12px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
  padding: 6px;
}

.leaflet-popup-tip {
  background: var(--bg-secondary) !important;
  border-left: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

/* Atribución del Mapa Leaflet con Estilo Oscuro y Glassmorphic */
.leaflet-control-attribution {
  background: rgba(4, 7, 20, 0.75) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--text-secondary) !important;
  font-size: 10px !important;
  border-left: 1px solid var(--border-color) !important;
  border-top: 1px solid var(--border-color) !important;
  border-radius: 8px 0 0 0;
  padding: 4px 8px !important;
}

.leaflet-control-attribution a {
  color: var(--accent-light) !important;
  text-decoration: none;
}

.leaflet-control-attribution a:hover {
  text-decoration: underline;
}

/* Popup de Cueva Estilizado */
.cave-popup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-family);
  max-width: 250px;
  text-align: left;
}

.cave-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.cave-popup-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.cave-popup-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  max-height: 80px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Barra de desplazamiento discreta para descripción de popup */
.cave-popup-desc::-webkit-scrollbar {
  width: 4px;
}
.cave-popup-desc::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
.cave-popup-desc::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}
.cave-popup-desc::-webkit-scrollbar-thumb:hover {
  background: var(--accent-light);
}

/* Carrusel de imágenes compacto para el popup de Leaflet */
.cave-popup .cave-carousel {
  height: 125px;
  margin-top: 4px;
  margin-bottom: 4px;
}

.cave-popup-meta {
  display: flex;
  gap: 10px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.cave-popup-creator {
  font-size: 0.65rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: right;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 4px;
}

/* Custom Marker Icon (Círculo de pulso cristalino) */
.custom-cave-marker {
  display: flex;
  justify-content: center;
  align-items: center;
}

.marker-pin {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  background: var(--accent-light);
  position: absolute;
  transform: rotate(-45deg);
  left: 50%;
  top: 50%;
  margin: -11px 0 0 -11px;
  border: 2px solid var(--text-primary);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.marker-pin::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-primary);
  position: absolute;
}

.marker-pulse {
  background: rgba(20, 184, 166, 0.3);
  border-radius: 50%;
  height: 40px;
  width: 40px;
  position: absolute;
  margin: -20px 0 0 -20px;
  animation: pulse-ring 2s infinite;
  pointer-events: none;
}

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

/* ==========================================
   MODAL FLOTANTE MOCK OAUTH
   ========================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

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

.oauth-box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6), 
              0 0 40px rgba(20, 184, 166, 0.1);
  animation: modalScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.oauth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(7, 11, 18, 0.5);
  border-bottom: 1px solid var(--border-color);
}

.provider-badge {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 30px;
  color: white;
}

.google-badge {
  background: #ea4335;
}

.facebook-badge {
  background: #1877f2;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.oauth-body {
  padding: 24px;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.oauth-loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(20, 184, 166, 0.1);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.oauth-profile-selector h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  font-weight: 700;
}

.oauth-app-consent {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.4;
}

.oauth-profiles-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.oauth-profile-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.oauth-profile-item:hover {
  background: rgba(20, 184, 166, 0.05);
  border-color: var(--accent-color);
  transform: translateY(-2px);
}

.profile-pic {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background-size: cover;
  background-position: center;
}

.pic-explorer {
  background-image: url('https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&q=80&w=100');
}

.pic-cazador {
  background-image: url('https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?auto=format&fit=crop&q=80&w=100');
}

.pic-user {
  background-image: url('https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?auto=format&fit=crop&q=80&w=100');
}

.profile-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.profile-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.oauth-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn 0.4s ease;
}

.success-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 2px solid #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: bold;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.hidden {
  display: none !important;
}

/* ==========================================
   RESPONSIVIDAD
   ========================================== */
@media (max-width: 768px) {
  .app-body {
    flex-direction: column-reverse;
  }

  /* Desactivar animaciones durante el arrastre táctil */
  .app-body.resizing-mobile .map-wrapper,
  .app-body.resizing-mobile .sidebar {
    transition: none !important;
  }

  .mobile-drag-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 18px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    cursor: row-resize;
    z-index: 101;
    flex-shrink: 0;
    touch-action: none;
    padding-top: 2px;
  }
  
  .mobile-drag-handle-bar {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    transition: background 0.2s ease, transform 0.2s ease;
  }

  .mobile-drag-handle:active .mobile-drag-handle-bar {
    background: var(--accent-light);
    transform: scaleX(1.1);
  }
  
  .sidebar {
    width: 100% !important;
    flex: 1;
    height: auto;
    min-height: 0; /* Evita que el contenido largo empuje el mapa fuera del viewport */
    overflow: hidden; /* Mantiene el scroll contenido en .sidebar-content */
    border-right: none;
    border-top: 1px solid var(--border-color);
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), flex 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar-resizer {
    display: none !important;
  }
  
  .sidebar-tabs {
    overflow-x: auto;
    display: flex;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Oculta la barra de desplazamiento en Firefox */
  }
  .sidebar-tabs::-webkit-scrollbar {
    display: none; /* Oculta la barra de desplazamiento en Chrome/Safari */
  }
  .sidebar-tab {
    flex: 0 0 auto;
    padding: 14px 18px;
    font-size: 0.88rem;
    white-space: nowrap; /* Evita envolturas de línea en el carrusel de móvil */
  }
  
  .map-wrapper {
    height: 55%;
    flex: none;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
  }

  /* Indicador flotante en el mapa para avisar de la expansión */
  .map-wrapper::after {
    content: "Toca el mapa para ampliar 🔍";
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(4, 7, 20, 0.85);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-light);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
  }

  /* Ocultar el indicador cuando el mapa se expande */
  .app-body.map-expanded .map-wrapper::after {
    opacity: 0;
    visibility: hidden;
  }

  /* Estado del mapa ampliado en móviles */
  .app-body.map-expanded .map-wrapper {
    height: calc(100% - 120px);
  }

  .app-body.map-expanded .sidebar {
    flex: none;
    height: 120px;
    overflow: hidden;
  }
  
  .login-container {
    padding: 24px 20px;
    margin: 16px;
  }
  
  .social-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .app-header {
    padding: 0 12px;
  }

  /* Ocultar saludo y email del usuario en móviles para dar espacio al logo */
  .user-info {
    display: none !important;
  }

  /* Evitar que los créditos del mapa se enrollen y tapen el mapa en móvil */
  .leaflet-control-attribution {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ==========================================
   TRACKS DE ACCESO (RUTAS)
   ========================================== */
.cave-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.track-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.3);
  border-radius: 8px;
  color: var(--accent-light);
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.track-btn:hover {
  background: var(--accent-color);
  color: var(--text-primary);
  box-shadow: 0 0 10px var(--accent-glow);
  border-color: var(--accent-light);
}

.track-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border-color);
  color: var(--text-muted);
}

.track-btn.disabled:hover {
  box-shadow: none;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  border-color: var(--border-color);
}

.track-link-external {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.track-link-external:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: rgba(239, 83, 80, 0.08);
  border: 1px solid rgba(239, 83, 80, 0.3);
  border-radius: 8px;
  color: #ef5350; /* Rojo */
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.delete-btn:hover {
  background: #ef5350;
  color: var(--text-primary);
  box-shadow: 0 0 10px rgba(239, 83, 80, 0.25);
  border-color: #ef9a9a;
}

/* Animación del Sendero en el Mapa */
.leaflet-interactive.hiking-trail {
  stroke-dasharray: 8, 8;
  animation: trail-march 15s linear infinite;
  filter: drop-shadow(0 0 4px var(--accent-light));
}

@keyframes trail-march {
  to {
    stroke-dashoffset: -160;
  }
}

/* ==========================================
   HUD MODO SEGUIMIENTO GPX
   ========================================== */
.gpx-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 320px;
  max-width: 92vw;
  padding: 10px 14px;
  border-radius: 16px;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  background: rgba(15, 23, 42, 0.82);
  border: 1.5px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
  pointer-events: all;
}

.gpx-hud.hidden {
  display: none;
}

/* Estados de color del HUD */
.gpx-hud.green {
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(16, 185, 129, 0.55);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.25), 0 8px 32px rgba(0,0,0,0.4);
}
.gpx-hud.orange {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.25), 0 8px 32px rgba(0,0,0,0.4);
}
.gpx-hud.red {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.55);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3), 0 8px 32px rgba(0,0,0,0.4);
}

.gpx-hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.gpx-hud-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
  transition: background 0.4s ease;
  box-shadow: 0 0 0 0 transparent;
}
.gpx-hud.green  .gpx-hud-dot { background: #10b981; animation: hud-pulse-green  2s ease-in-out infinite; }
.gpx-hud.orange .gpx-hud-dot { background: #f59e0b; animation: hud-pulse-orange 2s ease-in-out infinite; }
.gpx-hud.red    .gpx-hud-dot { background: #ef4444; animation: hud-pulse-red    1.2s ease-in-out infinite; }

@keyframes hud-pulse-green  { 0%,100%{box-shadow:0 0 0 0 rgba(16,185,129,0.5)}  50%{box-shadow:0 0 0 6px rgba(16,185,129,0)} }
@keyframes hud-pulse-orange { 0%,100%{box-shadow:0 0 0 0 rgba(245,158,11,0.5)} 50%{box-shadow:0 0 0 6px rgba(245,158,11,0)} }
@keyframes hud-pulse-red    { 0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,0.6)}   50%{box-shadow:0 0 0 8px rgba(239,68,68,0)} }

.gpx-hud-texts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.gpx-hud-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1;
}

.gpx-hud-msg {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.4s ease;
}
.gpx-hud.green  .gpx-hud-msg { color: #6ee7b7; }
.gpx-hud.orange .gpx-hud-msg { color: #fcd34d; }
.gpx-hud.red    .gpx-hud-msg { color: #fca5a5; }

.gpx-hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.gpx-hud-dist {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

.gpx-hud-stop-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.07);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  font-family: var(--font-family);
}
.gpx-hud-stop-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

/* ==========================================
   MODAL NAVEGAR AL INICIO DEL SENDERO
   ========================================== */
.gpx-navigate-box {
  background: linear-gradient(145deg, var(--surface-dark) 0%, var(--bg-medium) 100%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  width: 92%;
  max-width: 440px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  animation: modal-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-slide-up {
  from { transform: translateY(40px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.gpx-navigate-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.gpx-navigate-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6));
}

.gpx-navigate-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px;
  line-height: 1.2;
}

.gpx-navigate-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
}

.gpx-navigate-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gpx-navigate-distance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.gpx-dist-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gpx-dist-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fcd34d;
  font-variant-numeric: tabular-nums;
}

.gpx-navigate-hint {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.gpx-navigate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gpx-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  border-radius: 12px;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-family);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.gpx-btn:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}
.gpx-btn:active {
  transform: translateY(0);
}

.gpx-btn-primary {
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  color: #fff;
  box-shadow: 0 4px 15px rgba(26, 115, 232, 0.4);
}

.gpx-btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-color);
}
.gpx-btn-secondary:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}



/* ==========================================
   MODAL DE VISUALIZACIÓN DE FICHA DE CUEVA (IN-APP VIEWER)
   ========================================== */
.file-viewer-box {
  width: 90%;
  max-width: 1100px;
  height: 85%;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6), 
              0 0 50px rgba(0, 51, 204, 0.2);
  display: flex;
  flex-direction: column;
  animation: modalScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.file-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(7, 11, 18, 0.6);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.file-viewer-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-viewer-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.file-viewer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-viewer-btn {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.file-viewer-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--accent-light);
}

.file-viewer-body {
  flex: 1;
  position: relative;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #111;
}

/* Spinner de carga para el iframe */
.file-viewer-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.file-viewer-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.file-viewer-loader .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.file-viewer-loader span {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Reset de estilo de botón de link si se usa tag button */
button.track-link-external {
  font-family: var(--font-family);
  cursor: pointer;
  outline: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .file-viewer-box {
    width: 95%;
    height: 90%;
  }
  .file-viewer-header {
    padding: 12px 16px;
  }
  .file-viewer-title {
    font-size: 0.95rem;
  }
}

/* ==========================================
   ELEMENTOS DE MODERACIÓN Y APROBACIÓN
   ========================================== */

/* Insignias de Moderación */
.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-modified {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Caja de revisión de cambios del Admin */
.admin-review-box {
  margin-top: 12px;
  padding: 12px;
  background: rgba(4, 7, 20, 0.6);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  font-size: 0.82rem;
}

.admin-review-title {
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-review-diff {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.admin-review-diff-item {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-review-diff-item:last-child {
  border-bottom: none;
}

.diff-label {
  color: var(--text-muted);
  font-weight: 600;
}

.diff-old {
  color: #ef5350;
  text-decoration: line-through;
  word-break: break-all;
}

.diff-new {
  color: #10b981;
  word-break: break-all;
  font-weight: 500;
}

.admin-review-actions {
  display: flex;
  gap: 8px;
}

.review-btn-approve {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  font-family: var(--font-family);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition-smooth);
  font-weight: 600;
}

.review-btn-approve:hover {
  background: #10b981;
  color: white;
}

.review-btn-reject {
  background: rgba(239, 83, 80, 0.15);
  border: 1px solid rgba(239, 83, 80, 0.3);
  color: #ef5350;
  font-family: var(--font-family);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition-smooth);
  font-weight: 600;
}

.review-btn-reject:hover {
  background: #ef5350;
  color: white;
}

/* ==========================================
   TARJETAS DE GESTIÓN DE USUARIOS
   ========================================== */
.user-card {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition-smooth);
}

.user-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--bg-glass-hover);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.user-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.user-provider-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
}

.user-provider-badge.local {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.user-provider-badge.google {
  background: rgba(234, 67, 53, 0.15);
  color: #ea4335;
  border: 1px solid rgba(234, 67, 53, 0.3);
}

.user-provider-badge.facebook {
  background: rgba(24, 119, 242, 0.15);
  color: #1877f2;
  border: 1px solid rgba(24, 119, 242, 0.3);
}

.user-role-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.65rem;
}

.user-role-badge.admin {
  background: rgba(239, 83, 80, 0.15);
  color: #ef5350;
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.user-role-badge.user {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.user-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.user-action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition-smooth);
  font-weight: 600;
}

.user-action-btn:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 51, 204, 0.3);
}

.user-action-btn.demote-btn:hover {
  background: #ef5350;
  color: white;
  border-color: #ef5350;
  box-shadow: 0 0 10px rgba(239, 83, 80, 0.3);
}

.user-action-btn.reset-pw-btn:hover {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.user-action-btn.delete-user-btn:hover {
  background: #d32f2f;
  color: white;
  border-color: #d32f2f;
  box-shadow: 0 0 10px rgba(211, 47, 47, 0.3);
}

/* Botón de geolocalización flotante */
.geolocation-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: var(--transition-smooth);
}

.geolocation-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--accent-light);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 51, 204, 0.4);
}

.geolocation-btn:active {
  transform: scale(0.95);
}

.geolocation-btn.active {
  background: rgba(0, 51, 204, 0.2);
  color: var(--accent-light);
  border-color: var(--accent-light);
  box-shadow: 0 0 15px rgba(255, 235, 59, 0.4);
}

/* Estilos para el marcador pulsante de ubicación actual del usuario */
.user-location-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-location-pulse {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 51, 204, 0.4);
  animation: user-location-pulse 2s infinite ease-out;
}

.user-location-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0033cc;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  z-index: 10;
}

@keyframes user-location-pulse {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* ==========================================
   SUBIDA DE FICHEROS (GPX E IMÁGENES)
   ========================================== */
.file-upload-group {
  margin-bottom: 15px;
}

.file-drop-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.file-drop-area:hover, .file-drop-area.is-dragover {
  background: rgba(0, 51, 204, 0.05);
  border-color: var(--accent-light);
}

.file-input {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}

.file-msg {
  font-size: 0.8rem;
  color: var(--text-secondary);
  pointer-events: none;
}

.image-preview-item {
  position: relative;
  width: 55px;
  height: 55px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(239, 83, 80, 0.85);
  color: white;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}

/* ==========================================
   CARRUSEL DE IMÁGENES (FICHA DE CUEVA)
   ========================================== */
.cave-carousel {
  position: relative;
  width: 100%;
  height: 190px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.2);
}

.cave-carousel-inner {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cave-carousel-item {
  min-width: 100%;
  height: 100%;
}

.cave-carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cave-carousel-control {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  font-size: 1rem;
  transition: var(--transition-smooth);
}

.cave-carousel-control:hover {
  background: var(--accent-color);
  border-color: var(--accent-light);
  transform: translateY(-50%) scale(1.08);
}

.cave-carousel-control:active {
  transform: translateY(-50%) scale(0.95);
}

.cave-carousel-control.prev {
  left: 10px;
}

.cave-carousel-control.next {
  right: 10px;
}

.cave-carousel-indicators {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
}

.cave-carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.cave-carousel-dot.active {
  background: white;
  transform: scale(1.3);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

/* ==========================================
   METADATOS PROFESIONALES DE ESPELEOLOGÍA
   ========================================== */
.speleo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 12px;
}

.speleo-grid-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.speleo-grid-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.speleo-grid-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.materials-box {
  background: rgba(245, 158, 11, 0.03);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  margin-bottom: 12px;
}

.materials-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #f59e0b;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.materials-content {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* ==========================================
   INTERACTIVIDAD DE LA FICHA EXPANDIBLE
   ========================================== */
.cave-item .cave-carousel,
.cave-item .speleo-grid,
.cave-item .materials-box {
  display: none;
}

.cave-item.active {
  background: var(--bg-glass-hover);
  border-color: var(--accent-light);
  box-shadow: 0 0 15px rgba(255, 235, 59, 0.15);
  cursor: default;
}

.cave-item.active:hover {
  transform: none;
  border-color: var(--accent-light);
}

.cave-item.active .cave-carousel {
  display: block;
}

.cave-item.active .speleo-grid {
  display: grid;
}

.cave-item.active .materials-box {
  display: block;
}

/* ==========================================
   ESTILOS DE AMPLIACIÓN DE IMÁGENES (LIGHTBOX)
   ========================================== */
.file-viewer-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid var(--border-color);
  background: #000;
}

/* ==========================================
   ESTILOS DE GRABACIÓN GPS EN VIVO
   ========================================== */
.record-status-dot-active {
  background: #ef4444 !important;
  box-shadow: 0 0 10px #ef4444;
  animation: recording-pulse 1.5s infinite ease-out;
}

@keyframes recording-pulse {
  0% {
    transform: scale(0.9);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.5;
  }
  100% {
    transform: scale(0.9);
    opacity: 1;
  }
}

.badge-pending-count {
  background-color: #f59e0b;
  color: #0b0f19;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  display: inline-block;
  vertical-align: middle;
}

.pending-status-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: #f59e0b;
  font-size: 0.8rem;
  margin-top: 10px;
  font-weight: 500;
}

.badge-revisar {
  background: rgba(236, 72, 153, 0.12) !important;
  border: 1px solid rgba(236, 72, 153, 0.3) !important;
  color: #f472b6 !important;
}

/* ==========================================
   ESTILOS DE LEYENDA DEL MAPA
   ========================================== */
.map-legend {
  background: var(--bg-glass) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid var(--border-color) !important;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.78rem;
  line-height: 1.5;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  margin-bottom: 15px;
  max-width: 250px;
}
.map-legend h4 {
  margin: 0 0 6px 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-light);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.legend-item:last-child {
  margin-bottom: 0;
}
.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .map-legend {
    font-size: 0.7rem;
    padding: 6px 10px;
    max-width: 155px;
    margin-bottom: 10px;
  }
  .map-legend h4 {
    font-size: 0.74rem;
    margin-bottom: 4px;
  }
  .legend-color {
    width: 8px;
    height: 8px;
  }
}
