/**
 * Museo VR Visor — Estilos frontend
 *
 * Estilos para el contenedor del visor A-Frame,
 * barra de controles interactivos (zoom, auto-rotación, reset, ayuda),
 * loading overlay, botón VR y soporte responsive.
 *
 * @package MuseoVR
 * @version 1.1.0
 */

/* ═══ Container ═══ */
.museo-vr-container {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #1a1a2e;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.museo-vr-container a-scene {
  display: block;
  width: 100%;
  height: 100%;
}

/* Mantener el tamaño CSS del canvas fijado estrictamente al 100% del contenedor.
   Evita que Three.js o A-Frame reduzcan o desplacen el canvas al rotar en iOS. */
.museo-vr-container a-scene > canvas.a-canvas {
  display: block !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

.museo-vr-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: var(--museo-vh, 100vh) !important;
  height: 100dvh !important; /* Navegadores modernos: viewport dinámico real */
  z-index: 999999 !important;
  border-radius: 0 !important;
}

/* ═══ Estado cuando Modo VR / Cardboard está activo ═══ */
body.museo-vr-mode-active {
  overflow: hidden !important;
  touch-action: none !important;
}

body.museo-vr-mode-active header,
body.museo-vr-mode-active footer,
body.museo-vr-mode-active #wpadminbar,
body.museo-vr-mode-active .site-header,
body.museo-vr-mode-active .site-footer {
  display: none !important;
}

.museo-vr-container.museo-vr-in-vr {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: var(--museo-vh, 100vh) !important;
  height: 100dvh !important;
  z-index: 9999999 !important;
  border-radius: 0 !important;
}

/* ═══ Safe Areas para iPhones con notch / Dynamic Island ═══ */
.museo-vr-fullscreen .museo-vr-controls-overlay {
  top: max(16px, env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
}

.museo-vr-fullscreen .museo-vr-enter-vr-btn,
.museo-vr-fullscreen .museo-vr-audio-toggle,
.museo-vr-fullscreen .museo-vr-info-btn {
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
}

/* Salida visible y táctil para pantalla completa, Cardboard y WebXR. */
.museo-vr-exit-immersive {
  position: absolute;
  top: max(72px, calc(env(safe-area-inset-top, 0px) + 64px));
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 100001;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 88px;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.museo-vr-container.museo-vr-fullscreen .museo-vr-exit-immersive,
.museo-vr-container.museo-vr-in-vr .museo-vr-exit-immersive,
.museo-vr-container.museo-vr-cardboard-active .museo-vr-exit-immersive,
.museo-vr-container:fullscreen .museo-vr-exit-immersive,
.museo-vr-container:-webkit-full-screen .museo-vr-exit-immersive {
  display: flex;
}

.museo-vr-exit-immersive:hover,
.museo-vr-exit-immersive:focus-visible {
  background: rgba(192, 57, 43, 0.95);
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

/* ═══ Loading overlay ═══ */
.museo-vr-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #2c3e50;
  color: #f8f9fa;
  z-index: 100;
  gap: 16px;
  transition: opacity 0.5s, visibility 0.5s;
}

.museo-vr-loading p {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.85;
  margin: 0;
}

.museo-vr-loading-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.museo-vr-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: #c0392b;
  border-radius: 50%;
  animation: museo-vr-spin 0.8s linear infinite;
}

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

/* ═══ Barra de Controles Frontend ═══ */
.museo-vr-controls-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
  pointer-events: none;
  gap: 10px;
}

.museo-vr-controls-overlay > * {
  pointer-events: auto;
}

/* Selector / Badge de sala */
.museo-vr-scene-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(44, 62, 80, 0.85);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.museo-vr-scene-badge .ctrl-icon {
  font-size: 14px;
}

.museo-vr-scene-switcher {
  background: transparent !important;
  color: #ffffff !important;
  border: none !important;
  font-family: 'Montserrat', sans-serif !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  padding: 0 4px !important;
  outline: none !important;
}

.museo-vr-scene-switcher option {
  background: #2c3e50;
  color: #ffffff;
}

/* Grupo de botones de acción */
.museo-vr-ctrl-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(44, 62, 80, 0.85);
  backdrop-filter: blur(8px);
  padding: 4px 8px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.museo-vr-ctrl-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.museo-vr-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.museo-vr-ctrl-btn:active {
  transform: scale(0.95);
}

