/* ============================================================
   Z-Movies — TV App Mode CSS
   Applied when html.tv-app-mode is set
   ============================================================ */

/* ── Base TV app setup ──────────────────────────────────────── */
html.tv-app-mode body {
  cursor: default;
}

/* ── TV Sidebar ──────────────────────────────────────────────── */
.tv-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: linear-gradient(180deg, #0d1117 0%, #0a0d12 100%);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: width 0.2s ease;
}

.tv-sb-logo {
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tv-sb-logo img {
  height: 36px;
  width: auto;
}

.tv-sb-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.tv-sb-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  color: rgba(255,255,255,0.5);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  position: relative;
  border: 1px solid transparent;
  background: none;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.tv-sb-link:hover,
.tv-sb-link:focus {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
  outline: none;
}

.tv-sb-link.active {
  color: var(--accent);
  background: rgba(45,212,191,0.08);
  border-color: rgba(45,212,191,0.15);
}

.tv-sb-link.active svg { color: var(--accent); }

.tv-sb-link svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.tv-sb-link:hover svg,
.tv-sb-link.active svg,
.tv-sb-link:focus svg {
  opacity: 1;
}

.tv-sb-live-dot {
  width: 7px;
  height: 7px;
  background: #ef4444;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
  animation: ltv-pulse 1.5s infinite;
}

.tv-sb-link-sm {
  font-size: 13px;
  padding: 10px 14px;
}

.tv-sb-bottom {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

/* ── Page content offset for sidebar ───────────────────────── */
html.tv-app-mode .tv-page-wrapper {
  margin-left: 240px;
  padding-top: 0; /* remove navbar padding — sidebar replaces nav */
}

/* ── Hide navbar when TV app sidebar present ────────────────── */
html.tv-app-mode .navbar {
  display: none !important;
}

/* Detail page — no navbar, full height content */
html.tv-app-mode .page-wrapper {
  padding-top: 0;
  margin-left: 240px;
}

/* ── TV Search Overlay ───────────────────────────────────────── */
.tv-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  z-index: 9500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.tv-search-overlay.open {
  opacity: 1;
}

.tv-search-inner {
  width: 100%;
  max-width: 760px;
  padding: 0 24px;
}

.tv-search-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 18px 24px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 24px;
}

.tv-search-bar:focus-within {
  border-color: var(--accent);
  background: rgba(45,212,191,0.04);
  color: var(--accent);
}

.tv-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 24px;
  font-family: inherit;
  font-weight: 500;
}

.tv-search-input::placeholder { color: rgba(255,255,255,0.3); }

.tv-search-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.tv-search-close:hover, .tv-search-close:focus {
  background: rgba(255,255,255,0.15);
  color: #fff;
  outline: none;
}

.tv-search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}

.tv-search-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
}

.tv-search-item:hover, .tv-search-item:focus {
  border-color: var(--accent);
  transform: scale(1.03);
  outline: none;
}

.tv-search-item img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
}

.tv-search-item-info {
  padding: 0 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tv-search-item-title {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tv-search-item-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
}

.tv-search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  grid-column: 1/-1;
}

.tv-spinner-sm {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ltv-spin 0.7s linear infinite;
}

.tv-search-empty {
  color: rgba(255,255,255,0.4);
  text-align: center;
  padding: 40px;
  grid-column: 1/-1;
  font-size: 15px;
}

/* ── Controls Hint Bar ───────────────────────────────────────── */
.tv-controls-hint {
  position: fixed;
  bottom: 20px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10,13,18,0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 10px 18px;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  z-index: 800;
  pointer-events: none;
}

.tv-hint-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tv-hint-item kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
}

.tv-hint-sep {
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.1);
}

/* ── TV Player Overlay ───────────────────────────────────────── */
#tvPlayerOverlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.7) 0%,
    transparent 25%,
    transparent 60%,
    rgba(0,0,0,0.85) 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

#tvPlayerOverlay.controls-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Top bar */
.tv-player-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 28px;
}

