/* Sala de webinário: mobile-first. Tema via custom properties. */

:root {
  --brand: #1a7f5a;
  --brand-deep: #0e5b3f;
  --brand-soft: #e6f3ed;
  --accent: #e2b93b;
  --room: #f7f7f5;

  --live-red: #e5383b;
  --ink: #1c2420;
  --ink-soft: #5c6660;
  --surface: #ffffff;
  --line: #e4e6e2;
  --topbar-h: 52px;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 30, 25, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--room);
  color: var(--ink);
  overflow-x: hidden;
}

/* ============ Topbar ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--brand-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-live {
  background: var(--live-red);
  color: #fff;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

.badge-replay {
  background: var(--ink);
  color: #fff;
  display: none;
}

.viewers {
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ============ Layout da sala (mobile-first) ============ */
.room {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h));
}

.player-area { order: 1; }
.offer { order: 2; }
.chat { order: 3; }

/* ============ Player ============ */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f1613;
  overflow: hidden;
}

.video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Overlay de som (estado muted) */
.sound-overlay {
  position: absolute;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(12, 18, 15, 0.82);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  z-index: 6;
}

.sound-icon { font-size: 20px; }

body.state-muted .sound-overlay { display: inline-flex; }

/* Aviso anti-aceleração (banner discreto) */
.speed-warning {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  z-index: 5;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(12, 18, 15, 0.78);
  color: #f2f4f1;
  font-size: 12.5px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.speed-warning.is-visible,
body.state-demo .speed-warning {
  /* .is-visible: controlado pelo player.js (strikes). state-demo: só no preview. */
  opacity: 1;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Chip pós-rewind */
.live-chip {
  position: absolute;
  right: 12px;
  bottom: 46px;
  z-index: 5;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(12, 18, 15, 0.8);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.live-chip .chip-dot { color: var(--live-red); }
.live-chip.is-visible { display: inline-flex; }

/* Controles */
.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 20px 0 0;
  background: linear-gradient(to top, rgba(8, 12, 10, 0.75), transparent);
}

.progress-bar {
  position: relative;
  height: 5px;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
}

/* REQ-11: sem navegação (allow_rewind=false, default) não existe barra —
   player.js põe .no-scrubber no wrapper. Preview (state-demo) não passa
   pelo player.js, então os screenshots do protótipo mantêm a barra. */
.video-wrap.no-scrubber .progress-bar { display: none; }

.progress-fill {
  position: relative;
  height: 100%;
  background: var(--live-red);
}

.playhead {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--live-red);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.volume-icon { font-size: 15px; }

.volume-control input[type="range"] {
  width: 90px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ============ Oferta ============ */
.offer {
  padding: 12px;
}

.offer-banner {
  background: linear-gradient(100deg, var(--brand-deep), var(--brand));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.offer-landing {
  margin-top: 12px;
  min-height: 120px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ============ Chat ============ */
.chat {
  display: flex;
  flex-direction: column;
  height: 45vh;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.chat-header {
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 92%;
  background: var(--room);
  border-radius: 12px;
  padding: 8px 11px;
  font-size: 13.5px;
  line-height: 1.4;
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}

.msg-name {
  font-weight: 700;
  font-size: 12.5px;
}

.msg-time {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-left: auto;
  padding-left: 8px;
}

.badge-role {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}

.msg-host {
  background: var(--brand-soft);
  border: 1px solid rgba(26, 127, 90, 0.25);
}

.msg-host .badge-role {
  background: var(--brand);
  color: #fff;
}

.msg-staff .badge-role {
  background: var(--ink);
  color: #fff;
}

.msg-cta {
  background: var(--brand-soft);
  border: 1px solid rgba(26, 127, 90, 0.25);
}

.cta-button {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #3b2f07;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  background: var(--room);
  color: var(--ink);
}

.chat-input:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}

.chat-send {
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.chat-input:disabled,
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ Toasts ============ */
.toasts {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(20, 28, 24, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: slideIn 0.35s ease;
}

@keyframes slideIn {
  from { transform: translateX(-110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ Pré-porta (tela cheia) ============ */
.predoor {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, var(--brand-deep), #081d14 75%);
  color: #fff;
  text-align: center;
  padding: 24px;
}

body.state-predoor .predoor {
  display: flex;
}

/* REQ-39: trailer opcional em loop atrás do countdown (boot.js liga
   .has-trailer quando schedule.pre_door.type = "trailer"). */
.predoor-trailer {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

/* Overlay escuro leve: countdown SEMPRE legível sobre o vídeo */
.predoor::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(4, 14, 9, 0.55);
  display: none;
}

.predoor.has-trailer .predoor-trailer { display: block; }
.predoor.has-trailer::before { display: block; }

.predoor-inner {
  max-width: 480px;
  position: relative;
  z-index: 2;
}

/* "🔊 ativar som" do trailer: mesmo padrão visual do .sound-overlay */
.predoor-sound {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 3;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(12, 18, 15, 0.82);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.predoor.has-trailer .predoor-sound { display: inline-flex; }

.predoor-brand {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-soft);
  opacity: 0.85;
  margin-bottom: 18px;
}

.predoor-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 10px;
}

.predoor-countdown {
  font-size: 72px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.1;
  color: #fff;
}

.predoor-sub {
  margin: 14px 0 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
}

/* ============ Badges por estado ============ */
body.state-replay .badge-live { display: none; }
body.state-replay .badge-replay { display: inline-flex; }

/* ============ Desktop (>= 1024px) ============ */
@media (min-width: 1024px) {
  .room {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "player chat"
      "offer  chat";
    align-items: start;
    gap: 0;
  }

  .player-area { grid-area: player; }
  .offer { grid-area: offer; padding: 16px; }

  .chat {
    grid-area: chat;
    height: calc(100vh - var(--topbar-h));
    position: sticky;
    top: var(--topbar-h);
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .topbar { padding: 0 20px; }
  .brand { font-size: 16px; }
  .predoor-countdown { font-size: 96px; }
}
