:root {
  --astro-black: #080808;
  --astro-surface: #151515;
  --astro-surface-2: #202020;
  --astro-red: #E50914;
  --astro-red-dark: #A4060D;
  --astro-white: #FFFFFF;
  --astro-gray: #A6A6A6;
  --astro-light-gray: #6B6B6B;
  --astro-border: #303030;
  --focus-ring: 0 0 0 3px #E50914, 0 0 0 6px rgba(255, 255, 255, 0.88), 0 12px 28px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  background: var(--astro-black);
  color: var(--astro-white);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
  user-select: none;
}

/* Topo fixo 16:9 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 32px;
  background: rgba(8, 8, 8, 0.96);
  border-bottom: 1px solid #1e1e1e;
}

.brand-wrap { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo { height: 40px; width: auto; object-fit: contain; display: block; }

.demo-pill {
  background: rgba(229, 9, 20, 0.2);
  border: 1px solid var(--astro-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--astro-surface);
  color: var(--astro-gray);
  border: 1px solid var(--astro-border);
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.nav-btn img { width: 18px; height: 18px; object-fit: contain; opacity: 0.85; }
.nav-btn.active { background: var(--astro-red); border-color: var(--astro-red); color: #fff; }
.nav-btn.active img { opacity: 1; }

.focusable:focus,
.focusable.tv-focused {
  outline: none;
  box-shadow: var(--focus-ring);
  transform: scale(1.03);
  z-index: 10;
  position: relative;
}

.main-content {
  padding: 16px 32px 64px;
  max-width: 1920px;
  margin: 0 auto;
}

/* Home Sections */
.section-block { margin-bottom: 28px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; }
.section-title::before { content: ''; display: inline-block; width: 4px; height: 22px; border-radius: 2px; background: var(--astro-red); }
.section-subtitle { font-size: 13px; color: var(--astro-gray); }

