/* =====================================================================
   XX Larga Noche de Museos · La Paz 2026
   Diseño MOBILE-FIRST tipo app nativa — "Aurora Nocturna"
   Base: móvil  →  @media (min-width:821px) escala a escritorio
   ===================================================================== */
:root {
  --navy-900: #0a0f1c;
  --navy-850: #0e1525;
  --navy-800: #111c30;
  --navy-700: #18253c;
  --navy-600: #233650;
  --amber:    #fbbf24;
  --amber-600:#f59e0b;
  --violet:   #8b5cf6;
  --cyan:     #22d3ee;
  --text:     #eef2f9;
  --text-dim: #93a1ba;
  --line:     rgba(255,255,255,.10);
  --glass:    rgba(14,21,37,.82);
  --radius:   18px;
  --radius-sm:12px;
  --shadow:   0 16px 48px rgba(0,0,0,.5);
  --shadow-sm:0 6px 18px rgba(0,0,0,.4);
  --grad-amber: linear-gradient(135deg, #fbbf24, #f59e0b);
  --grad-cool:  linear-gradient(135deg, #8b5cf6, #22d3ee);
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--navy-900); color: var(--text);
  -webkit-font-smoothing: antialiased; overflow: hidden;
  overscroll-behavior: none;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(80vw 40vh at 90% -5%, rgba(139,92,246,.20), transparent 60%),
    radial-gradient(70vw 35vh at -10% 105%, rgba(34,211,238,.14), transparent 60%);
}
a { color: var(--amber); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }

.app { position: relative; z-index: 1; height: 100vh; height: 100dvh; }

/* ============ TOPBAR ============ */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--sat)) 14px 10px;
  background: linear-gradient(180deg, var(--navy-900) 30%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand .logo { font-size: 1.45rem; filter: drop-shadow(0 2px 6px rgba(251,191,36,.45)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b {
  font-size: 1.04rem; letter-spacing: .2px;
  background: linear-gradient(90deg, #fff, #c7d2e0);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand-text small { color: var(--amber); font-weight: 700; font-size: .68rem; letter-spacing: .3px; }

.icon-btn {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border-radius: 14px; font-size: 1.1rem;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: .18s;
}
.icon-btn:active { transform: scale(.92); }
.admin-link { margin-left: auto; }

/* ============ BÚSQUEDA FLOTANTE ============ */
.search-float {
  position: absolute; left: 12px; right: 12px; z-index: 990;
  top: calc(62px + var(--sat));
  pointer-events: none;
}
.search-float > * { pointer-events: auto; }
.search-wrap { position: relative; }
.search-ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-size: 1rem; opacity: .75; }
.search-wrap input {
  width: 100%; padding: 13px 42px 13px 42px;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  font-size: .95rem; outline: none; box-shadow: var(--shadow-sm);
}
.search-wrap input::placeholder { color: var(--text-dim); }
.search-wrap input:focus { border-color: rgba(251,191,36,.6); }
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; background: var(--navy-700);
  color: var(--text-dim); font-size: .8rem; display: none;
}
.search-wrap.has-text .search-clear { display: grid; place-items: center; }

/* Chips de zona (scroll horizontal) */
.chips {
  display: flex; gap: 8px; margin-top: 10px; overflow-x: auto;
  padding-bottom: 2px; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); color: var(--text-dim); white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: .15s;
}
.chip:active { transform: scale(.94); }
.chip.active { background: var(--grad-amber); color: #1a1206; border-color: transparent; }

/* ============ MAPA ============ */
.map-wrap { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: var(--navy-900); }

/* Controles flotantes (lado derecho, alcance del pulgar) */
.map-ctrls {
  position: absolute; right: 12px; z-index: 800;
  bottom: calc(var(--nav-h) + var(--sab) + 130px);
  display: flex; flex-direction: column; gap: 11px;
}
.map-btn {
  width: 50px; height: 50px; border-radius: 16px; font-size: 1.25rem;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); color: var(--text);
  display: grid; place-items: center; box-shadow: var(--shadow-sm); transition: .16s;
}
.map-btn:active { transform: scale(.9); }
.map-btn.primary { background: var(--grad-amber); color: #1a1206; border-color: transparent; box-shadow: 0 6px 18px rgba(245,158,11,.4); }
.map-btn.activo { background: var(--grad-cool); color: #fff; border-color: transparent; }
.map-btn.cargando .mb-ico { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tarjeta de ruta */
.ruta-card {
  position: absolute; left: 12px; right: 12px; z-index: 810;
  bottom: calc(var(--nav-h) + var(--sab) + 76px);
  display: none; align-items: center; gap: 12px;
  padding: 13px 14px; border-radius: 16px;
  background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(251,191,36,.45); box-shadow: var(--shadow);
}
.ruta-card.show { display: flex; animation: slideUp .25s; }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.ruta-ico { font-size: 1.3rem; }
.ruta-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ruta-info b { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ruta-info span { font-size: .82rem; color: var(--amber); font-weight: 700; }
.ruta-cerrar { margin-left: auto; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--navy-700); color: var(--text); font-size: .82rem; }

/* ============ HOJA DE CAPAS ============ */
.sheet-bg {
  position: fixed; inset: 0; z-index: 1190; background: rgba(5,9,16,.5);
  opacity: 0; visibility: hidden; transition: .25s;
}
.sheet-bg.show { opacity: 1; visibility: visible; }
.capas-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200;
  background: var(--navy-850); border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0; box-shadow: var(--shadow);
  padding: 10px 18px calc(22px + var(--sab));
  transform: translateY(110%); transition: transform .3s cubic-bezier(.34,1.2,.64,1);
}
.capas-sheet.open { transform: translateY(0); }
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: var(--navy-600); margin: 4px auto 14px; }
.capas-sheet h4 { margin: 0 0 14px; font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.capas-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.capa-opt { border-radius: 13px; overflow: hidden; border: 2px solid transparent; background: var(--navy-700); transition: .15s; }
.capa-opt:active { transform: scale(.95); }
.capa-opt.sel { border-color: var(--amber); }
.capa-opt .swatch { height: 56px; background-size: cover; background-position: center; }
.capa-opt span { display: block; text-align: center; font-size: .72rem; padding: 6px 2px; color: var(--text-dim); }
.capa-opt.sel span { color: var(--amber); font-weight: 700; }

/* ============ LISTA (bottom sheet) ============ */
.lista-sheet {
  position: absolute; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--sab)); z-index: 880;
  height: 62vh; max-height: 640px;
  background: var(--navy-850); border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  transform: translateY(calc(100% + var(--nav-h) + var(--sab)));
  transition: transform .32s cubic-bezier(.34,1.1,.64,1);
}
.lista-sheet.open { transform: translateY(0); }
.lista-sheet .sheet-handle { cursor: grab; padding: 0; margin: 8px auto 8px; }
.lista-head {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 16px 12px; border-bottom: 1px solid var(--line);
}
.contador { font-size: .82rem; color: var(--text); font-weight: 700; }
.mini-select {
  margin-left: auto; padding: 8px 11px; border-radius: 10px;
  background: var(--navy-700); color: var(--text); border: 1px solid var(--line);
  font-size: .82rem; max-width: 56%;
}
.lista { flex: 1; overflow-y: auto; padding: 10px 12px calc(16px + var(--sab)); -webkit-overflow-scrolling: touch; }
.lista::-webkit-scrollbar { width: 7px; }
.lista::-webkit-scrollbar-thumb { background: var(--navy-600); border-radius: 7px; }

.card {
  display: flex; gap: 12px; padding: 11px; margin-bottom: 9px;
  background: var(--navy-800); border: 1px solid var(--line);
  border-radius: var(--radius); transition: transform .14s, border-color .14s;
}
.card:active { transform: scale(.98); border-color: rgba(251,191,36,.5); }
.card .thumb {
  width: 60px; height: 60px; flex: none; border-radius: 13px;
  background: var(--navy-600) center/cover no-repeat;
  display: grid; place-items: center; font-size: 1.5rem;
}
.card .info { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.card .info b { font-size: .93rem; margin-bottom: 3px; line-height: 1.2; }
.card .info span { color: var(--text-dim); font-size: .77rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; width: fit-content; font-size: .63rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #1a1206; margin-top: 5px; background: var(--grad-amber); letter-spacing: .4px; }

/* ============ BARRA INFERIOR ============ */
.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1000;
  height: calc(var(--nav-h) + var(--sab)); padding-bottom: var(--sab);
  display: flex; align-items: stretch;
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-dim); font-size: .68rem; font-weight: 600; transition: .15s; position: relative;
}
.nav-btn .nav-ico { font-size: 1.3rem; transition: transform .15s; filter: grayscale(.4) opacity(.8); }
.nav-btn:active .nav-ico { transform: scale(.85); }
.nav-btn.active { color: var(--amber); }
.nav-btn.active .nav-ico { filter: none; transform: translateY(-1px); }
.nav-btn.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 3px; background: var(--grad-amber);
}

/* ============ MARCADORES ============ */
.marker-pin {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2.5px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.55); position: relative;
}
.marker-pin::after { content: ''; position: absolute; inset: 6px; background: #fff; border-radius: 50%; transform: rotate(45deg); }
.marker-pin.has360 { box-shadow: 0 0 0 4px rgba(251,191,36,.45), 0 4px 10px rgba(0,0,0,.55); animation: pulse360 2s infinite; }
@keyframes pulse360 {
  0%,100% { box-shadow: 0 0 0 4px rgba(251,191,36,.45), 0 4px 10px rgba(0,0,0,.55); }
  50%     { box-shadow: 0 0 0 9px rgba(251,191,36,.1), 0 4px 10px rgba(0,0,0,.55); }
}
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--cyan); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(34,211,238,.3), 0 2px 8px rgba(0,0,0,.4); }

