/* SLIM TV Player — linguagem da skill slim-apple-design (paleta escura + vermelho SLIM) e geometria slim-golden-ratio. */
:root {
  color-scheme: dark;
  --fundo: #07080c;
  --painel: #111218;
  --painel-claro: #191b22;
  --vermelho: #d00000;
  --vermelho-foco: #e50914;
  --vermelho-ativo: #ff3b3b;
  --texto: #ffffff;
  --texto-2: #b6b8c2;
  --texto-3: #858894;
  --linha: rgba(255, 255, 255, 0.10);
  --linha-forte: rgba(255, 255, 255, 0.20);
  --branco-8: rgba(255, 255, 255, 0.08);
  --branco-12: rgba(255, 255, 255, 0.12);
  /* raios Fibonacci */
  --raio-selo: 8px;
  --raio-card: 13px;
  --raio-painel: 21px;
  --raio-modal: 34px;
  --raio-capsula: 999px;
  --linha-canal: 52px;
  --rapido: 140ms;
  --fonte: Inter, "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fundo);
  color: var(--texto);
  font: 400 15px/1.35 var(--fonte);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

:focus-visible { outline: 2px solid var(--texto); outline-offset: 3px; }

/* ---------- botões e campos ---------- */
.botao {
  border: 0; border-radius: var(--raio-capsula); padding: 0 21px; min-height: 44px;
  font-weight: 600; cursor: pointer; transition: transform var(--rapido), background var(--rapido);
}
.botao:active { transform: scale(0.97); }
.botao.principal { background: var(--vermelho); color: #fff; }
.botao.principal:hover { background: var(--vermelho-foco); }
.botao.principal:disabled { opacity: 0.5; cursor: default; }
.botao.fantasma { background: var(--branco-12); }
.botao.fantasma:hover { background: rgba(255, 255, 255, 0.2); }
.botao.pequeno { min-height: 34px; padding: 0 16px; font-size: 13px; }

input {
  width: 100%; min-height: 46px; padding: 0 18px; border-radius: var(--raio-capsula);
  background: var(--branco-8); border: 1px solid var(--linha-forte); outline: none;
  transition: border-color var(--rapido), background var(--rapido);
}
input:focus { border-color: #fff; background: var(--branco-12); }
input::placeholder { color: var(--texto-3); }

/* ---------- entrada ---------- */
.entrada {
  min-height: 100%; display: grid; place-items: center; padding: 21px; overflow: auto;
  background: radial-gradient(1200px 700px at 50% -10%, rgba(208, 0, 0, 0.18), transparent 60%), var(--fundo);
}
.cartao-entrada {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 13px;
  background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio-modal); padding: 34px;
}
.cartao-entrada .logo { height: 46px; align-self: center; margin-bottom: 8px; }
.cartao-entrada h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.015em; text-align: center; }
.cartao-entrada .sub { margin: -5px 0 8px; color: var(--texto-2); text-align: center; font-size: 14px; }
.cartao-entrada label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--texto-2); }
.mais summary { cursor: pointer; color: var(--texto-2); font-size: 13px; padding: 4px 0; }
.mais[open] summary { margin-bottom: 8px; }
.erro { margin: 0; color: var(--vermelho-ativo); font-size: 14px; }
.cartao-entrada .botao { margin-top: 8px; }

