/**
 * Custom Video Player Styles
 * Estilos para player de video personalizado
 */

.custom-player-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
}

.custom-player {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  background: transparent;
}

/* YouTube Player Container */
#youtubePlayer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#youtubePlayer iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* BLOQUEADOR SUPERIOR (título, compartir, ver más) - SIEMPRE ACTIVO */
.youtube-top-blocker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px; /* Altura de la barra superior de YouTube */
  z-index: 15;
  pointer-events: all; /* SIEMPRE bloqueado */
  background: transparent;
  cursor: default;
}

/* Bloquear también esquina superior derecha */
.youtube-top-blocker::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 60px;
  z-index: 16;
  pointer-events: all;
}

/* BLOQUEADOR CENTRAL del overlay "Más videos" de YouTube */
.youtube-overlay-blocker {
  position: absolute;
  top: 60px; /* Debajo del bloqueador superior */
  left: 0;
  width: 100%;
  height: calc(100% - 110px); /* No bloquear título arriba ni controles abajo */
  z-index: 5;
  pointer-events: none; /* Permitir clicks en el video para play/pausa */
  background: transparent;
  cursor: default;
}

/* Bloquear solo cuando hay overlay visible (pausado o terminado) */
.custom-player:not(.playing) .youtube-overlay-blocker {
  pointer-events: all; /* Bloquear clicks cuando está pausado */
  cursor: pointer;
}

/* Indicador visual al pasar mouse cuando está bloqueado */
.custom-player:not(.playing) .youtube-overlay-blocker:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Agregar un mensaje de "Click para continuar" cuando está pausado */
.custom-player:not(.playing) .youtube-overlay-blocker::after {
  content: 'Click para continuar ▶';
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 10;
}

.custom-player:not(.playing) .youtube-overlay-blocker:hover::after {
  opacity: 1;
}

/* Loading spinner */
.player-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  color: white;
  display: none;
}

.custom-player video:not([src]) ~ .player-loading {
  display: block;
}

.spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 1rem;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #4F46E5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Overlay de play inicial */
.player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.7));
  z-index: 5;
  cursor: pointer;
  transition: opacity 0.3s;
}

.player-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.play-button-large {
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
  margin-bottom: 1rem;
}

.play-button-large:hover {
  transform: scale(1.1);
}

.play-button-large svg {
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.video-title {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  text-align: center;
  padding: 0 2rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.video-description {
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
  margin: 0;
  text-align: center;
  padding: 0 2rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Controles personalizados */
.player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  padding: 1rem;
  z-index: 10;
  transition: opacity 0.3s;
}

.player-controls.hidden {
  opacity: 0;
}

.custom-player:hover .player-controls {
  opacity: 1;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  position: relative;
}

.progress-filled {
  height: 100%;
  background: #4F46E5;
  border-radius: 3px;
  transition: width 0.1s;
}

.progress-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.progress-bar:hover .progress-handle {
  opacity: 1;
}

.controls-bottom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  border-radius: 4px;
}

.control-btn:hover {
  transform: scale(1.1);
  background: rgba(255,255,255,0.1);
}

.control-btn svg {
  width: 24px;
  height: 24px;
}

.hidden {
  display: none !important;
}

.time-display {
  color: white;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  user-select: none;
}

.time-separator {
  opacity: 0.6;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

/* Panel de configuración */
.settings-panel {
  position: absolute;
  bottom: 80px;
  right: 1rem;
  background: rgba(0,0,0,0.95);
  border-radius: 8px;
  padding: 1rem;
  min-width: 180px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.settings-panel.hidden {
  display: none;
}

.settings-panel h4 {
  color: white;
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding-bottom: 0.5rem;
}

#qualityOptions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.quality-option {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: white;
  padding: 0.625rem 0.75rem;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  font-size: 0.875rem;
  position: relative;
}

.quality-option:hover {
  background: rgba(255,255,255,0.15);
}

.quality-option.active {
  background: #4F46E5;
  font-weight: 600;
}

.quality-option.active::after {
  content: '✓';
  position: absolute;
  right: 0.75rem;
  color: white;
}

/* Error state */
.video-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  padding: 2rem;
}

/* Fullscreen */
.custom-player-wrapper:fullscreen {
  border-radius: 0;
}

.custom-player-wrapper:fullscreen .custom-player {
  padding-bottom: 0;
  height: 100vh;
}

/* Responsive */
@media (max-width: 768px) {
  .video-title {
    font-size: 1.25rem;
  }
  
  .video-description {
    font-size: 0.875rem;
  }
  
  .volume-control {
    display: none;
  }
  
  .time-display {
    font-size: 0.75rem;
  }
  
  .player-controls {
    padding: 0.75rem;
  }
}
