/* ===========================
   Base / Tokens
=========================== */
:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --chip: #f1f5f9;
  --primary: #0ea5e9;
  --primary-ink: #ffffff;
  --accent: #22c55e;
  --warn: #fef08a;
  --danger: #ef4444;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 24px rgba(15, 23, 42, .06);

  /* Tamanho padrão de ícone de plataforma */
  --pf-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
}

a { color: inherit; text-decoration: none; }

/* ===========================
   Layout comum (Home)
=========================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 12px;
}

.title {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 700;
}

.search {
  flex: 1 1 260px;
  display: flex;
  gap: 8px;
  position: relative; /* Para o dropdown */
}

.input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
}
.input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 500;
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Filtros Colapsáveis (AJUSTE VISUAL 1) --- */
.tag-clouds {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px; /* Reduzi um pouco o padding geral */
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 12px; /* Espaçamento entre os blocos details */
}

/* Estilo para o <details> dentro de .tag-clouds */
.tag-clouds details {
  border-radius: 10px;
  overflow: hidden;
}

/* Estilo para o <summary> (título do filtro) */
.tag-clouds summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  background: var(--chip); /* Fundo quando fechado */
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--fg);
  transition: background-color 0.2s, border-color 0.2s;
}

/* Remove marcador padrão do summary */
.tag-clouds summary::-webkit-details-marker { display: none; }

/* Hover no summary */
.tag-clouds summary:hover {
  background: #e2e8f0;
}

/* Ícone de seta para indicar expansão */
.tag-clouds summary::after {
  content: '';
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-left: 8px;
}

/* Estilo quando o details está ABERTO */
.tag-clouds details[open] summary {
  background: transparent; /* Fundo transparente quando aberto */
  border-color: transparent;
  border-bottom-color: var(--border); /* Apenas borda inferior */
  border-radius: 10px 10px 0 0; /* Arredonda só em cima */
  margin-bottom: 0;
}

/* Gira a seta quando aberto */
.tag-clouds details[open] summary::after {
  transform: rotate(225deg);
}

/* Contêiner dos chips (aparece quando aberto) */
.tag-clouds .chips {
  padding: 12px;
  border: 1px solid var(--border);
  border-top: none; /* Remove borda superior (já tem no summary) */
  border-radius: 0 0 10px 10px; /* Arredonda só embaixo */
  background: #fff;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Remove o h4 antigo se ainda estiver no HTML, pois o summary faz esse papel */
.tag-clouds h4 { display: none; }

/* --- Fim Filtros Colapsáveis --- */


.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.1;
}
.chip.active {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}

.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.muted { color: var(--muted); font-size: 13px; }

mark {
  background: var(--warn);
  color: var(--fg);
  padding: 1px 3px;
  border-radius: 4px;
}

/* ===========================
   Grid / Card
=========================== */
.grid {
  display: grid;
  gap: 14px;
  /* Ajuste para grids, se necessário no futuro */
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  /* Garante que a imagem não estique a altura do card desnecessariamente */
  align-items: flex-start;
  /* No mobile (padrão), o layout é horizontal (row) */
  flex-direction: row;
}

/* --- Pôsteres Mobile (AJUSTE VISUAL 2) --- */
.card-media {
  position: relative;
  background: #e5e7eb;
  cursor: pointer;
  /* Remove aspect-ratio fixo 16/9 que cortava */
  /* aspect-ratio: 16/9; */
  /* Impede que a imagem encolha */
  flex-shrink: 0;
  /* Largura fixa para o container da imagem no mobile */
  width: 130px;
  /* Altura automática baseada no aspect-ratio da imagem */
  height: auto;
}
.thumb {
  width: 100%;
  height: 100%;
  display: block;
  /* Garante proporção de pôster */
  aspect-ratio: 2 / 3;
  /* Preenche o espaço sem distorcer, cortando se necessário */
  object-fit: cover;
}
/* --- Fim Pôsteres Mobile --- */


/* Botão "Ver trailer" centralizado horizontalmente, mantendo perto da base */
.play {
  position: absolute;
  left: 50%;
  right: auto;
  top: auto;
  bottom: 8px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(2,6,23,.25);
  /* Garante que o botão não fique muito grande no mobile */
  white-space: nowrap;
}
.play:hover { filter: brightness(1.05); transform: translateX(-50%) translateY(-1px); }
.play[disabled] { opacity: .5; cursor: not-allowed; transform: translateX(-50%); }

.card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.title-sm { font-weight: 700; font-size: 15px; }

/* ===========================
   Ano + Status em linhas próprias (sem mexer no HTML atual)
=========================== */
.kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: stretch;
}
.kicker .muted {        /* Ano */
  flex: 0 0 100%;
  display: block;
}
.kicker .badge {        /* Na lista / Assistido */
  flex: 0 0 100%;
  display: block;
  text-align: center;
  padding: 8px 10px;
  font-weight: 700;
  border-radius: 10px;
}

/* Suporte à nova estrutura do template (quando o JS passar a usá-lo) */
.meta-row { margin-top: 2px; }
.year-row .year { color: var(--muted); font-size: 13px; }
.status-row .badge { width: 100%; text-align: center; padding: 8px 10px; font-weight: 700; border-radius: 10px; }