/* ---------- app: grade ---------- */
.app { height: 100%; display: flex; flex-direction: column; gap: 13px; padding: 13px 21px 21px; }
.vista { flex: 1; min-height: 0; display: grid; gap: 13px; }
.vista-canais {
  grid-template-columns: 220px 340px 1fr;
  grid-template-areas: "cat canais palco";
}
.vista-vod { grid-template-columns: 220px 1fr; grid-template-areas: "cat acervo"; }
.topo { display: flex; align-items: center; gap: 13px; min-height: 44px; }
.abas { display: flex; gap: 5px; margin-left: 13px; padding: 4px; background: var(--branco-8); border-radius: var(--raio-capsula); }
.aba {
  border: 0; background: transparent; color: var(--texto-2); min-height: 36px; padding: 0 18px;
  border-radius: var(--raio-capsula); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background var(--rapido), color var(--rapido);
}
.aba:hover { color: var(--texto); }
.aba[aria-selected="true"] { background: var(--vermelho); color: #fff; }
.logo-topo { height: 30px; }
.vencimento { margin-left: auto; color: var(--texto-2); font-size: 13px; }

.categorias, .canais, .acervo {
  background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio-painel);
  min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.categorias { grid-area: cat; }
.canais { grid-area: canais; }
.acervo { grid-area: acervo; }
.palco { grid-area: palco; min-width: 0; display: flex; flex-direction: column; gap: 13px; }

/* categorias */
.lista-categorias { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.categoria {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 13px; border: 0; border-radius: var(--raio-capsula);
  background: transparent; color: var(--texto-2); text-align: left; cursor: pointer; font-size: 14px;
  transition: background var(--rapido), color var(--rapido);
}
.categoria span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.categoria .qtd { color: var(--texto-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.categoria:hover { background: var(--branco-8); color: var(--texto); }
.categoria[aria-selected="true"] { background: var(--vermelho); color: #fff; font-weight: 600; }
.categoria[aria-selected="true"] .qtd { color: rgba(255, 255, 255, 0.8); }

/* canais */
.busca { padding: 8px 8px 5px; }
.busca input { min-height: 40px; }
.rolagem { flex: 1; overflow-y: auto; position: relative; scrollbar-width: thin; outline: none; }
.altura { position: relative; }
.janela { position: absolute; left: 0; right: 0; top: 0; padding: 0 8px; will-change: transform; }
.canal {
  height: var(--linha-canal); display: flex; align-items: center; gap: 13px; padding: 0 13px;
  border-radius: var(--raio-card); cursor: pointer; color: var(--texto); transition: background var(--rapido);
}
.canal:hover { background: var(--branco-8); }
.canal.ativo { background: var(--vermelho); }
.canal.ativo .num { color: rgba(255, 255, 255, 0.85); }
.canal .num { width: 40px; flex: none; text-align: right; color: var(--texto-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.canal .icone { width: 34px; height: 34px; flex: none; border-radius: var(--raio-selo); object-fit: contain; background: var(--branco-8); }
.canal .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.vazio { margin: 21px; color: var(--texto-3); text-align: center; }

/* favoritos: o coração do app (vazio / vermelho cheio) */
.coracao { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.coracao.cheio { fill: var(--vermelho-ativo); stroke: var(--vermelho-ativo); }
.botao.fav { display: inline-flex; align-items: center; gap: 8px; }
.agora-nome .fav { margin-left: auto; flex: none; }
.canal .marca { width: 16px; height: 16px; flex: none; color: var(--vermelho-ativo); fill: var(--vermelho-ativo); stroke: none; }
.canal.ativo .marca { fill: #fff; color: #fff; }
.capa .selo-fav {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(7, 8, 12, 0.7);
}
.capa .selo-fav svg { width: 15px; height: 15px; fill: var(--vermelho-ativo); }

/* grade de capas (filmes/séries), virtual por fileira */
.grade { position: absolute; left: 0; right: 0; top: 0; padding: 0 13px; display: grid; gap: 13px; will-change: transform; }
.capa {
  position: relative; border: 0; padding: 0; background: transparent; color: var(--texto); cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.capa .poster {
  width: 100%; aspect-ratio: 2 / 3; border-radius: var(--raio-card); overflow: hidden; background: var(--painel-claro);
  transition: transform var(--rapido), box-shadow var(--rapido);
}
.capa img { width: 100%; height: 100%; object-fit: cover; display: block; }
.capa .titulo { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--texto-2); }
.capa .barra { position: absolute; left: 8px; right: 8px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.capa .barra i { display: block; height: 100%; background: var(--vermelho-ativo); }
.capa:hover .poster, .capa:focus-visible .poster { transform: scale(1.04); box-shadow: 0 0 0 2px var(--fundo), 0 0 0 3.5px var(--vermelho-foco); }
.capa:focus-visible { outline: none; }
.capa:hover .titulo { color: var(--texto); }

/* player */
.quadro {
  position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 190px);
  background: #000; border-radius: var(--raio-painel); overflow: hidden; border: 1px solid var(--linha);
}
.quadro video { width: 100%; height: 100%; display: block; background: #000; }
.quadro:fullscreen { border-radius: 0; border: 0; max-height: none; }
.aviso {
  position: absolute; inset: auto 21px 21px; padding: 13px 18px; border-radius: var(--raio-card);
  background: rgba(7, 8, 12, 0.85); border: 1px solid var(--linha-forte); color: var(--texto); font-size: 14px;
}
.carregando { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.carregando span {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff; animation: gira 0.8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }
.agora { padding: 0 5px; }
.agora-nome { display: flex; align-items: baseline; gap: 13px; }
.agora-nome .num { color: var(--texto-3); font-size: 15px; font-variant-numeric: tabular-nums; }
.agora h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.012em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.epg { margin: 5px 0 0; color: var(--texto-2); font-size: 14px; min-height: 1.35em; }
.epg b { color: var(--vermelho-ativo); font-weight: 600; margin-right: 6px; }

/* ---------- detalhes / player de filmes e séries ---------- */
.detalhe {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 21px;
  background: rgba(7, 8, 12, 0.72);
}
.det-cartao {
  position: relative; width: min(1100px, 100%); max-height: 100%; overflow-y: auto; scrollbar-width: thin;
  background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio-modal);
}
.det-fechar {
  position: absolute; top: 13px; right: 13px; z-index: 3; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(7, 8, 12, 0.7); color: #fff; font-size: 16px; cursor: pointer;
}
.det-fechar:hover { background: rgba(255, 255, 255, 0.2); }
.det-midia { position: relative; aspect-ratio: 16 / 9; max-height: 62vh; width: 100%; background: #000; overflow: hidden; }
.det-fundo { width: 100%; height: 100%; object-fit: cover; display: block; }
.det-degrade { position: absolute; inset: auto 0 0 0; height: 45%; background: linear-gradient(transparent, var(--painel)); pointer-events: none; }
.det-midia .quadro { position: absolute; inset: 0; border: 0; border-radius: 0; max-height: none; aspect-ratio: auto; height: 100%; }
.det-midia.tocando .det-fundo, .det-midia.tocando .det-degrade { display: none; }
.det-corpo { padding: 21px 34px 34px; display: flex; flex-direction: column; gap: 13px; }
.det-corpo h2 { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; }
.det-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.det-meta span { padding: 4px 10px; border-radius: var(--raio-selo); background: var(--branco-12); font-size: 13px; font-weight: 600; }
.det-sinopse { margin: 0; color: var(--texto-2); max-width: 760px; line-height: 1.45; }
.det-elenco { margin: 0; color: var(--texto-3); font-size: 13px; max-width: 760px; }
.det-elenco:empty, .det-sinopse:empty { display: none; }
.det-acoes { display: flex; gap: 13px; flex-wrap: wrap; }
.temporadas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.temporadas .categoria { flex: none; background: var(--branco-8); min-height: 36px; }
.temporadas .categoria[aria-selected="true"] { background: var(--vermelho); color: #fff; }
.episodios { display: flex; flex-direction: column; gap: 5px; }
.episodio {
  display: flex; align-items: center; gap: 13px; padding: 8px; border: 0; border-radius: var(--raio-card);
  background: transparent; color: var(--texto); text-align: left; cursor: pointer; transition: background var(--rapido);
}
.episodio:hover, .episodio.ativo { background: var(--branco-8); }
.episodio.ativo { box-shadow: inset 0 0 0 1.5px var(--vermelho-foco); }
.episodio .mini { width: 160px; flex: none; aspect-ratio: 16 / 9; border-radius: var(--raio-selo); overflow: hidden; background: var(--painel-claro); position: relative; }
.episodio .mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.episodio .mini .barra { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.25); }
.episodio .mini .barra i { display: block; height: 100%; background: var(--vermelho-ativo); }
.episodio .txt { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.episodio .txt b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.episodio .txt small { color: var(--texto-3); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .app { padding: 13px; }
  .vista-canais { grid-template-columns: 200px 300px 1fr; }
  .vista-vod { grid-template-columns: 200px 1fr; }
}

/* ---------- celular: player em cima, categorias em fila, canais embaixo ---------- */
@media (max-width: 820px) {
  body { overflow: hidden; }
  .app { gap: 8px; padding: 8px 0 0; padding-top: max(8px, env(safe-area-inset-top)); --linha-canal: 56px; }
  .vista { gap: 8px; }
  .vista-canais { grid-template-columns: 100%; grid-template-rows: auto auto 1fr; grid-template-areas: "palco" "cat" "canais"; }
  .vista-vod { grid-template-columns: 100%; grid-template-rows: auto 1fr; grid-template-areas: "cat" "acervo"; }
  .topo { padding: 0 13px; min-height: 36px; gap: 8px; flex-wrap: wrap; }
  .abas { order: 3; width: 100%; margin: 0; }
  .aba { flex: 1; padding: 0 8px; }
  .vencimento { font-size: 12px; }
  .acervo { border-radius: var(--raio-painel) var(--raio-painel) 0 0; border-bottom: 0; }
  .grade { padding: 0 8px; gap: 8px; }
  .detalhe { padding: 0; place-items: stretch; }
  .det-cartao { border-radius: 0; border: 0; max-height: none; height: 100%; }
  .det-midia { max-height: none; }
  .det-corpo { padding: 13px 16px 34px; }
  .det-corpo h2 { font-size: 22px; }
  .episodio .mini { width: 120px; }
  .logo-topo { height: 24px; }
  .palco { gap: 8px; }
  .quadro { border-radius: 0; border-left: 0; border-right: 0; max-height: none; }
  .agora { padding: 0 13px; }
  .agora h2 { font-size: 17px; }
  .epg { font-size: 13px; }
  .categorias { background: transparent; border: 0; border-radius: 0; }
  .lista-categorias { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 13px; gap: 8px; scrollbar-width: none; }
  .lista-categorias::-webkit-scrollbar { display: none; }
  .categoria { flex: none; background: var(--branco-8); min-height: 36px; }
  .categoria span:first-child { max-width: 180px; }
  .canais { border-radius: var(--raio-painel) var(--raio-painel) 0 0; border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}