.museo-vr-ctrl-btn.active {
  background: #c0392b;
}

/* ═══ VR Enter button ═══ */
.museo-vr-enter-vr-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(192, 57, 43, 0.45);
  transition: all 0.25s ease;
}

.museo-vr-enter-vr-btn:hover {
  background: #e74c3c;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(192, 57, 43, 0.6);
}

.museo-vr-enter-vr-btn span {
  font-size: 18px;
}

/* Ocultar el botón VR nativo de A-Frame */
.museo-vr-container .a-enter-vr-button {
  display: none !important;
}

/* ═══ Modal de Ayuda para Visitantes ═══ */
.museo-vr-help-modal {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.museo-vr-help-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  color: #1e293b;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3);
  font-family: 'Montserrat', sans-serif;
}

.museo-vr-help-card h4 {
  margin: 0 0 14px 0;
  font-size: 17px;
  color: #2c3e50;
}

.museo-vr-help-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
}

.museo-vr-help-card li {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
  color: #475569;
}

.museo-vr-btn-close-help {
  display: block;
  width: 100%;
  background: #2c3e50 !important;
  color: #ffffff !important;
  border: none !important;
  padding: 10px !important;
  border-radius: 8px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  text-align: center;
  transition: background 0.2s ease;
}

.museo-vr-btn-close-help:hover {
  background: #c0392b !important;
}

/* ═══ Error message ═══ */
.museo-vr-error {
  padding: 20px;
  background: #fef0ef;
  border: 1px solid #f5c6cb;
  border-left: 4px solid #c0392b;
  border-radius: 8px;
  color: #721c24;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
}

/* ═══ Responsivo ═══ */
@media (max-width: 768px) {
  .museo-vr-container {
    border-radius: 12px;
  }

  .museo-vr-controls-overlay {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .museo-vr-enter-vr-btn {
    bottom: 12px;
    right: 12px;
    padding: 8px 16px;
    font-size: 13px;
  }

  .museo-vr-audio-toggle {
    bottom: 12px;
    left: 12px;
    padding: 8px 14px;
    font-size: 12px;
  }

  .museo-vr-info-btn {
    bottom: 60px;
    left: 12px;
    padding: 8px 14px;
  }

  /* Drawer se convierte en bottom-sheet en móvil */
  .museo-vr-info-drawer {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 60vh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    transform: translateY(100%);
  }

  .museo-vr-info-drawer.open {
    transform: translateY(0);
  }

  /* Botón cerrar del drawer: zona tap mínima 44x44px para iOS */
  .museo-vr-info-drawer-close {
    width: 44px;
    height: 44px;
    font-size: 24px;
    top: 10px;
    right: 10px;
  }
}

/* ═══ Landscape mobile — optimización para orientación horizontal ═══ */
@media (max-width: 920px) and (orientation: landscape) {
  .museo-vr-container {
    border-radius: 0;
  }

  .museo-vr-controls-overlay {
    flex-direction: row;
    top: 8px;
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
  }

  .museo-vr-enter-vr-btn {
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
  }

  .museo-vr-audio-toggle {
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    left: max(8px, env(safe-area-inset-left, 0px));
  }

  .museo-vr-info-btn {
    bottom: max(48px, calc(env(safe-area-inset-bottom, 0px) + 40px));
    left: max(8px, env(safe-area-inset-left, 0px));
  }

  /* Drawer en landscape: panel lateral más estrecho */
  .museo-vr-info-drawer {
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 320px;
    max-width: 50%;
    height: 100%;
    border-radius: 0;
    transform: translateX(100%);
  }

  .museo-vr-info-drawer.open {
    transform: translateX(0);
  }
}

/* ═══ Audio Ambiental Toggle Button ═══ */
.museo-vr-audio-toggle {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(44, 62, 80, 0.85);
  backdrop-filter: blur(8px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.25s ease;
}

.museo-vr-audio-toggle:hover {
  background: rgba(44, 62, 80, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.museo-vr-audio-toggle.muted {
  opacity: 0.6;
}

.museo-vr-audio-toggle.muted .museo-vr-audio-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: #c0392b;
  transform: rotate(-45deg);
}

.museo-vr-audio-icon {
  position: relative;
  font-size: 16px;
  line-height: 1;
}

.museo-vr-audio-label {
  font-size: 12px;
}

/* ═══ Info Button (ⓘ Saber más) ═══ */
.museo-vr-info-btn {
  position: absolute;
  bottom: 72px;
  left: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(44, 62, 80, 0.9);
  backdrop-filter: blur(8px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
  animation: museo-vr-info-pulse 2s ease-in-out infinite;
}

.museo-vr-info-btn:hover {
  background: rgba(192, 57, 43, 0.9);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 24px rgba(192, 57, 43, 0.4);
  animation: none;
}

.museo-vr-info-btn-icon {
  font-size: 18px;
}

.museo-vr-info-btn-text {
  font-size: 13px;
}

@keyframes museo-vr-info-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); }
  50% { box-shadow: 0 4px 24px rgba(192, 57, 43, 0.5), 0 0 0 8px rgba(192, 57, 43, 0.1); }
}

/* ═══ Info Drawer (Panel Contextual) ═══ */
.museo-vr-info-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 42%;
  z-index: 80;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.4s;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* CRÍTICO: Cuando está cerrado, NO interceptar touch/pointer events */
  pointer-events: none;
  visibility: hidden;
}

