/* Layout Principal */
body {
  margin: 0;
  padding: 0;
  background-color: #111;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-family: "Courier New", Courier, monospace;
}

.painel-controle {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-right: 40px;
  background-color: #222;
  padding: 20px;
  border: 2px solid #555;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8);
}

.painel-titulo {
  color: #fff;
  text-align: center;
  margin: 0 0 5px 0;
  font-size: 16px;
  text-transform: uppercase;
  border-bottom: 1px solid #555;
  padding-bottom: 10px;
}

/* Botões do Painel */
.btn-teste,
.btn-comercial,
.btn-random,
.btn-assistir,
.btn-desligar {
  color: white;
  border: 2px solid #fff;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  transition: background-color 0.2s;
}

.btn-teste {
  background-color: #002288;
}
.btn-teste:hover {
  background-color: #ff4444;
}

.btn-comercial {
  background-color: #2e8b57;
}
.btn-comercial:hover {
  background-color: #3cb371;
}

.btn-random {
  background-color: #8b0000;
}
.btn-random:hover {
  background-color: #ff0000;
}

.btn-assistir {
  background-color: #d2691e;
}
.btn-assistir:hover {
  background-color: #ff8c00;
}

.btn-desligar {
  background-color: #444;
}
.btn-desligar:hover {
  background-color: #222;
  border-color: #aaa;
}

/* Contêiner da TV */
.tv-container {
  position: relative;
  width: min(800px, calc(100% - 24px), calc((70vh - 104px) * 1.0596));
  height: auto;
  aspect-ratio: 800 / 755;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer; /* O cursor agora mostra que a TV inteira é clicável */
}

#tv-overlay {
  gap: clamp(6px, 1.5vh, 14px);
  padding: clamp(8px, 2vh, 18px);
}

#tv-overlay > .btn-wide {
  flex: 0 0 auto;
  margin-top: 0 !important;
}

#tv-overlay > .caixa-dialogo {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: min(90%, 620px);
  min-height: 42px;
  max-height: none;
  margin: 0;
  box-sizing: border-box;
  border: 2px solid white;
  border-radius: 8px;
  background: rgba(0, 0, 150, 0.69);
  color: white;
  font-size: clamp(10px, 1.2vw, 16px);
  line-height: 1.35;
  padding: 8px 12px 14px;
  z-index: 1;
  user-select: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  overflow: visible;
  word-break: break-word;
}

.tv-moldura {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 2;
  pointer-events: none;
}

.tv-dialog-text {
  display: block;
  width: 100%;
  margin-bottom: 4px;
}

.tv-dialog-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f8f8f8;
  color: #04192d;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}

.tv-dialog-link:hover {
  filter: brightness(1.1);
}

.caixa-dialogo::after {
  content: "▼";
  position: absolute;
  bottom: 3px;
  right: 8px;
  font-size: 11px;
  animation: piscar 1s infinite;
}

@keyframes piscar {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* --- ESTRUTURAS DAS CENAS --- */
.tela-preta {
  position: absolute;
  left: 7.125%;
  top: 7.68%;
  width: 80%;
  height: 72.32%;
  background-color: #000;
  z-index: 0; /* Fica no fundo absoluto */
}

.cena-base {
  position: absolute;
  left: 7.125%;
  top: 7.68%;
  width: 80%;
  height: 72.32%;
  z-index: 1;
  display: none;
}

.img-host,
.img-fullscreen {
  width: 100%;
  height: 100%;
  object-fit: fill;
  background-color: #000;
}

#cena-host {
  display: block;
}

#fundo-azul {
  background-color: #002288;
  box-sizing: border-box;
  padding: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.tv-logo-canal {
  position: absolute;
  top: 4%;
  left: 4%;
  width: 12%;
  max-width: 80px;
  max-height: 13%;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
}

.tv-legenda {
  font-weight: bold;
  font-size: clamp(11px, 3vw, 24px);
  color: #fff;
  margin-top: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 2px 2px #000;
}

#bloco-unico {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 65%;
  height: 100%;
  margin-top: 0;
}
.foto-unica {
  width: 100%;
  height: auto;
  max-height: 52%;
  border: 4px solid #fff;
  object-fit: contain;
  background-color: #000;
}

#bloco-duplo {
  display: none;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  margin-top: 0;
}
.tv-cartaz {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 42%;
}
.foto-dupla {
  width: 100%;
  height: auto;
  max-height: 320px;
  border: 4px solid #fff;
  object-fit: contain;
  background-color: #000;
  image-rendering: pixelated;
}

@media (max-width: 620px) {
  .tv-container {
    width: min(800px, calc(100% - 24px), calc((90vh - 150px) * 1.0596));
  }
  #fundo-azul {
    padding: 7% 3% 3%;
  }
  .tv-logo-canal {
    width: 13%;
    max-width: 48px;
  }
  .tv-legenda {
    margin-top: 6px;
    font-size: clamp(9px, 3vw, 13px);
    letter-spacing: 1px;
  }
  #bloco-unico {
    width: 72%;
  }
  .foto-unica {
    max-height: 52%;
    border-width: 2px;
  }
  #bloco-duplo {
    gap: 3%;
    align-items: center;
  }
  .tv-cartaz {
    width: 47%;
  }
  .foto-dupla {
    max-height: 62%;
    border-width: 2px;
  }
  #tv-overlay > .caixa-dialogo {
    width: min(94%, 620px);
    max-height: 18vh;
    min-height: 38px;
    padding: 5px 8px 11px;
    font-size: clamp(9px, 2.6vw, 11px);
    line-height: 1.25;
  }
  #tv-overlay > .caixa-dialogo::after {
    right: 7px;
    bottom: 3px;
    font-size: 10px;
  }
}

@media (max-height: 600px) {
  #tv-overlay {
    padding: 6px;
    gap: 4px;
  }
  .tv-container {
    width: min(800px, calc(100% - 24px), calc((90vh - 150px) * 1.0596));
  }
  #tv-overlay > .caixa-dialogo {
    width: min(94%, 620px);
    max-height: 20vh;
    padding: 4px 6px 10px;
    font-size: clamp(8px, 1.2vw, 10px);
    line-height: 1.2;
  }
  #tv-overlay > .caixa-dialogo::after {
    right: 6px;
    bottom: 2px;
    font-size: 9px;
  }
}
