/* ===========================
   Arab TV - Smart TV Styles
   10-foot UI, Focus States,
   Overscan Safe Area, D-pad Nav
   =========================== */

/* ── TV Mode Detection ── */
.tv-mode {
  --tv-focus-color: #3b82f6;
  --tv-focus-glow: 0 0 0 3px rgba(59,130,246,0.5), 0 0 20px rgba(59,130,246,0.3);
  --tv-overscan: 2.5%;
  cursor: none;
}

/* ── Overscan Safe Area ── */
.tv-mode .home-container,
.tv-mode .live-container,
.tv-mode .browse-layout,
.tv-mode .pro-player-page {
  margin: 0;
}
.tv-mode .navbar {
  padding-right: var(--tv-overscan);
  padding-left: var(--tv-overscan);
}

/* ── Larger Text for TV distance ── */
.tv-mode {
  font-size: 16px;
}
.tv-mode .navbar {
  height: 64px;
}
.tv-mode .nav-tabs a,
.tv-mode .nav-tabs button {
  padding: 0.6rem 1.5rem;
  font-size: 1.1rem;
}
.tv-mode .ch-name {
  font-size: 1.05rem;
}
.tv-mode .ch-cat {
  font-size: 0.85rem;
}
.tv-mode .category-item .cat-name {
  font-size: 1rem;
}
.tv-mode .card-title {
  font-size: 0.95rem;
}
.tv-mode .card-label {
  font-size: 1.6rem;
}

/* ── Focus Ring (Critical for TV) ── */
.tv-mode *:focus {
  outline: none;
}
.tv-mode *:focus-visible {
  outline: 3px solid var(--tv-focus-color);
  outline-offset: 2px;
  box-shadow: var(--tv-focus-glow);
  z-index: 10;
  position: relative;
}

/* Home cards focus */
.tv-mode .home-card:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgba(59,130,246,0.4), 0 0 30px rgba(59,130,246,0.5);
  transform: translateY(-6px) scale(1.04);
}

/* Channel items focus */
.tv-mode .channel-item:focus-visible {
  background: var(--bg-card-active);
  border-right: 4px solid var(--tv-focus-color);
  outline: 2px solid var(--tv-focus-color);
  outline-offset: -2px;
}

/* Category items focus */
.tv-mode .category-item:focus-visible {
  background: var(--bg-card-active);
  border-right: 4px solid var(--tv-focus-color);
  outline: 2px solid var(--tv-focus-color);
  outline-offset: -2px;
}

/* Media cards focus */
.tv-mode .media-card:focus-visible {
  outline: 3px solid var(--tv-focus-color);
  outline-offset: 3px;
  box-shadow: var(--tv-focus-glow);
  transform: translateY(-6px) scale(1.05);
}
.tv-mode .media-card:focus-visible .play-overlay {
  opacity: 1;
}

/* Episode items focus */
.tv-mode .episode-item:focus-visible {
  outline: 2px solid var(--tv-focus-color);
  background: var(--bg-card-active);
}

/* Season tabs focus */
.tv-mode .season-tab:focus-visible {
  outline: 2px solid var(--tv-focus-color);
  outline-offset: 2px;
}

/* Buttons focus */
.tv-mode button:focus-visible,
.tv-mode .btn:focus-visible,
.tv-mode .source-btn:focus-visible {
  outline: 3px solid var(--tv-focus-color);
  outline-offset: 2px;
  box-shadow: var(--tv-focus-glow);
}

/* Nav links focus */
.tv-mode .nav-tabs a:focus-visible {
  outline: 2px solid var(--tv-focus-color);
  outline-offset: 2px;
  background: rgba(59,130,246,0.15);
  border-radius: 8px;
}

/* Genre sidebar items focus */
.tv-mode .browse-sidebar .category-item:focus-visible {
  background: var(--bg-card-active);
  outline: 2px solid var(--tv-focus-color);
}

/* Select/input focus on TV */
.tv-mode select:focus-visible,
.tv-mode input:focus-visible {
  border: 2px solid var(--tv-focus-color);
  box-shadow: var(--tv-focus-glow);
}

/* ── TV Home Page ── */
.tv-mode .home-cards {
  gap: 2rem;
}
.tv-mode .home-card {
  width: 380px;
  height: 260px;
}
.tv-mode .home-card .card-icon svg {
  width: 90px;
  height: 90px;
}

/* ── TV Live Layout ── */
.tv-mode .live-container {
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
}
.tv-mode .channel-item {
  padding: 0.75rem 1rem;
}
.tv-mode .channel-item .ch-logo {
  width: 48px;
  height: 48px;
}
.tv-mode .category-item {
  padding: 0.85rem 1rem;
}

/* ── TV Player Page ── */
.tv-mode .pro-player-container {
  max-height: 80vh;
}
.tv-mode .source-bar {
  padding: 0.75rem 1.25rem;
}
.tv-mode .source-btn {
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
}

/* ── TV Media Grid ── */
.tv-mode .media-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

/* ── TV Settings ── */
.tv-mode .modal {
  max-width: 600px;
  font-size: 1rem;
}
.tv-mode .setting-group label {
  font-size: 1rem;
}
.tv-mode .setting-group select {
  font-size: 1rem;
  padding: 0.65rem;
}

/* ── TV Mode Toggle Button ── */
.tv-toggle {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 90;
  transition: all 0.2s;
  cursor: pointer;
}
.tv-toggle:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.tv-mode .tv-toggle { color: var(--accent); border-color: var(--accent); }

/* ── TV Install Banner ── */
.tv-mode .install-banner {
  bottom: 2rem;
  padding: 1.5rem 2rem;
  font-size: 1.1rem;
  max-width: 600px;
}
.tv-mode .install-banner .btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

/* ── Hide elements on TV ── */
.tv-mode .mobile-nav,
.tv-mode .bottom-bar {
  display: none !important;
}
.tv-mode .nav-tabs {
  display: flex !important;
}

/* ── Toast on TV ── */
.tv-mode .toast {
  font-size: 1rem;
  padding: 0.8rem 1.5rem;
}

/* ── TV Subtitle Panel ── */
.tv-mode .sub-panel {
  font-size: 1rem;
}
.tv-mode .sub-panel .sub-item {
  padding: 0.85rem 1rem;
}

/* ── Scrollbar hidden on TV ── */
.tv-mode ::-webkit-scrollbar {
  width: 4px;
}
.tv-mode ::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
}

/* ── TV Responsive (large screens) ── */
@media (min-width: 1920px) {
  .tv-mode {
    font-size: 18px;
  }
  .tv-mode .home-card {
    width: 440px;
    height: 300px;
  }
  .tv-mode .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 2rem;
  }
  .tv-mode .channel-item .ch-logo {
    width: 56px;
    height: 56px;
  }
  .tv-mode .navbar {
    height: 72px;
  }
  .tv-mode .nav-tabs a {
    font-size: 1.2rem;
    padding: 0.7rem 2rem;
  }
}

/* ── 4K TV ── */
@media (min-width: 3200px) {
  .tv-mode {
    font-size: 24px;
  }
  .tv-mode .home-card {
    width: 600px;
    height: 400px;
  }
  .tv-mode .home-card .card-icon svg {
    width: 120px;
    height: 120px;
  }
  .tv-mode .card-label {
    font-size: 2.2rem;
  }
}
