/* Live 24/7: painel de controle da transmissão.
   Uma faixa escura de controle (o estado da live) e o resto claro e quieto. */

:root {
  --ink: #16202b;
  --ink-soft: #2a3745;
  --bg: #eef1f4;
  --surface: #ffffff;
  --rule: #cfd6dd;
  --text: #1c2631;
  --muted: #566474;
  --band-text: #f3f6f9;
  --band-muted: #a9b6c3;
  --tally: #ff3b30;
  --amber: #f2a900;
  --ok: #1d7a59;
  --danger: #b3261e;
  --radius: 4px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.5 "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; font-stretch: 75%; font-weight: 700; letter-spacing: 0.005em; }
p { margin: 0; }

:focus-visible { outline: 3px solid #2f6fed; outline-offset: 2px; }

/* ------------------------------------------------------------------ */
/* Botões e campos                                                     */
/* ------------------------------------------------------------------ */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  font-family: inherit; font-size: 0.95rem; font-weight: 600; line-height: 1;
  color: var(--ink); background: transparent;
  border: 1px solid var(--ink); border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: rgba(22, 32, 43, 0.07); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-soft); }
.btn.light { background: var(--band-text); color: var(--ink); border-color: var(--band-text); }
.btn.light:hover { background: #fff; }
.btn.ghost { color: var(--band-text); border-color: #62707f; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.link {
  appearance: none; background: none; border: 0; padding: 0;
  font: inherit; color: inherit; text-decoration: underline; cursor: pointer;
}

label { display: block; margin-top: 16px; font-weight: 600; font-size: 0.92rem; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-top: 18px; }
.check input { width: 18px; height: 18px; margin: 0; }

input[type="text"], input[type="password"], select {
  width: 100%; min-height: 42px; margin-top: 6px; padding: 9px 12px;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid #94a1ae; border-radius: var(--radius);
}
input[type="text"] + input[type="text"] { margin-top: 8px; }
form .btn { margin-top: 18px; }
.hint { margin-top: 6px; font-size: 0.85rem; color: var(--muted); }

/* ------------------------------------------------------------------ */
/* Faixa de controle ("no ar")                                          */
/* ------------------------------------------------------------------ */
.onair { background: var(--ink); color: var(--band-text); }
.onair-inner { max-width: 1180px; margin: 0 auto; padding: 14px 24px 30px; }

.onair-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--band-muted); font-size: 0.9rem; }
.brand { font-stretch: 75%; font-weight: 700; font-size: 1.05rem; color: var(--band-text); }
.who { display: flex; align-items: center; gap: 14px; }

.onair-state { display: flex; align-items: center; gap: 18px; margin-top: 26px; }
.onair-state h1 {
  font-size: clamp(2.6rem, 8vw, 5rem); line-height: 1; font-stretch: 62%; font-weight: 800;
}

.tally {
  flex: none; display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  background: #6b7886;
}
.onair[data-state="live"] .tally { background: var(--tally); animation: pulse 2.6s ease-out infinite; }
.onair[data-state="starting"] .tally,
.onair[data-state="reconnecting"] .tally,
.onair[data-state="no_key"] .tally { background: var(--amber); }
.onair[data-state="starting"] .tally,
.onair[data-state="reconnecting"] .tally { animation: blink 1.2s steps(2, jump-none) infinite; }
.onair[data-state="offline"] .tally { background: transparent; box-shadow: inset 0 0 0 3px var(--tally); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.65); }
  70%  { box-shadow: 0 0 0 16px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}
@keyframes blink { 50% { opacity: 0.25; } }

.onair-title { margin-top: 14px; max-width: 60ch; font-size: 1.3rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.onair-detail { margin-top: 6px; max-width: 70ch; color: var(--band-muted); font-size: 0.97rem; }
.onair-detail.warn { color: #ffcf8a; }
.onair-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.onair-actions:empty { display: none; }

/* ------------------------------------------------------------------ */
/* Layout                                                               */
/* ------------------------------------------------------------------ */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 56px;
  max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px;
}
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.section-head h2, .side h2 { font-size: 1.7rem; line-height: 1.15; }
.section-note, .side-note { color: var(--muted); font-size: 0.92rem; }
.side-note { margin-top: 12px; }

.side section { padding: 26px 0; border-top: 1px solid var(--rule); }
.side section:first-child { padding-top: 0; border-top: 0; }
.side h2 { font-size: 1.35rem; margin-bottom: 12px; }

/* ------------------------------------------------------------------ */
/* Fila de exibição                                                     */
/* ------------------------------------------------------------------ */
.queue { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--ink); }

.row {
  display: grid; grid-template-columns: 22px 28px minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px;
  padding: 12px 8px 12px 10px; border-bottom: 1px solid var(--rule);
  border-left: 4px solid transparent; background: transparent;
}
.row:hover { background: rgba(255, 255, 255, 0.55); }
.row.is-onair { border-left-color: var(--tally); background: var(--surface); }
.row.dragging { opacity: 0.35; }
.row.drop-before { box-shadow: inset 0 3px 0 var(--ink); }
.row.drop-after { box-shadow: inset 0 -3px 0 var(--ink); }