.row-rail {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 8px 4px 14px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

/* Game Card (Escudos duplos) */
.game-card {
  flex: 0 0 300px;
  background: linear-gradient(145deg, #1a1a1a 0%, #101010 100%);
  border: 1px solid var(--astro-border);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.game-card-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--astro-gray); }
.game-time-pill { background: var(--astro-red); color: #fff; font-weight: 700; padding: 3px 9px; border-radius: 6px; font-size: 12px; }
.game-youth-pill { background: #2b2b2b; color: #ffd166; border: 1px solid #444; font-weight: 700; padding: 2px 7px; border-radius: 6px; font-size: 11px; }
.game-crests { display: flex; align-items: center; justify-content: space-around; gap: 8px; min-height: 70px; }
.team-slot { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 42%; text-align: center; }
.team-badge { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,0.04); padding: 3px; }
.team-badge-fallback { width: 52px; height: 52px; border-radius: 50%; background: var(--astro-surface-2); border: 1px solid var(--astro-border); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; }
.team-name { font-size: 13px; font-weight: 600; line-height: 1.2; color: #fff; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vs-label { font-size: 14px; font-weight: 800; color: var(--astro-red); }

/* Poster Card */
.poster-card {
  flex: 0 0 176px;
  background: var(--astro-surface);
  border: 1px solid var(--astro-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.poster-img-wrap { position: relative; width: 100%; aspect-ratio: 300 / 440; background: var(--astro-surface-2); overflow: hidden; }
.poster-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-badge { position: absolute; top: 8px; right: 8px; background: rgba(8,8,8,0.86); border: 1px solid rgba(255,255,255,0.2); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.poster-progress-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255,255,255,0.28); }
.poster-progress-fill { height: 100%; background: var(--astro-red); }
.poster-meta { padding: 9px 10px 11px; display: flex; flex-direction: column; gap: 3px; }
.poster-title { font-size: 13px; font-weight: 600; line-height: 1.28; color: #fff; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poster-sub { font-size: 11px; color: var(--astro-gray); }

/* ============================================================
   LAYOUT TRADICIONAL SMART TV: CANAIS (3 COLUNAS + MINI-PLAYER + EPG)
   ============================================================ */
.channels-layout {
  display: grid;
  grid-template-columns: 270px 1fr 410px;
  gap: 16px;
  height: calc(100vh - 106px);
  min-height: 520px;
}

.sidebar-col {
  background: var(--astro-surface);
  border: 1px solid var(--astro-border);
  border-radius: 14px;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #101010;
  color: #dcdcdc;
  border: 1px solid #262626;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.sidebar-item.active {
  background: var(--astro-red);
  border-color: var(--astro-red);
  color: #fff;
}
.sidebar-item .cat-count {
  font-size: 12px;
  opacity: 0.78;
  flex-shrink: 0;
}

.channel-list-col {
  background: var(--astro-surface);
  border: 1px solid var(--astro-border);
  border-radius: 14px;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.channel-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #101010;
  color: #fff;
  border: 1px solid #262626;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
.channel-row.playing {
  background: #ffffff;
  color: #080808;
  border-color: var(--astro-red);
}
.channel-row.playing .ch-sub { color: #444; }

.ch-fav-btn {
  background: transparent;
  border: none;
  color: var(--astro-gray);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.ch-fav-btn.is-fav { color: var(--astro-red); }

.ch-logo-box {
  width: 44px;
  height: 32px;
  border-radius: 6px;
  background: #202020;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}
.ch-logo-box img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.ch-info { flex: 1; min-width: 0; }
.ch-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { font-size: 12px; color: var(--astro-gray); margin-top: 2px; }

/* Coluna Direita: Mini-Player + EPG */
.preview-epg-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.mini-player-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--astro-border);
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
}
.mini-player-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.mini-player-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 12px;
  background: linear-gradient(0deg, rgba(0,0,0,0.9), transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}
.mini-fs-btn {
  background: var(--astro-red);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.epg-panel {
  flex: 1;
  background: var(--astro-surface);
  border: 1px solid var(--astro-border);
  border-radius: 14px;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.epg-card {
  background: #101010;
  border: 1px solid #262626;
  border-radius: 10px;
  padding: 10px 12px;
}
.epg-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.epg-title { font-size: 14px; font-weight: 700; color: #fff; }
.epg-badge-live { background: var(--astro-red); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.epg-badge-next { background: #262626; color: #d4d4d4; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.epg-prog-bg { width: 100%; height: 4px; background: #4a4a4a; border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.epg-prog-fill { height: 100%; background: var(--astro-red); }
.epg-time-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--astro-gray); }

/* ============================================================
   LAYOUT TRADICIONAL SMART TV: FILMES E SÉRIES (2 COLUNAS)
   ============================================================ */
.catalog-split-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 18px;
  height: calc(100vh - 106px);
  min-height: 520px;
}

.catalog-grid-col {
  overflow-y: auto;
  padding: 4px 6px 24px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

/* Detalhes + Elenco TMDB */
.details-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 8, 8, 0.97);
  overflow-y: auto;
  padding: 28px 44px 64px;
}
.details-hero { display: grid; grid-template-columns: 250px 1fr; gap: 32px; align-items: start; margin-top: 16px; }
.details-poster { width: 100%; aspect-ratio: 300 / 440; object-fit: cover; border-radius: 14px; border: 1px solid var(--astro-border); background: var(--astro-surface-2); }
.details-title { font-size: 32px; font-weight: 800; line-height: 1.15; margin-bottom: 10px; }
.details-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; color: var(--astro-gray); font-size: 14px; }
.details-plot { font-size: 16px; line-height: 1.6; color: #dcdcdc; max-width: 780px; margin-bottom: 22px; }
.action-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }

.btn-primary { background: var(--astro-red); color: #fff; border: none; border-radius: 10px; padding: 12px 24px; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-secondary { background: var(--astro-surface-2); color: #fff; border: 1px solid var(--astro-border); border-radius: 10px; padding: 12px 20px; font-size: 15px; font-weight: 600; cursor: pointer; }

.cast-rail { display: flex; gap: 14px; overflow-x: auto; padding: 8px 4px 16px; }
.actor-card { flex: 0 0 124px; background: var(--astro-surface); border: 1px solid var(--astro-border); border-radius: 12px; padding: 10px; text-align: center; cursor: pointer; color: #fff; }
.actor-photo { width: 78px; height: 78px; border-radius: 50%; object-fit: cover; margin: 0 auto 8px; background: var(--astro-surface-2); display: block; }
.actor-name { font-size: 13px; font-weight: 700; line-height: 1.25; }
.actor-role { font-size: 11px; color: var(--astro-gray); margin-top: 3px; }
.episodes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 12px; }
.episode-card { background: var(--astro-surface); border: 1px solid var(--astro-border); border-radius: 10px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; color: #fff; text-align: left; }

/* Busca */
.search-bar-wrap { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; align-items: center; }
.search-input { flex: 1 1 300px; background: var(--astro-surface); color: #fff; border: 1px solid var(--astro-border); border-radius: 10px; padding: 13px 16px; font-size: 16px; }

/* Ativação por Código Único */
.activation-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at top, #230709 0%, #080808 60%); }
.activation-card { width: 100%; max-width: 660px; background: var(--astro-surface); border: 1px solid var(--astro-border); border-radius: 20px; padding: 36px; text-align: center; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75); }
.activation-logo { height: 54px; margin: 0 auto 20px; display: block; }
.device-code-box { margin: 22px auto; padding: 20px 24px; background: #0d0d0d; border: 2px solid var(--astro-red); border-radius: 16px; font-size: 42px; font-weight: 900; letter-spacing: 0.12em; color: #fff; }
.activation-status { font-size: 15px; color: var(--astro-gray); margin-bottom: 22px; line-height: 1.5; }

/* Player Tela Cheia com Barra Arrastável (Vermelho assistido / Cinza clarinho restante) */
.player-overlay { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; flex-direction: column; justify-content: center; }
.player-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-hud {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 24px 36px;
  background: linear-gradient(180deg, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0) 28%, rgba(0,0,0,0) 64%, rgba(0,0,0,0.92) 100%);
  transition: opacity 0.25s ease;
}
.player-hud.hidden-hud { opacity: 0; pointer-events: none; }
.player-controls-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.seek-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #E50914 0%, #E50914 var(--seek-pct, 0%), #6e6e6e var(--seek-pct, 0%), #6e6e6e 100%);
  outline: none;
  cursor: pointer;
  margin-bottom: 14px;
}
.seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #E50914;
  cursor: pointer;
}
.seek-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #E50914;
  cursor: pointer;
}

.hidden { display: none !important; }

@media (max-width: 960px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .brand-logo { height: 32px; }
  .main-content { padding: 12px 14px 64px; }
  .channels-layout { grid-template-columns: 1fr; height: auto; }
  .catalog-split-layout { grid-template-columns: 1fr; height: auto; }
  .sidebar-col { flex-direction: row; overflow-x: auto; max-height: 70px; }
  .sidebar-item { width: auto; white-space: nowrap; }
  .details-hero { grid-template-columns: 1fr; }
  .device-code-box { font-size: 28px; }
}