/* Badges de status mais evidentes */
.badge {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--chip);
}
.badge.status-assistido {
  background: rgba(34, 197, 94, .14);
  border-color: rgba(34, 197, 94, .35);
  color: #14532d;
}
.badge.status-na_lista {
  background: rgba(234, 179, 8, .18);
  border-color: rgba(234, 179, 8, .4);
  color: #713f12;
}

/* ===========================
   Gêneros e Plataformas
=========================== */
.tags, .platforms {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}

/* Força o rótulo a ocupar uma linha inteira antes das tags,
   evitando ficar na mesma linha do primeiro chip */
.tags .section-label,
.platforms .section-label {
  flex-basis: 100%;
  margin-bottom: 2px;
}

/* Separação visual */
.platforms {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
}

/* Cores distintas */
.badge-genre {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #312e81;
}
.badge-platform {
  background: #ecfeff;
  border-color: #a5f3fc;
  color: #164e63;
}

/* ===========================
   Collapsibles (quando usar <details>)
=========================== */
.platforms-block { margin-top: 2px; }
.platforms-details { margin-top: 4px; }
.platforms-details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.platforms-details > summary::-webkit-details-marker { display: none; }
.platforms-details[open] > summary { background: var(--chip); }

/* Comentários */
.comments-block > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 500;
}
.comments-block > summary::-webkit-details-marker { display: none; }
.comments { margin-top: 8px; }

/* ===========================
   Títulozinhos
=========================== */
.section-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
  display: block;
}

.footer { padding: 8px 0; display: flex; justify-content: center; }
.pagination { display: flex; gap: 6px; }

/* ===========================
   Modal (trailer)
=========================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .8);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal.open { display: flex; }
.modal-card {
  width: min(960px, 100%);
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0b1020;
  color: #fff;
  padding: 10px 14px;
}
.modal-body { aspect-ratio: 16/9; background: #000; }
.modal-body iframe { width: 100%; height: 100%; border: 0; }

/* ===========================
   Utilidades
=========================== */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.results-info { margin: 8px 0 6px; }
.is-hidden { display: none !important; }

/* ===========================
   Dropdown de Busca
=========================== */
#dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 20;
  margin-top: 6px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 400px;
  overflow-y: auto;
}
.dd-row {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
}
.dd-row:hover { background-color: var(--chip); }
.dd-row.active { background-color: #e0f2fe; color: #0c4a6e; }
.dd-row img {
  width: 40px; height: 60px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
}

/* ===========================
   Página de Inserção
=========================== */
.preview {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #fff;
}

/* ===========================
   Chips com ícone (plataformas)
=========================== */
.chip.platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  --pf-size: 16px;
  white-space: nowrap;          /* evita quebra em 2 linhas dentro do chip */
}
.chip.platform img {
  width: var(--pf-size);
  height: var(--pf-size);
  max-width: none;
  max-height: none;
  object-fit: contain;
  display: block;
  border-radius: 3px;
  image-rendering: -webkit-optimize-contrast;
}
.chip.platform .pf-fallback {
  width: var(--pf-size);
  height: var(--pf-size);
  border-radius: 50%;
  background: var(--fg);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
}

/* ===========================
   Utilitários de ícone fora do chip
=========================== */
.pf {
  --pf-size: 16px;
  inline-size: var(--pf-size);
  block-size: var(--pf-size);
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: transparent;
}
.pf > img, .pf > svg {
  max-inline-size: 100%;
  max-block-size: 100%;
  object-fit: contain;
  display: block;
}
.pf-16  { --pf-size: 16px; }
.pf-20  { --pf-size: 20px; }
.pf-24  { --pf-size: 24px; }
.pf-32  { --pf-size: 32px; }
.pf-40  { --pf-size: 40px; }
.pf-48  { --pf-size: 48px; }
.pf-64  { --pf-size: 64px; }
.pf.rounded { border-radius: 8px; }

/* ===========================
   Logos dentro de .platforms
=========================== */
.platforms .badge-platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  line-height: 1;
}
.platforms .badge-platform img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
  border-radius: 3px;
}

/* ===========================
   Seções (Filmes / Séries)
=========================== */
.sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-block {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: var(--card);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.section-foot {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.section-foot .btn {
  width: 100%;
  max-width: 360px;
}

/* ===========================
   Media Queries (Desktop)
=========================== */
@media (min-width: 768px) {
  /* Em telas maiores, os cards voltam a ser verticais (coluna) */
  .card {
    flex-direction: column;
  }

  /* A imagem volta a ter aspect-ratio de vídeo para o topo do card */
  .card-media {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    flex-shrink: 1; /* Pode encolher se necessário */
  }
  /* Thumb volta a preencher o container 16/9 */
  .thumb {
    aspect-ratio: auto; /* Remove o 2/3 fixo */
  }

  /* Botão play volta ao centro */
  .play {
    font-size: 14px;
    padding: 12px 16px;
  }

  /* Ano + Status voltam a ficar na mesma linha */
  .kicker {
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
  }
  .kicker .muted,
  .kicker .badge {
    flex: 0 1 auto; /* Tamanho automático */
    display: inline-block;
    width: auto;
    text-align: left;
    padding: 3px 6px; /* Padding de badge normal */
    font-weight: normal;
    border-radius: 6px;
  }
  /* Reverte estilo de badge "block" */
  .kicker .badge { font-size: 11px; }
}