/* ============================================================
   /mapa/css/mapa.css — Estilos del mapa (scoped a #mapa-app)
   ============================================================ */

/* Contenedor principal */
#mapa-app {
  position: relative;
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 500px;
  margin: 1rem auto;
  max-width: 1400px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(139, 58, 31, 0.15);
  background: #FFF8F0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #2D1B13;
  --primary: #C75B39;
  --primary-dark: #8B3A1F;
  --primary-light: #E88C6D;
  --bg: #FFF8F0;
  --bg-alt: #FDF0E3;
  --text: #2D1B13;
  --text-secondary: #6B4D3D;
  --card-bg: #FFFFFF;
  --card-shadow: 0 2px 12px rgba(139, 58, 31, 0.12);
  --panel-shadow: 0 -4px 20px rgba(45, 27, 19, 0.15);
  --border: #E5D5C8;
  --audio-bar-height: 64px;
  --fab-size: 48px;
  --fab-gap: 16px;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --transition-fast: 0.2s ease;
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#mapa-app *,
#mapa-app *::before,
#mapa-app *::after { box-sizing: border-box; }

/* ===== Pantalla completa ===== */
#mapa-app:fullscreen,
#mapa-app:-webkit-full-screen,
#mapa-app:-moz-full-screen {
  height: 100vh !important;
  width: 100vw !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
}
#mapa-app:fullscreen .panel { max-height: 40vh; }
#mapa-app:fullscreen .panel.expanded { max-height: 70vh; }

/* ===== Mapa ===== */
#map.mapa-page {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ===== Panel inferior ===== */
#mapa-app .panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--card-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--panel-shadow);
  max-height: 40vh;
  min-height: 120px;
  overflow: hidden;
  transition: transform var(--transition-smooth), max-height var(--transition-smooth);
  transform: translateY(0);
}
#mapa-app .panel.collapsed { transform: translateY(calc(100% - 50px)); }
#mapa-app .panel.expanded { max-height: 70vh; overflow-y: auto; }
#mapa-app .panel-handle {
  width: 40px;
  height: 4px;
  background: #DCD0C8;
  border-radius: 2px;
  margin: 10px auto 6px;
}
#mapa-app .panel-content {
  padding: 4px 20px 20px;
  max-height: calc(40vh - 30px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#mapa-app .panel.expanded .panel-content { max-height: calc(70vh - 30px); }
#mapa-app .panel-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px 16px;
  font-size: 15px;
  line-height: 1.6;
}

/* Detalle de punto */
#mapa-app .point-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
#mapa-app .point-category-icon { font-size: 40px; flex-shrink: 0; line-height: 1; }
#mapa-app .point-title-area { flex: 1; min-width: 0; }
#mapa-app .point-title { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.2; margin-bottom: 4px; }
#mapa-app .point-distance { font-size: 13px; color: var(--primary); font-weight: 600; display: flex; align-items: center; gap: 4px; }
#mapa-app .point-short-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin: 8px 0 14px; }
#mapa-app .point-full-desc {
  font-size: 14px; color: var(--text); line-height: 1.7;
  display: none; padding-top: 8px;
  border-top: 1px solid var(--border); margin-top: 8px;
}
#mapa-app .point-full-desc.visible { display: block; }
#mapa-app .panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Botones */
#mapa-app .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 25px; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all var(--transition-fast); font-family: inherit;
  white-space: nowrap; text-decoration: none;
}
#mapa-app .btn-primary {
  background: var(--primary); color: #FFF;
  box-shadow: 0 2px 8px rgba(199, 91, 57, 0.3);
}
#mapa-app .btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
#mapa-app .btn-primary:active { transform: scale(0.97); }
#mapa-app .btn-outline {
  background: var(--card-bg); color: var(--primary);
  border: 2px solid var(--primary);
}
#mapa-app .btn-outline:hover { background: var(--bg-alt); }
#mapa-app .btn-play {
  width: 48px; height: 48px; border-radius: 50%; padding: 0;
  font-size: 20px;
}
#mapa-app .btn-patrimonio {
  display: inline-block; text-decoration: none;
  padding: 8px 16px; border: 2px solid var(--primary);
  border-radius: 8px; color: var(--primary);
  font-weight: 600; font-size: 14px; text-align: center;
  transition: all 0.2s;
}
#mapa-app .btn-patrimonio:active { background: var(--primary); color: #fff; }

