/**
 * Container WordPress do NewChat. Alturas em vh/dvh (não 100% em cadeia quebrada).
 * O layout vídeo+chat fica DENTRO do iframe — evitar regras que forcem o iframe a alturas instáveis.
 */
.digitaledu-newchat-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-width: 0;
}

/* Barra do botão: fluxo normal — evita “Tela cheia” solto à esquerda (absolute) */
.digitaledu-newchat-stage__bar {
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;
  padding: 6px 0 4px;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
}

.digitaledu-newchat-stage .digitaledu-newchat-embed {
  position: relative;
  z-index: 0;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 280px;
  /* Padrão: limita por viewport mas reserva “folga” (cabeçalhos/rodapés) — melhora com zoom do browser */
  height: min(85dvh, calc(100dvh - 5rem), 100dvh) !important;
  max-height: min(90dvh, calc(100dvh - 4rem), 1200px) !important;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 20, 60, 0.12);
}

.digitaledu-newchat-stage .digitaledu-newchat-embed iframe {
  width: 100% !important;
  height: 100% !important;
  min-height: 240px !important;
  border: 0 !important;
  display: block !important;
  background: #000;
}

.digitaledu-newchat-theater-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font: 600 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  background: rgba(0, 47, 119, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.digitaledu-newchat-theater-btn:hover {
  background: #003d99;
  transform: translateY(-1px);
}

.digitaledu-newchat-theater-btn:focus-visible {
  outline: 2px solid #1d9500;
  outline-offset: 2px;
}

.digitaledu-newchat-theater-icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  opacity: 0.95;
}

.digitaledu-newchat-stage.is-theater {
  position: fixed;
  inset: 0;
  /* Portal: modais/overlays com z-index 10^7+; o teatro deve ficar por cima */
  z-index: 2000000000;
  max-width: none;
  width: 100%;
  max-height: none;
  margin: 0;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #050810;
}

.digitaledu-newchat-stage.is-theater .digitaledu-newchat-embed {
  flex: 1 1 auto;
  min-height: 0 !important;
  height: 100% !important;
  max-height: none !important;
  border-radius: 0;
  box-shadow: none;
  width: 100% !important;
}

.digitaledu-newchat-stage.is-theater .digitaledu-newchat-stage__bar {
  flex: 0 0 auto;
  padding: max(8px, env(safe-area-inset-top, 0px)) 12px 8px;
  background: rgba(0, 0, 0, 0.35);
}

body.digitaledu-newchat-theater-open {
  overflow: hidden;
}

@media (min-width: 1200px) {
  .digitaledu-newchat-stage .digitaledu-newchat-embed {
    min-height: 320px;
  }
}

@media (min-width: 2560px) {
  .digitaledu-newchat-stage .digitaledu-newchat-embed {
    max-width: 2560px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .digitaledu-newchat-theater-btn {
    transition: none;
  }
}

@media print {
  .digitaledu-newchat-theater-btn {
    display: none !important;
  }
}

/* DigitalEDU Ao Vivo (Portal): cadeia flex — altura = slot do pai, não 85% do viewport (evita corte c/ rodapé/zoom) */
#shortcode-container .digitaledu-newchat-stage {
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#shortcode-container .digitaledu-newchat-stage .digitaledu-newchat-embed {
  min-height: 0;
  flex: 1 1 auto;
  height: 100% !important;
  max-height: 100% !important;
}

#shortcode-container .digitaledu-newchat-stage.is-theater .digitaledu-newchat-embed {
  min-height: 0 !important;
  height: 100% !important;
  max-height: none !important;
}

/* Portal: contentor do shortcode herda a célula de vídeo (flex) */
body.transmissao-mode .transmissao-main-content,
body.transmissao-mode .video-container-main,
body.transmissao-mode #shortcode-container {
  min-height: 0;
}

body.transmissao-mode .video-container-main {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden;
}

body.transmissao-mode #shortcode-container {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  box-sizing: border-box;
  overflow: hidden;
}

body.transmissao-mode #shortcode-container .digitaledu-newchat-stage .digitaledu-newchat-embed {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
}

/* Eventos WD — #transmissao: limita a coluna ao viewport (menos chrome do evento), sem exigir altura de pai */
#transmissao .transmissao-container {
  min-height: 0;
  align-items: stretch;
  max-width: 100%;
}

#transmissao .streaming-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  /* Teto visível: evita que o bloco do NewChat “empurre” o rodapé do evento em zoom alto */
  max-height: min(88dvh, calc(100dvh - 5rem));
  overflow: hidden;
  box-sizing: border-box;
}

#transmissao .streaming-content .digitaledu-newchat-stage:not(.is-theater) {
  flex: 1 1 auto;
  min-height: min(220px, 50dvh);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#transmissao .streaming-content .digitaledu-newchat-stage:not(.is-theater) .digitaledu-newchat-embed {
  flex: 1 1 auto;
  min-height: 0 !important;
  height: min(80dvh, calc(100dvh - 6rem)) !important;
  max-height: min(88dvh, calc(100dvh - 4.5rem)) !important;
}

/* Webinar externo: o cartão nem sempre tem cadeia flex com altura definida — teto em dvh + folga do layout */
.webinar-landing3 .wl-info-wrap .digitaledu-newchat-stage:not(.is-theater),
.webinar-landing .wl-info-wrap .digitaledu-newchat-stage:not(.is-theater) {
  min-height: 0;
  max-height: min(78dvh, calc(100dvh - 10rem));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.webinar-landing3 .wl-info-wrap .digitaledu-newchat-stage:not(.is-theater) .digitaledu-newchat-embed,
.webinar-landing .wl-info-wrap .digitaledu-newchat-stage:not(.is-theater) .digitaledu-newchat-embed {
  min-height: 0 !important;
  flex: 1 1 auto;
  height: min(75dvh, calc(100dvh - 10rem)) !important;
  max-height: min(78dvh, calc(100dvh - 9rem)) !important;
}

/* Portal: contentores com overflow:hidden recortam o stage em position:fixed */
body.digitaledu-newchat-theater-open.transmissao-mode .transmissao-container-section,
body.digitaledu-newchat-theater-open.transmissao-mode .transmissao-main-content,
body.digitaledu-newchat-theater-open.transmissao-mode .video-container-main {
  overflow: visible !important;
}

/* Webinar externo (ao vivo): mesma lógica */
body.digitaledu-newchat-theater-open .webinar-landing3 .wl-info-wrap,
body.digitaledu-newchat-theater-open .webinar-landing3 .wl-container,
body.digitaledu-newchat-theater-open .webinar-landing3 main,
body.digitaledu-newchat-theater-open .webinar-landing3 .wl-shortcode-area {
  overflow: visible !important;
}