/* Popups Leaflet en tema oscuro */
.leaflet-popup-content-wrapper { background: var(--navy-800); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--navy-800); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; font-size: .86rem; }
.leaflet-popup-content a { font-weight: 700; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-dim); }
.leaflet-control-zoom { display: none; } /* en móvil usamos pellizco */
.leaflet-control-attribution { background: rgba(10,15,28,.7) !important; color: var(--text-dim) !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* ============ MODAL / 360 ============ */
.modal-bg {
  position: fixed; inset: 0; z-index: 2000; padding: 0;
  background: rgba(5,9,16,.8); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-bg.open { display: flex; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-height: 94vh; overflow: hidden;
  background: var(--navy-850); border: 1px solid var(--line);
  border-radius: 24px 24px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: sheetUp .3s cubic-bezier(.34,1.15,.64,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal .pano { width: 100%; height: 250px; background: #000; }
.modal .pano-empty { height: 180px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: var(--text-dim); background: linear-gradient(135deg, var(--navy-700), var(--navy-800)); }
.modal .pano-empty .pe-ico { font-size: 2.3rem; opacity: .8; }
.modal .body { padding: 18px 18px calc(22px + var(--sab)); overflow-y: auto; }
.modal .body h2 { margin: 0 0 8px; font-size: 1.3rem; }
.modal .meta { color: var(--text-dim); font-size: .86rem; margin-bottom: 13px; display: flex; flex-wrap: wrap; gap: 7px 15px; }
.modal .meta b { color: var(--text); }
.modal .body p { line-height: 1.6; color: #c8d2e2; margin: 0; }
.acciones-modal { display: flex; gap: 10px; margin-top: 16px; }
.btn-ruta {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--grad-amber); color: #1a1206; font-weight: 700;
  padding: 13px 14px; border-radius: 14px; font-size: .9rem; box-shadow: 0 6px 16px rgba(245,158,11,.3); transition: .15s;
}
.btn-ruta:active { transform: scale(.96); }
.btn-ruta.sec { background: var(--navy-700); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.modal .galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px,1fr)); gap: 8px; margin-top: 18px; }
.modal .galeria img { width: 100%; height: 78px; object-fit: cover; border-radius: 11px; }
.modal .close {
  position: absolute; top: 12px; right: 14px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff;
  font-size: 1.4rem; display: grid; place-items: center; transition: .15s;
}
.modal .close:active { transform: scale(.9); }

/* ============ TOAST ============ */
.toast {
  position: fixed; left: 50%; z-index: 3000;
  bottom: calc(var(--nav-h) + var(--sab) + 20px); transform: translateX(-50%) translateY(20px);
  background: var(--navy-700); color: var(--text); border: 1px solid var(--line);
  padding: 12px 20px; border-radius: 999px; font-size: .86rem; box-shadow: var(--shadow);
  opacity: 0; transition: .3s; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =====================================================================
   ESCRITORIO / TABLET  (≥ 821px) — el layout cambia a 2 columnas
   ===================================================================== */
@media (min-width: 821px) {
  :root { --nav-h: 0px; --topbar-h: 62px; }

  .topbar {
    height: var(--topbar-h); padding: 0 22px;
    background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .brand-text b { font-size: 1.08rem; }
  .brand-text small { font-size: .66rem; text-transform: uppercase; letter-spacing: 1.2px; }

  /* 2 columnas: lista (sidebar izq) + mapa (der) bajo la topbar */
  .lista-sheet {
    position: absolute; top: var(--topbar-h); left: 0; bottom: 0; right: auto;
    width: 380px; height: auto; max-height: none;
    border-radius: 0; border-top: none; border-right: 1px solid var(--line);
    transform: none !important; box-shadow: none;
    background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    z-index: 700;
  }
  .lista-sheet .sheet-handle { display: none; }
  .map-wrap { top: var(--topbar-h); left: 380px; }

  /* Búsqueda dentro de la columna izquierda */
  .search-float { left: 14px; right: auto; top: calc(var(--topbar-h) + 12px); width: 352px; z-index: 750; }

  /* Controles del mapa arriba a la derecha */
  .map-ctrls { top: 16px; bottom: auto; right: 16px; }
  .ruta-card { bottom: 22px; left: 50%; right: auto; transform: translateX(-50%); min-width: 320px; max-width: 460px; }
  .ruta-card.show { transform: translateX(-50%); }

  /* Capas como popover, no hoja */
  .sheet-bg { display: none; }
  .capas-sheet {
    position: absolute; left: auto; right: 76px; bottom: auto; top: 16px;
    width: 260px; border-radius: var(--radius); border: 1px solid var(--line);
    padding: 14px 16px 18px;
    transform: translateY(8px) scale(.97); transition: .2s; visibility: hidden; opacity: 0;
  }
  .capas-sheet .sheet-handle { display: none; }
  .capas-sheet.open { transform: translateY(0) scale(1); visibility: visible; opacity: 1; }

  .bottom-nav { display: none; }
  .leaflet-control-zoom { display: block; }

  /* Modal centrado tipo diálogo */
  .modal-bg { align-items: center; padding: 20px; }
  .modal { width: min(920px, 94vw); max-height: 92vh; border-radius: 22px; animation: pop .24s cubic-bezier(.34,1.4,.64,1); }
  @keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  .modal .pano { height: 400px; }
  .acciones-modal .btn-ruta { flex: initial; }
  .toast { bottom: 30px; }

  .card:hover { border-color: rgba(251,191,36,.5); transform: translateY(-2px); }
  .map-btn:hover { transform: translateY(-1px); }
}

@media (min-width: 1600px) {
  .lista-sheet { width: 440px; }
  .map-wrap { left: 440px; }
  .search-float { width: 412px; }
  .modal .pano { height: 460px; }
}

/* Accesibilidad: menos movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .05ms !important; }
}
