/* H Announcer TV - painel do cliente (tv.html). Mesma identidade do app da TV:
   azul-noite com gradiente laranja/rosa. */
:root {
  --bg: #0a0e18;
  --surface: #121827;
  --surface-2: #1a2235;
  --border: #26314a;
  --text: #f2f5fa;
  --muted: #8c98b0;
  --primary: #ff7a1a;
  --accent: #ff3d6e;
  --success: #2bd98a;
  --warning: #ffb020;
  --danger: #ff5470;
  --grad: linear-gradient(135deg, var(--primary), var(--accent));
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 600px at -10% -20%, rgba(255, 122, 26, .14), transparent 60%),
    radial-gradient(800px 600px at 110% 120%, rgba(255, 61, 110, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.tv-muted { color: var(--muted); }
button, input, select { font: inherit; color: inherit; }

/* ---------- marca ---------- */
.tv-marca { display: flex; align-items: center; gap: 12px; }
.tv-logo {
  width: 42px; height: 42px; border-radius: 12px; background: var(--grad);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 22px rgba(255, 122, 26, .35);
}
.tv-logo svg { width: 24px; height: 24px; }
.tv-marca strong { display: block; font-size: 18px; font-weight: 800; letter-spacing: -.3px; line-height: 1.1; }
.tv-marca small { color: var(--primary); font-weight: 700; letter-spacing: 4px; font-size: 11px; }

/* ---------- botoes, campos ---------- */
.tv-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 10px 16px; font-weight: 600; cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s;
}
.tv-btn:hover { border-color: #3a4766; }
.tv-btn:active { transform: scale(.98); }
.tv-btn:disabled { opacity: .5; cursor: default; }
.tv-btn.primario { background: var(--grad); border: 0; color: #fff; }
.tv-btn.fantasma { background: transparent; }
.tv-btn.perigo { color: var(--danger); border-color: rgba(255, 84, 112, .4); background: rgba(255, 84, 112, .08); }
.tv-btn.pequeno { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.tv-btn:focus-visible, .tv-chip:focus-visible, .tv-aba:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; width: 100%; outline: none;
}
input:focus, select:focus { border-color: var(--primary); }

.tv-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.tv-check input { accent-color: var(--primary); width: 16px; height: 16px; }

/* interruptor */
.tv-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.tv-switch input { opacity: 0; width: 0; height: 0; }
.tv-switch span {
  position: absolute; inset: 0; border-radius: 99px; background: var(--surface-2);
  border: 1px solid var(--border); transition: .2s; cursor: pointer;
}
.tv-switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: .2s;
}
.tv-switch input:checked + span { background: var(--primary); border-color: var(--primary); }
.tv-switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.tv-switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.tv-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tv-chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tv-chip.ativo { color: #fff; background: rgba(255, 122, 26, .18); border-color: var(--primary); }

/* ---------- login ---------- */
.tv-login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.tv-login-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 32px 28px; display: grid; gap: 14px;
}
.tv-login-card h1 { margin: 12px 0 0; font-size: 24px; }
.tv-login-card p { margin: 0; }
.tv-login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.tv-erro { color: var(--danger); margin: 0; font-size: 14px; }

/* ---------- estrutura ---------- */
.tv-app { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }
.tv-topo { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.tv-topo-dir { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tv-empresa { text-align: right; min-width: 0; }
.tv-empresa strong, .tv-empresa small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-empresa small { color: var(--muted); font-size: 12px; }

.tv-aviso {
  border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; font-weight: 500;
  background: rgba(255, 84, 112, .1); border: 1px solid rgba(255, 84, 112, .4); color: #ffd3dc;
}

.tv-resumo { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.tv-kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: grid; gap: 4px; min-width: 0;
}
.tv-kpi-rotulo { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.tv-kpi strong { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.tv-kpi small { color: var(--muted); font-size: 13px; }
.tv-barra { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 4px 0 2px; }
.tv-barra i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .4s; }
.tv-barra.cheia i { background: var(--warning); }

.tv-abas { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tv-aba {
  background: none; border: 0; padding: 12px 16px; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tv-aba.ativa { color: var(--text); border-bottom-color: var(--primary); }
.tv-badge {
  display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 99px;
  background: rgba(43, 217, 138, .18); color: var(--success); font-size: 12px; margin-left: 4px;
}
.tv-painel { display: none; }
.tv-painel.ativo { display: block; }
.tv-secao-topo { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tv-secao-topo p { margin: 0; max-width: 640px; }
.tv-dica { color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ---------- upload ---------- */
.tv-upload {
  display: grid; justify-items: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 28px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: rgba(18, 24, 39, .6); transition: border-color .15s, background .15s;
}
.tv-upload:hover, .tv-upload.arrastando { border-color: var(--primary); background: rgba(255, 122, 26, .06); }
.tv-upload-icone {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255, 122, 26, .15); color: var(--primary);
}
.tv-upload-icone svg { width: 26px; height: 26px; }
.tv-upload small { color: var(--muted); }
.tv-upload-opcoes { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 12px 0 4px; }

.tv-fila { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.tv-fila li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; display: grid; gap: 6px;
}
.tv-fila .linha { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.tv-fila .linha span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-fila li.erro { border-color: rgba(255, 84, 112, .5); }
.tv-fila li.erro .linha span:last-child { color: var(--danger); }
.tv-fila li.ok .linha span:last-child { color: var(--success); }

.tv-filtros { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 24px 0 14px; }
.tv-busca { max-width: 260px; }

/* ---------- grade de midias ---------- */
.tv-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tv-midia {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: border-color .2s;
}
.tv-midia.ativa { border-color: rgba(255, 122, 26, .6); }
.tv-midia-thumb { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; }
.tv-midia-thumb img, .tv-midia-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tv-midia-thumb .tv-thumb-icone { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.tv-midia-thumb .tv-thumb-icone svg { width: 40px; height: 40px; }
.tv-midia-selos { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }
.tv-selo {
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 99px; padding: 3px 9px; backdrop-filter: blur(4px);
}
.tv-selo.slide { background: var(--primary); }
.tv-midia-corpo { padding: 12px 14px 14px; display: grid; gap: 10px; }
.tv-midia-nome { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-midia-meta { color: var(--muted); font-size: 12px; margin-top: -8px; }
.tv-linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.tv-tempo { display: flex; align-items: center; gap: 6px; }
.tv-tempo input { width: 70px; padding: 6px 8px; text-align: center; }
.tv-midia .tv-chips { gap: 6px; }
.tv-midia .tv-chip { padding: 4px 10px; font-size: 12px; }
.tv-vazio {
  grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 16px;
  border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ---------- canais ---------- */
.tv-canais { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tv-canal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.tv-canal-topo { display: flex; align-items: center; gap: 12px; }
.tv-canal-num {
  flex: none; width: 52px; height: 52px; border-radius: 14px; background: var(--grad);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; line-height: 1;
  text-align: center;
}
.tv-canal-num small { display: block; font-size: 9px; letter-spacing: 1px; opacity: .85; }
.tv-canal-topo input { font-weight: 700; font-size: 16px; }
.tv-canal-info { color: var(--muted); font-size: 13px; }
.tv-campo { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.tv-campo-linha { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.tv-campo-linha small { display: block; color: var(--muted); font-size: 12px; }
.tv-transicoes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tv-transicoes button {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px;
  padding: 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tv-transicoes button.ativo { border-color: var(--primary); color: #fff; background: rgba(255, 122, 26, .18); }
.tv-duracao { display: flex; align-items: center; gap: 10px; }
.tv-duracao input[type=range] { flex: 1; accent-color: var(--primary); }
.tv-duracao output { min-width: 44px; text-align: right; font-weight: 700; color: var(--text); }
.tv-canal-acoes { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- dispositivos ---------- */
.tv-aparelhos { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.tv-aparelho { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 12px; }
.tv-aparelho.inativo { opacity: .65; }
.tv-aparelho-topo { display: flex; align-items: center; gap: 12px; }
.tv-aparelho-icone {
  flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; color: var(--muted); position: relative;
}
.tv-aparelho-icone svg { width: 22px; height: 22px; }
.tv-ponto { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: #5a6782; }
.tv-ponto.online { background: var(--success); box-shadow: 0 0 0 4px rgba(43, 217, 138, .2); }
.tv-aparelho-nome { flex: 1; min-width: 0; }
.tv-aparelho-nome strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-aparelho-nome small { color: var(--muted); font-size: 12px; }
.tv-status { font-size: 12px; font-weight: 700; border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.tv-status.online { color: var(--success); background: rgba(43, 217, 138, .14); }
.tv-status.offline { color: var(--muted); background: var(--surface-2); }
.tv-status.desligado { color: var(--danger); background: rgba(255, 84, 112, .12); }
.tv-aparelho-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; color: var(--muted); }
.tv-aparelho-meta b { color: var(--text); font-weight: 600; }
.tv-aparelho-acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- download do APK ---------- */
.tv-apk {
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: start;
  background: linear-gradient(135deg, rgba(255, 122, 26, .12), rgba(255, 61, 110, .08));
  border: 1px solid rgba(255, 122, 26, .45); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px;
}
.tv-apk.destaque { box-shadow: 0 0 0 3px rgba(255, 122, 26, .5); }
.tv-apk-icone { width: 48px; height: 48px; border-radius: 14px; background: var(--grad); color: #fff; display: grid; place-items: center; }
.tv-apk-icone svg { width: 26px; height: 26px; }
.tv-apk h3 { margin: 0 0 8px; font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tv-apk-versao { font-size: 12px; font-weight: 700; color: var(--success); background: rgba(43, 217, 138, .14); border-radius: 99px; padding: 2px 9px; }
.tv-apk ol { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; }
.tv-apk p { margin: 0; font-size: 13px; }
.tv-apk-link { color: var(--primary); font-size: 15px; letter-spacing: .2px; }
.tv-apk-acoes { display: grid; gap: 8px; }
.tv-apk-acoes .tv-btn { text-align: center; text-decoration: none; }
@media (max-width: 720px) {
  .tv-apk { grid-template-columns: 1fr; }
  .tv-apk-icone { display: none; }
  .tv-apk-acoes { grid-template-columns: 1fr 1fr; }
}

/* ---------- toast ---------- */
.tv-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 14px; z-index: 50; transition: .25s; max-width: calc(100% - 32px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.tv-toast.visivel { opacity: 1; transform: translate(-50%, 0); }
.tv-toast.erro { border-color: rgba(255, 84, 112, .6); }

@media (max-width: 860px) {
  .tv-resumo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .tv-topo { flex-wrap: wrap; }
  .tv-empresa { text-align: left; }
  .tv-kpi strong { font-size: 22px; }
  .tv-aparelhos, .tv-canais { grid-template-columns: 1fr; }
  .tv-grade { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .tv-transicoes { grid-template-columns: repeat(3, 1fr); }
  .tv-busca { max-width: none; }
}

/* ---------- conta sem o produto H Announcer TV ---------- */
.tv-sem-produto {
  max-width: 560px; margin: 48px auto; text-align: center; display: grid; justify-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 36px 28px;
}
.tv-sem-produto h2 { margin: 6px 0 0; font-size: 22px; }
.tv-sem-produto p { margin: 0; line-height: 1.5; }
.tv-sem-produto-acoes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.tv-sem-produto-acoes .tv-btn { text-decoration: none; }

/* ---------- ordem dos slides (janela) ---------- */
.tv-btn-ordem { display: inline-flex; align-items: center; gap: 6px; justify-self: start; }
.tv-btn-ordem svg { width: 16px; height: 16px; }
.tv-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(5, 8, 15, .7); backdrop-filter: blur(4px); }
.tv-modal-caixa { width: min(620px, 100%); max-height: min(760px, calc(100dvh - 40px)); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.tv-modal-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.tv-modal-topo h3 { margin: 0 0 4px; font-size: 18px; }
.tv-modal-topo p { margin: 0; font-size: 13px; }
.tv-modal-rodape { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.tv-ordem { list-style: none; margin: 0; padding: 12px 14px; overflow-y: auto; display: grid; gap: 8px; }
.tv-ordem-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; cursor: grab; }
.tv-ordem-item.arrastando { opacity: .5; border-color: var(--primary); }
.tv-ordem-item.inativa { opacity: .6; }
.tv-ordem-pos { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 800; font-size: 13px; }
.tv-ordem-alca { color: var(--muted); letter-spacing: -2px; user-select: none; }
.tv-ordem-thumb { flex: none; width: 64px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--bg); display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.tv-ordem-nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.tv-ordem-nome small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.tv-ordem-setas { display: flex; gap: 4px; }
.tv-ordem-setas .tv-btn { padding: 4px 10px; }