.tv-player-back {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 10px 18px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.tv-player-back:hover, .tv-player-back:focus {
  background: rgba(255,255,255,0.22);
  outline: none;
}

.tv-player-title-area {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tv-player-show-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-player-ep-label {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

/* Center controls */
.tv-player-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.tv-player-big-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.2);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
}

.tv-player-big-btn:hover, .tv-player-big-btn:focus {
  background: rgba(255,255,255,0.25);
  transform: scale(1.08);
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.tv-player-play {
  width: 88px;
  height: 88px;
  background: rgba(45,212,191,0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.tv-player-play:hover, .tv-player-play:focus {
  background: var(--accent);
  color: #000;
}

/* Bottom controls */
.tv-player-bottom {
  padding: 20px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tv-player-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tv-player-time {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 42px;
}

.tv-player-progress-track {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}

.tv-player-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1s linear;
}

.tv-player-progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: left 1s linear;
}

.tv-player-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tv-player-left-actions,
.tv-player-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tv-player-ctrl {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.tv-player-ctrl:hover, .tv-player-ctrl:focus {
  background: rgba(255,255,255,0.18);
  color: #fff;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tv-player-ctrl.muted { color: #ef4444; border-color: rgba(239,68,68,0.4); }

.tv-player-vol-track {
  width: 60px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.tv-player-vol-fill {
  height: 100%;
  background: rgba(255,255,255,0.6);
  border-radius: 2px;
  transition: width 0.2s;
}

.tv-player-hints {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: center;
}

.tv-player-hints span {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  gap: 5px;
}

.tv-player-hints kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: inherit;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
}

/* Settings panel */
.tv-player-settings-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: rgba(10,13,18,0.97);
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tv-settings-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tv-settings-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 12px 12px 0;
  gap: 4px;
}

.tv-settings-tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: 8px 8px 0 0;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.tv-settings-tab.active {
  background: rgba(45,212,191,0.1);
  color: var(--accent);
}

.tv-settings-tab:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tv-settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.tv-settings-pane { display: none; }
.tv-settings-pane.active { display: block; }

/* Override videasy button styles inside our settings panel */
.tv-settings-pane button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.tv-settings-pane button:hover, .tv-settings-pane button:focus {
  background: rgba(255,255,255,0.1);
  color: #fff;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── Context Menu ────────────────────────────────────────────── */
.tv-context-menu {
  position: fixed;
  z-index: 9800;
  background: rgba(15,19,26,0.97);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  pointer-events: none;
}

.tv-context-menu.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.tv-ctx-title {
  padding: 10px 14px 8px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 9px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}

.tv-ctx-item:hover, .tv-ctx-item:focus {
  background: rgba(255,255,255,0.08);
  color: #fff;
  outline: none;
}

.tv-ctx-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* ── TV Toast ────────────────────────────────────────────────── */
.tv-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15,19,26,0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(45,212,191,0.3);
  color: var(--accent);
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9900;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}

.tv-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Hide hover-only card elements on TV (need hold) ─────────── */
html.tv-app-mode .card-overlay { display: none !important; }
html.tv-app-mode .card-watchlist-btn { display: none !important; }
html.tv-app-mode .continue-remove-btn { display: none !important; }
html.tv-app-mode .card-poster::after { display: none !important; }

/* Make cards more TV-friendly */
html.tv-app-mode .media-card {
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s, outline 0.1s;
}

html.tv-app-mode .media-card:focus-within,
html.tv-app-mode .media-card:hover {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  transform: scale(1.04);
}

html.tv-app-mode .cards-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

html.tv-app-mode .scroll-row .media-card {
  min-width: 180px;
  max-width: 220px;
}

/* Hero bigger on TV */
html.tv-app-mode .hero {
  min-height: 65vh;
}

html.tv-app-mode .hero-title {
  font-size: clamp(2rem, 4vw, 3.5rem);
}

/* Detail page full-screen player */
html.tv-app-mode .player-section {
  padding: 0;
  background: #000;
}

html.tv-app-mode .player-wrap {
  aspect-ratio: 16/9;
  width: 100%;
  max-width: 100%;
  border-radius: 0;
  max-height: 100vh;
}

/* Hide original videasy inner UI elements via CSS injection on their iframe */
html.tv-app-mode .player-wrap {
  position: relative;
}

/* Detail page — remove container padding */
html.tv-app-mode .detail-hero {
  padding-top: 0;
}

/* Episode list bigger */
html.tv-app-mode .episode-item {
  padding: 18px;
  border-radius: 12px;
}

html.tv-app-mode .episode-item:hover,
html.tv-app-mode .episode-item:focus {
  outline: 3px solid var(--accent);
  outline-offset: 0;
}

html.tv-app-mode .ep-title { font-size: 16px; }

/* Section titles bigger */
html.tv-app-mode .section-title,
html.tv-app-mode .section-title h2 {
  font-size: 1.5rem;
}

/* Footer hidden on TV */
html.tv-app-mode .footer { display: none; }

/* Live TV page on TV — expand to fill remaining space (sidebar already present) */
html.tv-app-mode .livetv-app {
  padding-top: 0;
}

html.tv-app-mode .ltv-main {
  margin-left: 0; /* livetv has its own sidebar, but on TV we use the global one */
}

html.tv-app-mode .ltv-sidebar {
  display: none; /* hide livetv's own sidebar — global TV sidebar takes over */
}

/* Live TV channel cards TV mode */
html.tv-app-mode .ltv-channel-card:focus,
html.tv-app-mode .ltv-channel-card-lg:focus {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  transform: scale(1.05);
}

/* ── Responsive: TV sidebar collapses to icons on narrow ────── */
@media (max-width: 1100px) {
  .tv-sidebar {
    width: 72px;
  }

  .tv-sidebar .tv-sb-link span { display: none; }
  .tv-sidebar .tv-sb-logo img { height: 28px; }
  .tv-sidebar .tv-sb-logo { padding: 20px 16px; }
  .tv-sidebar .tv-sb-link { padding: 14px; justify-content: center; }
  .tv-sidebar .tv-sb-live-dot { position: absolute; top: 8px; right: 8px; }

  html.tv-app-mode .tv-page-wrapper,
  html.tv-app-mode .page-wrapper {
    margin-left: 72px;
  }
}

@media (max-width: 600px) {
  .tv-sidebar { display: none; }
  html.tv-app-mode .tv-page-wrapper,
  html.tv-app-mode .page-wrapper { margin-left: 0; }
  .tv-controls-hint { display: none; }
}