.handle { color: #8a97a4; cursor: grab; display: grid; place-items: center; height: 32px; touch-action: none; }
.handle:active { cursor: grabbing; }
.pos { color: var(--muted); font-weight: 600; text-align: right; }

.t { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.onair-badge { margin-left: 8px; font-size: 0.82rem; font-weight: 700; color: var(--danger); }
.m { margin-top: 2px; font-size: 0.87rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.dur { font-weight: 600; min-width: 54px; text-align: right; }

.st::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--muted); }
.st.ready::before { background: var(--ok); }
.st.busy::before { background: var(--amber); }
.st.err { color: var(--danger); }
.st.err::before { background: var(--danger); }

.bar { width: 120px; height: 5px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.4s linear; }

.acts { display: flex; gap: 2px; }
.icon-btn {
  appearance: none; display: grid; place-items: center; width: 36px; height: 36px;
  color: var(--ink-soft); background: transparent; border: 0; border-radius: var(--radius); cursor: pointer;
}
.icon-btn:hover { background: rgba(22, 32, 43, 0.09); }
.icon-btn.danger:hover { background: #fbe4e2; color: var(--danger); }
.icon-btn[disabled] { opacity: 0.3; cursor: default; background: transparent; }
.icon-btn svg, .handle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.empty { margin-top: 18px; max-width: 52ch; color: var(--muted); }

/* ------------------------------------------------------------------ */
/* Envio                                                                */
/* ------------------------------------------------------------------ */
.drop {
  padding: 22px 18px; border: 2px dashed #94a1ae; border-radius: var(--radius); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--ink); background: var(--surface); }
.drop-main { font-weight: 600; }
.link-look { text-decoration: underline; }
.drop-sub { margin-top: 6px; font-size: 0.86rem; color: var(--muted); }

.uploads { list-style: none; margin: 10px 0 0; padding: 0; }
.uploads li { padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 0.92rem; }
.uploads .u-name { font-weight: 600; overflow-wrap: anywhere; }
.uploads .u-info { margin-top: 2px; color: var(--muted); font-size: 0.85rem; }
.uploads .u-info.err { color: var(--danger); }
.uploads .bar { width: 100%; margin-top: 6px; }

/* ------------------------------------------------------------------ */
/* Registro, avisos, diálogo                                            */
/* ------------------------------------------------------------------ */
summary { cursor: pointer; font-stretch: 75%; font-weight: 700; font-size: 1.35rem; }
.log {
  margin: 12px 0 0; padding: 12px; max-height: 340px; overflow: auto;
  background: var(--ink); color: #d8e0e8; border-radius: var(--radius);
  font: 0.78rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}

.toasts { position: fixed; left: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 15px; color: #fff; background: var(--ink); border-radius: var(--radius); border-left: 4px solid var(--ok); font-size: 0.95rem; }
.toast.error { border-left-color: var(--tally); background: #3a1614; }

dialog { width: min(92vw, 440px); padding: 24px; border: 0; border-radius: 6px; color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(22, 32, 43, 0.55); }
dialog h3 { font-size: 1.5rem; }
dialog p { margin-top: 8px; color: var(--muted); }
dialog input[type="text"] { margin-top: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dlg-actions .btn { margin-top: 0; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-fill:hover { background: #8f1d17; }

/* ------------------------------------------------------------------ */
/* Login                                                                */
/* ------------------------------------------------------------------ */
.login-page { background: var(--ink); color: var(--band-text); }
.login { max-width: 380px; margin: 0 auto; padding: 14vh 24px 48px; }
.login-mark { margin-bottom: 18px; }
.login-mark .tally { background: var(--tally); width: 20px; height: 20px; }
.login h1 { font-size: 3rem; line-height: 1; font-stretch: 62%; font-weight: 800; }
.login-sub { margin-top: 10px; color: var(--band-muted); }
.login form { margin-top: 18px; }
.login .btn.primary { width: 100%; margin-top: 22px; background: var(--band-text); color: var(--ink); border-color: var(--band-text); }
.login .btn.primary:hover { background: #fff; }
.form-error { margin-top: 18px; padding: 10px 12px; color: #ffb4ae; background: #3a1614; border-left: 4px solid var(--tally); border-radius: var(--radius); }

/* ------------------------------------------------------------------ */
/* Telas menores                                                        */
/* ------------------------------------------------------------------ */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 40px; padding-top: 26px; }
}
@media (max-width: 560px) {
  .onair-inner, .layout { padding-left: 16px; padding-right: 16px; }
  .row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .row .pos { display: none; }
  .row .dur { grid-column: 2; grid-row: 2; text-align: left; }
  .row .acts { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .onair[data-state] .tally { animation: none; }
  .bar > i { transition: none; }
}
