/* ═══════════════════════════════════════════════════════════
   HBPlayer Component — Plyr.js + HLS.js Netflix Dark Skin
   v3/organisms/hbplayer/hbplayer.css
   
   Classe raiz: .hbplayer-host (adicionada ao container do player)
   Plyr CSS CDN deve ser carregado ANTES deste arquivo.
═══════════════════════════════════════════════════════════ */

/* ── Plyr dark skin variables (Netflix style) ── */
:root {
  --plyr-color-main:               #e50914;
  --plyr-video-background:         #000;
  --plyr-font-family:              'Poppins', inherit;
  --plyr-font-size-base:           14px;
  --plyr-control-spacing:          10px;
  --plyr-range-fill-background:    #e50914;
  --plyr-range-thumb-background:   #fff;
  --plyr-range-thumb-shadow:       0 1px 3px rgba(0,0,0,.6);
  --plyr-video-controls-background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.85));
  --plyr-menu-background:          rgba(20,20,20,.97);
  --plyr-menu-color:               #ddd;
  --plyr-menu-border-color:        rgba(255,255,255,.1);
  --plyr-badge-background:         #e50914;
  --plyr-captions-background:      rgba(0,0,0,.8);
  --plyr-tooltip-background:       rgba(20,20,20,.97);
  --plyr-tooltip-color:            #fff;
}

/* ── Container: SEM aspect-ratio — Plyr cria a altura via padding-bottom internamente ── */
.hbplayer-host {
  position: relative;
  width: 100%;
  overflow: visible !important;     /* permite anéis/glow do botão play */
  padding-bottom: 0 !important;     /* zerar padding do main.css — Plyr controla */
}

/* Plyr ocupa toda a largura, altura sai do seu próprio wrapper */
.hbplayer-host .plyr {
  position: relative;
  width: 100%;
  background: #000;
}
.hbplayer-host .plyr__video-wrapper {
  position: relative;
  height: 0 !important;
  padding-bottom: 56.25% !important;   /* 16:9 forçado */
  background: #000;
  overflow: hidden;
}
/* Video DEVE ser absolute dentro do wrapper — senão poster cria altura extra */
.hbplayer-host .plyr__video-wrapper video {
  position: absolute !important;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}
/* Permite que decorações do botão saiam do bounds */
.hbplayer-host .plyr--video {
  overflow: visible !important;
}
.plyr--video { border-radius: 0; }
.plyr--fullscreen-fallback { z-index: 99999; }
/* Volume slider maior em mobile */
.plyr__volume input[type=range] { width: 80px; }
@media (max-width: 480px) {
  .plyr__volume input[type=range] { width: 60px; }
}
/* Badge de qualidade no botão */
.plyr__menu__container .plyr__control--back::after { display: none; }

/* ── Fix: Plyr settings submenu (speed/quality) em mobile ──
   Plyr 3.7.8 calcula height inline via JS no .plyr__menu__container ao
   navegar para o submenu (Speed, Quality). Em mobile não-fullscreen essa
   height é frequentemente menor que o necessário, cortando as opções.
   Solução: forçar height:auto e overflow visível no container + innerDiv. */
.hbplayer-host .plyr__menu__container {
  height: auto !important;          /* override do inline style do Plyr */
  overflow: visible !important;
}
.hbplayer-host .plyr__menu__container > div {
  overflow: visible !important;
}
.hbplayer-host .plyr__menu__container [role="menu"] {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 280px;
}
/* Em mobile, garante que os controles e o menu não sejam cortados */
@media (max-width: 768px) {
  .hbplayer-host .plyr__controls {
    overflow: visible !important;
  }
  .hbplayer-host .plyr__menu {
    position: static;
  }
  .hbplayer-host .plyr__menu__container {
    bottom: 100%;
    min-width: 180px;
  }
}


/* ═══════════════════════════════════════════════
   Botão Play Cinematic (Netflix style)
═══════════════════════════════════════════════ */

/* Botão play central */
.plyr--video .plyr__control--overlaid {
  width: 72px !important;
  height: 72px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  border: none !important;
  /* vidro escuro com tint vermelho */
  background: rgba(180, 10, 10, 0.55) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  /* borda translúcida */
  outline: 2px solid rgba(255, 60, 40, 0.45) !important;
  outline-offset: 0px !important;
  /* sombra de brasa — camadas */
  box-shadow:
    0 0 0   0   rgba(229, 9, 20, 0),
    0 0 22px 4px rgba(229, 9, 20, 0.50),
    0 0 50px 8px rgba(180, 20, 0,  0.25),
    inset 0 1px 0 rgba(255,255,255,.12) !important;
  animation: hbPulseGlow 2.4s ease-in-out infinite !important;
  transition: transform .18s ease, backdrop-filter .18s ease !important;
  overflow: visible !important;
}

