/**
 * TopApp Video Interactivo - Frontend Stylesheet
 * Modern, responsive, glassmorphic UI
 */

:root {
  --topapp-brightness: 100%;
  --topapp-contrast: 100%;
  --topapp-saturate: 100%;
  --topapp-blur: 0px;
  --topapp-grayscale: 0%;
  --topapp-hue-rotate: 0deg;
  --topapp-invert: 0%;
  --topapp-sepia: 0%;
  --topapp-opacity: 1;
}

/* ==========================================================================
   Contenedor Raíz y Wrapper
   ========================================================================== */
.topapp-video-interactivo-root {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
}

.topapp-video-interactivo-root * {
  box-sizing: border-box;
}

.topapp-video-wrapper {
  position: relative;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   Modo Sticky (Scroll Pin / Apple Style)
   ========================================================================== */
.topapp-scroll-track {
  position: relative;
  width: 100%;
  background-color: #000000;
  /* La altura se asigna dinámicamente mediante inline style o CSS var (--topapp-track-height) */
}

.topapp-sticky-window {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #000000;
  z-index: 10;
}

/* Modo en flujo (no sticky) */
.topapp-mode-flow .topapp-video-container {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 350px;
  overflow: hidden;
}

/* ==========================================================================
   Contenedor del Video y Elemento de Video
   ========================================================================== */
.topapp-video-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #000000;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

/* Cursores según modo */
.topapp-interaction-drag_360 .topapp-video-container,
.topapp-interaction-hybrid .topapp-video-container {
  cursor: grab;
  touch-action: pan-y; /* Permite scroll vertical pero detecta gestos horizontales */
}

.topapp-interaction-drag_360.topapp-is-dragging .topapp-video-container,
.topapp-interaction-hybrid.topapp-is-dragging .topapp-video-container {
  cursor: grabbing !important;
}

.topapp-interaction-mouse_x .topapp-video-container,
.topapp-interaction-mouse_xy .topapp-video-container {
  cursor: ew-resize;
}

.topapp-video-element {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  background-color: transparent;
  display: block;
  transition: opacity 0.3s ease;
  will-change: filter, transform;
}

/* ==========================================================================
   Loader Spinner
   ========================================================================== */
.topapp-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  opacity: 1;
}

.topapp-loader.topapp-loaded {
  opacity: 0;
  visibility: hidden;
}

.topapp-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: topapp-spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Hint Badge Interactivo (Glassmorphic)
   ========================================================================== */
.topapp-hint-badge {
  position: absolute;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 9999px;
  background: rgba(20, 20, 24, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: #ffffff;
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.topapp-hint-badge.topapp-badge-hidden {
  opacity: 0;
  transform: translateY(12px) scale(0.95);
}

/* Posiciones de Badge */
.topapp-badge-pos-bottom-center {
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
}
.topapp-badge-pos-bottom-center.topapp-badge-hidden {
  transform: translate(-50%, 14px) scale(0.95);
}

.topapp-badge-pos-bottom-left {
  bottom: 28px;
  left: 28px;
}

.topapp-badge-pos-bottom-right {
  bottom: 28px;
  right: 28px;
}

.topapp-badge-pos-top-left {
  top: 28px;
  left: 28px;
}

.topapp-badge-pos-top-right {
  top: 28px;
  right: 28px;
}

.topapp-badge-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #60a5fa;
}

.topapp-icon-spin {
  animation: topapp-pulse 2.5s ease-in-out infinite;
}

@keyframes topapp-pulse {
  0%, 100% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.1);
  }
}

.topapp-badge-text-group {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.topapp-badge-title {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.topapp-badge-sub {
  font-family: inherit;
  font-size: 11px;
  opacity: 0.72;
}

/* ==========================================================================
   Botones de Control Flotantes
   ========================================================================== */
.topapp-ui-controls {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  gap: 10px;
  z-index: 25;
}

.topapp-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: rgba(20, 20, 24, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  cursor: pointer;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.topapp-control-btn:hover {
  background: rgba(40, 40, 48, 0.9);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-2px) scale(1.05);
}

.topapp-control-btn:active {
  transform: translateY(0) scale(0.95);
}

/* ==========================================================================
   Barra de Progreso Minimalista
   ========================================================================== */
.topapp-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  z-index: 20;
  pointer-events: none;
}

.topapp-progress-fill {
  width: 0%;
  height: 100%;
  background: #3b82f6;
  box-shadow: 0 0 12px #3b82f6;
  transition: width 0.05s linear;
}

/* ==========================================================================
   Modo Pantalla Completa
   ========================================================================== */
.topapp-video-container:fullscreen,
.topapp-video-container:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  background-color: #000000;
  border-radius: 0 !important;
}

/* ==========================================================================
   Ajustes Responsivos
   ========================================================================== */
@media (max-width: 767px) {
  .topapp-hint-badge {
    padding: 6px 12px;
    gap: 8px;
  }
  
  .topapp-badge-title {
    font-size: 11px;
  }

  .topapp-badge-sub {
    font-size: 9px;
  }

  .topapp-ui-controls {
    top: 14px;
    right: 14px;
    gap: 6px;
  }

  .topapp-control-btn {
    width: 32px;
    height: 32px;
  }
}
