/**
 * Inspenet TV Player Styles
 * Custom HLS player with seek bar, PiP, quality & subtitles
 */

/* Container */
/* Contenedor principal debe tener position relative o absolute */
.tv-player {
    aspect-ratio: 16/9;
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: #000; /* Fallback */
}

/* El layer del background */
.tv-player__background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    
    /* Opcional: Oscurecer el fondo o aplicar blur para un look más moderno */
    /* filter: blur(8px) brightness(0.6); */
    /* transform: scale(1.05); /* Evita bordes blancos causados por el blur */
}

/* Asegurar que el video/iframe esté por encima del background */
.tv-player__video {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
}

/* Big play button (center) */
.tv-player__big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.tv-player__big-play svg {
  width: 40px;
  height: 40px;
  margin-left: 4px;
}

.tv-player__big-play:hover {
  background: rgba(30, 136, 229, 0.9);
  transform: translate(-50%, -50%) scale(1.1);
}

.tv-player__big-play:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.tv-player__big-play:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.tv-player__big-play--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.8);
}

/* Controls wrapper */
.tv-player__controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tv-player:hover .tv-player__controls,
.tv-player:focus-within .tv-player__controls,
.tv-player--playing .tv-player__controls:hover {
  opacity: 1;
}

/* Auto-hide (JS override - must be after hover rules for priority) */
.tv-player--controls-hidden {
  cursor: none;
}

.tv-player.tv-player--controls-hidden .tv-player__controls {
  opacity: 0 !important;
  pointer-events: none !important;
}

.tv-player.tv-player--controls-hidden .tv-player__big-play {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Progress bar wrapper */
.tv-player__progress-wrapper {
  position: relative;
  padding: 12px 16px 4px;
  cursor: pointer;
}

.tv-player__progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  transition: height 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
}

.tv-player__progress-wrapper:hover .tv-player__progress-track {
  height: 6px;
}

.tv-player__progress-buffer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  transition: width 0.3s ease;
  pointer-events: none;
}

.tv-player__progress-filled {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: #1e88e5;
  border-radius: 2px;
  pointer-events: none;
  transition: width 0.05s linear;
}

.tv-player__progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  background: #1e88e5;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.tv-player__progress-wrapper:hover .tv-player__progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

/* Progress tooltip */
.tv-player__progress-tooltip {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: system-ui, -apple-system, sans-serif;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  margin-bottom: 8px;
}

.tv-player__progress-tooltip--visible {
  opacity: 1;
}

/* Controls bar */
.tv-player__controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
}

/* Control groups */
.tv-player__controls-left,
.tv-player__controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.tv-player__btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.tv-player__btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.tv-player__btn:active {
  transform: scale(0.95);
}

.tv-player__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.tv-player__btn svg {
  width: 22px;
  height: 22px;
  transition: opacity 0.2s ease;
}

/* Volume slider */
.tv-player__volume-slider {
  width: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  opacity: 0;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.tv-player__controls-left:hover .tv-player__volume-slider {
  width: 80px;
  opacity: 1;
  margin-left: -4px;
}

.tv-player__volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.tv-player__volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

.tv-player__volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
}

/* Time display */
.tv-player__time {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

/* Menus (quality, subtitles) */
.tv-player__menu {
  position: absolute;
  bottom: 56px;
  right: 16px;
  background: rgba(20, 20, 20, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 8px 0;
  min-width: 160px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.tv-player__menu--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tv-player__menu-title {
  padding: 8px 16px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

.tv-player__menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tv-player__menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.tv-player__menu-item--active {
  color: #1e88e5;
  font-weight: 600;
}

.tv-player__menu-item--active::before {
  content: '✓';
  margin-right: 8px;
  font-size: 12px;
}

/* Buffering indicator */
.tv-player--buffering::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #1e88e5;
  border-radius: 50%;
  animation: tv-player-spin 0.8s linear infinite;
  z-index: 5;
}

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

/* Error state */
.tv-player--error::before {
  content: '⚠';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  color: #ff4444;
  z-index: 5;
}

/* Fallback for no-JS */
.tv-player__fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.tv-player__fallback video,
.tv-player__fallback iframe {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: none;
}

/* Screen reader only */
.tv-player__announcer.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Fullscreen adjustments */
.tv-player:fullscreen {
  border-radius: 0;
}

.tv-player:fullscreen .tv-player__video {
  width: 100%;
  height: 100%;
}

/* Simple controls (YouTube/Vimeo) */
.tv-player__controls--simple {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tv-player:hover .tv-player__controls--simple,
.tv-player:focus-within .tv-player__controls--simple {
  opacity: 1;
}

/* Mobile optimizations */
@media (max-width: 767px) {
  .tv-player__big-play {
    width: 64px;
    height: 64px;
  }

  .tv-player__big-play svg {
    width: 32px;
    height: 32px;
  }

  .tv-player__controls-bar {
    padding: 6px 12px 10px;
  }

  .tv-player__progress-wrapper {
    padding: 10px 12px 2px;
  }

  .tv-player__btn svg {
    width: 20px;
    height: 20px;
  }

  .tv-player__time {
    font-size: 11px;
  }

  .tv-player__controls-left,
  .tv-player__controls-right {
    gap: 4px;
  }

  .tv-player__menu {
    bottom: 48px;
    right: 12px;
    min-width: 140px;
  }
}