/* Ícone SVG play — centralizado via flexbox do pai */
.plyr--video .plyr__control--overlaid svg {
  width: 26px !important;
  height: 26px !important;
  fill: #fff !important;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.6)) !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Anel externo pulsante */
.plyr--video .plyr__control--overlaid::after {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 50% !important;
  border: 1.5px solid rgba(229, 9, 20, 0.6) !important;
  transform: translate(-50%, -50%) scale(1) !important;
  animation: hbRingExpand 2.4s ease-out infinite !important;
  pointer-events: none !important;
}

/* Segundo anel, defasado */
.plyr--video .plyr__control--overlaid::before {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 50% !important;
  border: 1.5px solid rgba(229, 9, 20, 0.35) !important;
  transform: translate(-50%, -50%) scale(1) !important;
  animation: hbRingExpand 2.4s ease-out infinite !important;
  animation-delay: 1.2s !important;
  pointer-events: none !important;
}

/* Hover: cresce, intensifica e PARA as animações */
.plyr--video .plyr__control--overlaid:hover {
  transform: translate(-50%, -50%) scale(1.1) !important;
  background: rgba(229, 9, 20, 0.80) !important;
  box-shadow:
    0 0 0   0   rgba(229, 9, 20, 0),
    0 0 34px 8px rgba(229, 9, 20, 0.70),
    0 0 70px 14px rgba(180, 20, 0, 0.35),
    inset 0 1px 0 rgba(255,255,255,.18) !important;
  animation-play-state: paused !important;
}
.plyr--video .plyr__control--overlaid:hover::before,
.plyr--video .plyr__control--overlaid:hover::after {
  animation-play-state: paused !important;
  opacity: 0 !important;
  transition: opacity .2s ease !important;
}

/* Pulso de brilho — o botão "respira" */
@keyframes hbPulseGlow {
  0%, 100% {
    box-shadow:
      0 0 0   0   rgba(229, 9, 20, 0),
      0 0 22px 4px rgba(229, 9, 20, 0.50),
      0 0 50px 8px rgba(180, 20, 0,  0.25),
      inset 0 1px 0 rgba(255,255,255,.12);
    outline-color: rgba(255, 60, 40, 0.45);
  }
  50% {
    box-shadow:
      0 0 0   10px rgba(229, 9, 20, 0),
      0 0 34px 8px rgba(229, 9, 20, 0.70),
      0 0 70px 14px rgba(180, 20, 0, 0.40),
      inset 0 1px 0 rgba(255,255,255,.18);
    outline-color: rgba(255, 80, 60, 0.70);
  }
}

/* Anel expandindo e sumindo */
@keyframes hbRingExpand {
  0%   { transform: translate(-50%, -50%) scale(1);    opacity: .7; }
  80%  { transform: translate(-50%, -50%) scale(2.0);  opacity: 0;  }
  100% { transform: translate(-50%, -50%) scale(2.0);  opacity: 0;  }
}

/* Mobile */
@media (max-width: 480px) {
  .plyr--video .plyr__control--overlaid {
    width: 58px !important;
    height: 58px !important;
  }
  .plyr--video .plyr__control--overlaid svg {
    width: 22px !important;
    height: 22px !important;
  }
}


/* ═══════════════════════════════════════════════
   Spinner de carregamento (Veil)
═══════════════════════════════════════════════ */
.hb-veil {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  pointer-events: none;
  transition: opacity .4s;
}
.hb-veil.hid {
  opacity: 0;
  pointer-events: none;
}
.hb-veil svg {
  animation: hbSpin 1s linear infinite;
}
@keyframes hbSpin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════
   Seek Preview (canvas thumbnail, zero servidor)
═══════════════════════════════════════════════ */
.plyr__progress { position: relative !important; }

.hb-seek-preview {
  position: absolute;
  bottom: calc(100% + 12px);
  width: 160px;
  transform: translateX(-50%);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 6px 28px rgba(0,0,0,.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
  z-index: 200;
  background: #000;
}
.hb-seek-preview.visible {
  opacity: 1;
}
.hb-seek-preview canvas {
  display: block;
  width: 160px;
  height: 90px;
}
.hb-seek-preview .hb-sptime {
  text-align: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 0 4px;
  background: rgba(0,0,0,.75);
  letter-spacing: .4px;
}


/* ═══════════════════════════════════════════════
   Watermark Anti-Pirataria
═══════════════════════════════════════════════ */
.hb-watermark {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  transition: opacity .6s ease;
  font-family: 'Courier New', monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .6px;
  color: rgba(255,255,255,0.25);
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7), -1px -1px 3px rgba(0,0,0,0.7);
  white-space: nowrap;
  line-height: 1.4;
}
.hb-watermark.visible {
  opacity: 1;
}


/* ═══════════════════════════════════════════════
   Mid-Roll Ad Overlay
═══════════════════════════════════════════════ */
.hb-ad-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: #000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hb-ad-overlay.active {
  display: flex;
}
.hb-ad-overlay video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
}
/* Badge "Publicidade" */
.hb-ad-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0,0,0,0.75);
  color: #ffd600;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  z-index: 62;
  pointer-events: none;
  font-family: 'Poppins', sans-serif;
}
/* Countdown "Pular em Xs" + botão "Pular anúncio" */
.hb-ad-skip-wrap {
  position: absolute;
  bottom: 20px;
  right: 16px;
  z-index: 62;
}
.hb-ad-skip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  padding: 8px 18px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  cursor: default;
  opacity: 0.5;
  transition: background .2s, opacity .2s, border-color .2s;
  outline: none;
}
.hb-ad-skip-btn.ready {
  cursor: pointer;
  opacity: 1;
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.5);
}
.hb-ad-skip-btn.ready:hover {
  background: rgba(255,255,255,0.35);
}
.hb-ad-skip-btn svg { flex-shrink: 0; }
/* Tempo restante do ad */
.hb-ad-timer {
  position: absolute;
  bottom: 20px;
  left: 16px;
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  font-family: 'Poppins', sans-serif;
  z-index: 62;
  pointer-events: none;
}
/* Link de destino overlay (invisível sobre o vídeo) */
.hb-ad-link {
  position: absolute;
  inset: 0;
  z-index: 61;
  cursor: pointer;
}
@media (max-width: 480px) {
  .hb-ad-badge { top: 6px; left: 6px; font-size: 10px; padding: 3px 7px; }
  .hb-ad-skip-wrap { bottom: 12px; right: 8px; }
  .hb-ad-skip-btn { font-size: 12px; padding: 6px 12px; }
  .hb-ad-timer { bottom: 12px; left: 8px; font-size: 10px; }
}