.museo-vr-info-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
}

.museo-vr-info-drawer-inner {
  padding: 28px 24px;
  color: #f1f5f9;
  font-family: 'Montserrat', sans-serif;
}

.museo-vr-info-drawer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #f1f5f9;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.museo-vr-info-drawer-close:hover {
  background: rgba(192, 57, 43, 0.8);
  transform: scale(1.1);
}

.museo-vr-info-drawer-img {
  margin-bottom: 20px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.museo-vr-info-drawer-img img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  max-height: 200px;
}

.museo-vr-info-drawer-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 8px 0;
  line-height: 1.3;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(192, 57, 43, 0.6);
}

.museo-vr-info-drawer-desc {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.museo-vr-info-drawer-historia {
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.museo-vr-info-drawer-historia h4 {
  margin: 0 0 10px 0;
  font-size: 15px;
  font-weight: 700;
  color: #fbbf24;
}

.museo-vr-info-drawer-historia p {
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.7;
  margin: 0;
}

.museo-vr-info-drawer-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.museo-vr-info-meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.museo-vr-info-meta-item .meta-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.museo-vr-info-meta-item .meta-label {
  color: #94a3b8;
  font-weight: 600;
  white-space: nowrap;
}

.museo-vr-info-meta-item .meta-value {
  color: #e2e8f0;
  font-weight: 500;
}

/* ═══ Info Drawer Backdrop (sutil) ═══ */
.museo-vr-info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 75;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.museo-vr-info-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ═══ Touch optimization para elementos interactivos ═══ */
.museo-vr-ctrl-btn,
.museo-vr-enter-vr-btn,
.museo-vr-info-btn,
.museo-vr-audio-toggle,
.museo-vr-btn-close-help {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ═══ Help Modal: asegurar que no intercepte eventos cuando oculto ═══ */
.museo-vr-help-modal[style*="display: none"],
.museo-vr-help-modal[style*="display:none"] {
  pointer-events: none;
}

/* ═══ Ocultar modales y botones inyectados por defecto de A-Frame ═══ */
.a-orientation-modal,
.a-enter-vr-modal,
.a-enter-vr {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ═══ Toast informativo flotante (para activación de Modo Inmersivo / Giroscopio) ═══ */
.museo-vr-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 50px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 999999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-align: center;
  max-width: 90%;
  white-space: nowrap;
}

.museo-vr-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══ Modo Cardboard Estereoscópico (Pantalla Dividida en 2) ═══ */
.museo-vr-container.museo-vr-cardboard-active .museo-vr-controls-overlay,
.museo-vr-container.museo-vr-cardboard-active .museo-vr-enter-vr-btn,
.museo-vr-container.museo-vr-cardboard-active .museo-vr-info-btn,
.museo-vr-container.museo-vr-cardboard-active .museo-vr-audio-toggle {
  display: none !important;
}

.museo-vr-cardboard-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 99999;
  display: none;
}

.museo-vr-container.museo-vr-cardboard-active .museo-vr-cardboard-overlay {
  display: block;
}

/* Línea divisoria central para Cardboard */
.museo-vr-cardboard-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

.museo-vr-cardboard-divider::after {
  content: '🥽';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  background: rgba(15, 23, 42, 0.7);
  padding: 4px;
  border-radius: 50%;
  opacity: 0.7;
}