/* ===== Lista ===== */
#mapa-app #list-view {
  position: absolute; inset: 0; z-index: 800;
  background: var(--bg);
  transition: transform var(--transition-smooth);
  overflow: hidden; display: flex; flex-direction: column;
}
#mapa-app #list-view.hidden { transform: translateX(110%); }
#mapa-app #list-view:not(.hidden) { transform: translateX(0); }
#mapa-app .list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#mapa-app .list-header h2 { font-size: 20px; font-weight: 700; color: var(--text); margin: 0; }
#mapa-app .list-count {
  background: var(--primary); color: #FFF;
  font-size: 13px; font-weight: 700;
  min-width: 26px; height: 26px; padding: 0 8px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
}
#mapa-app .list-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 16px 100px;
}
#mapa-app .list-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-bg); border-radius: var(--radius-md);
  padding: 14px; margin-bottom: 10px;
  box-shadow: var(--card-shadow); cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
#mapa-app .list-item:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(139, 58, 31, 0.08);
}
#mapa-app .list-item-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  background: var(--bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; flex-shrink: 0;
}
#mapa-app .list-item-info { flex: 1; min-width: 0; }
#mapa-app .list-item-name {
  font-size: 16px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mapa-app .list-item-category { font-size: 12px; color: var(--text-secondary); margin: 2px 0; }
#mapa-app .list-item-dist { font-size: 13px; color: var(--primary); font-weight: 600; }

/* ===== FABs ===== */
#mapa-app .fab {
  position: absolute; z-index: 950;
  width: var(--fab-size); height: var(--fab-size);
  border-radius: 50%; border: none;
  background: var(--card-bg);
  box-shadow: 0 4px 16px rgba(45, 27, 19, 0.2);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition-fast);
  line-height: 1;
}
#mapa-app .fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(45, 27, 19, 0.25); }
#mapa-app .fab:active { transform: scale(0.94); }
#mapa-app .gps-fab { bottom: calc(120px + var(--fab-gap)); right: var(--fab-gap); }
#mapa-app .gps-fab.locating {
  animation: pulse 1.2s ease-in-out infinite;
  background: var(--primary-light); color: #FFF;
}
#mapa-app .view-fab { bottom: calc(120px + 68px); right: var(--fab-gap); }
#mapa-app .fs-fab { bottom: calc(120px + 68px + 68px); right: var(--fab-gap); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(199, 91, 57, 0.4); }
  50%      { box-shadow: 0 0 0 12px rgba(199, 91, 57, 0); }
}

/* ===== Audio ===== */
#mapa-app .audio-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  z-index: 910; height: var(--audio-bar-height);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(45, 27, 19, 0.1);
  display: flex; align-items: center;
  padding: 0 8px; gap: 10px;
  transition: transform var(--transition-smooth);
}
#mapa-app .audio-bar.hidden { transform: translateY(100%); }
#mapa-app .audio-close {
  background: none; border: none; font-size: 18px;
  color: var(--text-secondary); cursor: pointer;
  flex-shrink: 0; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
#mapa-app .audio-close:hover { background: var(--bg-alt); }
#mapa-app .audio-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#mapa-app .audio-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mapa-app .audio-progress-container {
  height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden; width: 100%;
}
#mapa-app .audio-progress {
  height: 100%; background: var(--primary);
  border-radius: 2px; transition: width 0.3s linear; width: 0%;
}
#mapa-app .audio-time { font-size: 11px; color: var(--text-secondary); }
#mapa-app .audio-play-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #FFF; border: none;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all var(--transition-fast);
}
#mapa-app .audio-play-btn:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ===== Notificación ===== */
#mapa-app .notification {
  position: absolute; top: 16px; left: 50%;
  transform: translateX(-50%); z-index: 1100;
  background: var(--primary-dark); color: #FFF;
  padding: 14px 24px; border-radius: 28px;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(139, 58, 31, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition-smooth);
  max-width: calc(100% - 40px);
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mapa-app .notification.visible { opacity: 1; pointer-events: auto; }