/* ═══════════════════════════════════════════════
   Credit Balance Badge
═══════════════════════════════════════════════ */
.hb-credit-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  padding: 6px 14px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.hb-credit-badge.visible {
  opacity: 1;
}
.hb-credit-badge.low {
  color: #ffd600;
  border: 1px solid rgba(255,214,0,0.3);
}
.hb-credit-badge.critical {
  color: #ff1744;
  border: 1px solid rgba(255,23,68,0.4);
  animation: hbCreditPulse 1s ease infinite;
}
.hb-credit-badge .hb-credit-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
@keyframes hbCreditPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@media (max-width: 480px) {
  .hb-credit-badge {
    top: 6px;
    right: 6px;
    font-size: 11px;
    padding: 4px 10px;
  }
}

/* ═══════════════════════════════════════════════
   Credits Exhausted Overlay
═══════════════════════════════════════════════ */
.hb-credits-exhausted {
  position: absolute;
  inset: 0;
  z-index: 65;
  background: rgba(0,0,0,0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  font-family: 'Poppins', sans-serif;
}
.hb-credits-exhausted.active {
  display: flex;
}
.hb-credits-exhausted .hb-ce-icon {
  width: 56px;
  height: 56px;
  opacity: 0.7;
}
.hb-credits-exhausted .hb-ce-title {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}
.hb-credits-exhausted .hb-ce-subtitle {
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  margin: 0;
  max-width: 300px;
}
.hb-credits-exhausted .hb-ce-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e50914;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 28px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}
.hb-credits-exhausted .hb-ce-btn:hover {
  background: #b20710;
}
@media (max-width: 480px) {
  .hb-credits-exhausted .hb-ce-title { font-size: 16px; }
  .hb-credits-exhausted .hb-ce-subtitle { font-size: 12px; }
  .hb-credits-exhausted .hb-ce-btn { font-size: 13px; padding: 10px 22px; }
}