/* ===== Leaflet overrides ===== */
#mapa-app .leaflet-control-zoom { display: none; }
#mapa-app .custom-marker {
  background: var(--primary);
  border: 3px solid #FFF;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(139, 58, 31, 0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #FFF;
  transition: transform 0.2s ease;
}
#mapa-app .custom-marker.selected {
  background: var(--primary-dark);
  transform: scale(1.2);
  border-color: #FFD8C8;
  z-index: 1000 !important;
}
#mapa-app .user-location-marker {
  background: #4285F4;
  border: 3px solid #FFF;
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(66, 133, 244, 0.4);
  display: flex; align-items: center; justify-content: center;
}
#mapa-app .user-location-dot {
  width: 18px; height: 18px;
  background: #FFF; border-radius: 50%;
}

/* ===== GPS Alert ===== */
#mapa-app .gps-alert {
  position: absolute; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
#mapa-app .gps-alert-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px; margin: 24px; max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
#mapa-app .gps-alert-content p {
  margin-bottom: 20px; font-size: 1.05em;
  color: var(--text); line-height: 1.5;
}
#mapa-app .gps-alert-buttons { display: flex; gap: 12px; justify-content: center; }
#mapa-app .gps-alert-buttons .btn { flex: 1; max-width: 140px; justify-content: center; }

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #mapa-app {
    height: calc(100vh - 260px);
    margin: 0.5rem;
    border-radius: 8px;
  }
  #mapa-app .gps-fab  { bottom: calc(120px + 8px); right: 8px; }
  #mapa-app .view-fab { bottom: calc(120px + 60px); right: 8px; }
  #mapa-app .fs-fab   { bottom: calc(120px + 112px); right: 8px; }
}

@media (min-width: 1024px) {
  #mapa-app .gps-fab  { bottom: 24px;  right: 24px; }
  #mapa-app .view-fab { bottom: 84px;  right: 24px; display: none; }
  #mapa-app .fs-fab   { bottom: 144px; right: 24px; }
  #mapa-app #list-view {
    max-width: 380px; right: auto;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 20px rgba(45, 27, 19, 0.08);
  }
  #mapa-app #list-view.hidden { transform: translateX(-110%); }
  #mapa-app #list-view:not(.hidden) { transform: translateX(0); }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  #mapa-app *,
  #mapa-app *::before,
  #mapa-app *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   MarkerCluster — estilo personalizado
   ============================================================ */

/* El contenedor del cluster no debe tener fondo propio */
#mapa-app .marker-cluster-wrapper {
  background: transparent !important;
  border: none !important;
}

/* Círculo con número (todos los tamaños) */
#mapa-app .marker-cluster {
  background: rgba(199, 91, 57, 0.85) !important;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  box-shadow: 0 3px 12px rgba(139, 58, 31, 0.5);
  transition: transform 0.2s ease;
}
#mapa-app .marker-cluster:hover {
  transform: scale(1.1);
  background: rgba(139, 58, 31, 0.9) !important;
}
#mapa-app .marker-cluster div {
  background: transparent !important;
  color: #fff !important;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  margin: 0;
  width: auto;
  height: auto;
}

/* Para tamaños pequeños, medianos y grandes (los usamos iguales) */
#mapa-app .marker-cluster-small,
#mapa-app .marker-cluster-medium,
#mapa-app .marker-cluster-large {
  background: rgba(199, 91, 57, 0.85) !important;
}
#mapa-app .marker-cluster-small div,
#mapa-app .marker-cluster-medium div,
#mapa-app .marker-cluster-large div {
  background: transparent !important;
  color: #fff !important;
}