/* --- EPISODE CARD STYLES --- */
.episodes-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}
.episode-card {
  background: linear-gradient(120deg, #23272f 60%, #181c22 100%);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  padding: 14px 18px 12px 18px;
  min-width: 180px;
  max-width: 240px;
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.18s, box-shadow 0.18s, border 0.18s, transform 0.18s;
}
.episode-card:hover, .episode-card:focus {
  background: linear-gradient(120deg, #23272f 80%, #23272f 100%);
  box-shadow: 0 6px 24px rgba(241,196,15,0.10);
  border: 1.5px solid var(--accent);
  transform: translateY(-2px) scale(1.01);
  outline: none;
}
.episode-title {
  font-size: 1.08em;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
  letter-spacing: 0.01em;
}
.episode-meta {
  font-size: 0.98em;
  color: #bfc7cf;
  margin-bottom: 2px;
}
.episode-overview {
  font-size: 0.95em;
  color: #bfc7cf;
  opacity: 0.92;
  margin-bottom: 0;
  line-height: 1.4;
  max-height: 3.2em;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* --- END EPISODE CARD STYLES --- */
/* Overlay for search focus mode */
#searchOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18,22,28,0.48);
  z-index: 10999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(.4,0,.2,1);
}
#searchOverlay.visible {
  opacity: 1;
  pointer-events: auto;
}
:root{
  --bg: #0f1113;
  --panel: #16181a;
  --muted: #bfc7cf;
  --accent: #f1c40f;
  --accent-2: #ffb86b;
  --glass: rgba(255,255,255,0.04);
  --radius: 10px;
  --elev-1: 0 6px 18px rgba(0,0,0,0.6);
  --focus: 0 0 0 4px rgba(241,196,15,0.14);
}

/* General Body */
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: linear-gradient(180deg, #081017 0%, #0f1113 60%);
  color: #e6eef6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Sidebar and Main content */
#sidebar {
  width: 260px;
  background: linear-gradient(180deg, #181c22 0%, #101216 100%);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  padding: 28px 18px 18px 18px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  z-index: 106;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28), 2px 0 0 0 #23272f;
  border-right: 1.5px solid rgba(255,255,255,0.04);
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  transition: transform 0.28s cubic-bezier(.2,.9,.2,1), box-shadow 0.2s;
}

body.sidebar-closed #sidebar {
  transform: translateX(-100%);
}

body.sidebar-open #sidebar {
  transform: translateX(0);
}

#sidebar-content {
  padding: 20px 10px;
  overflow-y: auto;
  flex-grow: 1;
}

#bottom-nav {
  padding: 10px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
}

#main {
  margin-left: 0;
  padding-top: 100px;
  padding-left: 20px;
  padding-right: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: 100vh;
  box-sizing: border-box;
  transition: margin-left 0.28s cubic-bezier(.2,.9,.2,1);
}

body.sidebar-open #main {
  margin-left: 220px;
}

/* Top Bar and Elements */
#topbar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 105;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px 14px 24px;
  height: 84px;
  background: linear-gradient(90deg, #181c22 0%, #23272f 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  border-bottom: 1.5px solid rgba(255,255,255,0.04);
  backdrop-filter: blur(8px) saturate(1.08);
}

.top-left-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-shrink: 0;
}

.brand {
  margin-bottom: 5px;
}

.brand-logo {
  max-width: 120px;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.12));
}

#menu-button {
  background: none;
  border: none;
  color: #f1c40f;
  font-size: 28px;
  cursor: pointer;
  z-index: 1001;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.16s, color 0.16s;
}
#menu-button:hover, #menu-button:focus {
  background: rgba(241,196,15,0.08);
  color: #fff;
  outline: none;
}

#top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

#scrollable-top-content {
  display: -webkit-box;
  flex-grow: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tab-container, .search-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  align-items: center;
}

/* New Overlay Style */
#overlay-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 105;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

#overlay-bg.visible {
    opacity: 1;
    pointer-events: auto;
}

/* General Styles (from your original code) */
#profileArea {
  margin-bottom: 30px;
}
#profileBtn {
  font-size: 18px;
}
.nav-item {
  font-size: 18px;
  display: block;
  padding: 12px 18px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.01), rgba(0,0,0,0.08));
  border: none;
  color: #bfc7cf;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  letter-spacing: 0.01em;
  font-weight: 500;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.nav-item.active, .nav-item:focus {
  background: linear-gradient(90deg, #23272f 0%, #181c22 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(241,196,15,0.08);
  outline: none;
}
.nav-item.active {
  border-left: 4px solid var(--accent);
  padding-left: 14px;
}
.nav-item:hover:not(.active) {
  background: linear-gradient(90deg, #23272f 0%, #181c22 100%);
  color: #fff;
}
.tab-container::-webkit-scrollbar {
  display: none;
}
.tab {
  font-size: 16px;
  background-color: transparent;
  border: none;
  color: #ccc;
  padding: 8px 15px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease-in-out;
  flex-shrink: 0;
  white-space: nowrap;
}
.tab.active {
  border-bottom: 2px solid #f1c40f;
  color: #fff;
}
.tab:focus {
  outline: none;
  border-bottom: 2px solid #fff;
  color: #fff;
}
.search-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 6px 10px;
  gap:4px;
}
.search-icon svg {
  width: 20px;
  height: 20px;
}
.search-icon span {
  font-size: 12px;
}

/* Search input hidden by default; toggle .visible to show */
/* Search input hidden by default; toggle .visible to show */
#searchInput[aria-hidden="true"] {
  visibility: hidden;
}
#searchInput {
  /* Center the search input in the viewport */
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -54%);
  width: 58%;
  max-width: 920px;
  min-width: 260px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.06);
  /* Use solid, non-transparent background for better readability */
  background: var(--panel);
  color: #fff; /* ensure high contrast */
  font-size: 16px;
  z-index: 11000; /* above topbar/sidebar */
  box-shadow: var(--elev-1);
  transition: opacity 0.22s ease, transform 0.22s ease;
  opacity: 0;
  pointer-events: none;
  /* for pop effect */
  transform: translate(-50%, -54%) scale(0.98);
}

/* Visible state */
#searchInput.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.03);
  pointer-events: auto;
  visibility: visible;
}

/* Small screens: make it nearly full width and slightly higher on screen */
@media (max-width: 700px) {
  #searchInput {
    width: calc(100% - 40px);
    left: 50%;
    top: 40%;
    transform: translate(-50%, -40%);
    font-size: 15px;
    min-width: 0;
  }
}
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 18px;
  flex-grow: 1;
  overflow-y: auto;
  align-items: start;
  padding-top: 10px;
  grid-row-gap: 18px;
}

.grid-item {
  position: relative;
  text-align: center;
  color: #fff;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  box-shadow: 0 6px 20px rgba(2,6,23,0.6);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
  background-color: rgba(255,255,255,0.02);
  aspect-ratio: 16/9;
}

/* Card used by JS-generated items */
.card {
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.18));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card .title {
  font-size: 12px;
  padding: 10px 12px;
  text-align: center;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(0,0,0,0.0), rgba(0,0,0,0.6));
  color: var(--muted);
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}
.card:focus, .card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 18px 40px rgba(2,6,23,0.6);
  z-index: 6;
}
.grid-item.focusable:focus {
  outline: 4px solid #f1c40f;
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
  z-index: 5;
}
.card img, .channel-logo-small {
  width: 80%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  max-height: 100%;
}
.card .title, .channel-card .title {
  font-size: 10px;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
}
.card .category {
  font-size: 14px;
  color: #bbb;
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 5px 8px;
  border-radius: 5px;
}
.channel-card {
  position: relative;
  text-align: center;
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  aspect-ratio: 16/9;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  background-color: rgba(30, 30, 30, 0.8);
  padding: 5px;
}
.pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  cursor: pointer;
  background: linear-gradient(90deg, rgba(255,255,255,0.02), rgba(0,0,0,0.2));
  color: var(--muted);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.pill:focus, .pill:hover { transform: translateY(-2px); box-shadow: var(--focus); color: #fff; }
.pill:focus {
  outline: 2px solid #fff;
}
.hidden { display: none !important; }


.video-js {
  width: 100% !important; /* Ensures it overrides any inline styles */
  height: auto !important; /* Maintains aspect ratio */
}


#closeButton {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 2; /* Ensures it's on top of the video */
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
    padding: 10px 15px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: opacity 0.3s;
}

.channel-info {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 2;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 5px;
    transition: opacity 0.3s;
}

.channel-info h2 {
    margin: 0;
    font-size: 24px;
}

.channel-number {
    font-size: 14px;
    color: #ccc;
}

#livePlayerOverlay {
  position: fixed; /* Essential for z-index to work */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000; /* Set a very high value to ensure it's on top */
  background-color: black;
}







/* --- Modal Container --- */
.modal {
  position: fixed;
  top: 60px;
  left: 0;
  width: 100vw;
  height: calc(100vh - 60px);
  background: rgba(18,22,28,0.82);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  z-index: 1000 !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(.4,0,.2,1);
}

.modal.hidden {
    display: none;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
  display: flex;
  flex-direction: row;
  background: linear-gradient(120deg, rgba(30,34,40,0.98) 60%, rgba(24,28,34,0.98) 100%);
  border-radius: 22px;
  box-shadow: 0 12px 48px 0 rgba(0,0,0,0.55), 0 1.5px 0 0 var(--accent);
  color: #f5f5f5;
  width: 92vw;
  max-width: 900px;
  max-height: 88vh;
  position: relative;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* --- Modal Sections (Left/Right) --- */
.modal-left {
    flex-shrink: 0;
    width: 25%;
    max-height: 100%;
}


.modal-right {
}

/* --- The fixed details section (implicitly handled by Flexbox) --- */

/* --- The scrollable torrent list container --- */
#torrentList {
    flex-grow: 1; /* Makes it fill all available vertical space */
    overflow-y: auto; /* **This is the key fix.** It makes only this section scrollable. */
}

/* --- Modal Poster and Title --- */
.modal-poster {
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.38);
  display: block;
  width: 100%;
  max-width: 200px;
  max-height: 340px;
  object-fit: cover;
}

.modal-title {
  font-size: 2.1em;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

/* --- Metadata and Overview --- */
.modal-meta, .modal-overview {
  font-size: 1em;
  line-height: 1.6;
  color: #bfc7cf;
  margin-bottom: 18px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

#seasonsAndEpisodesList {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex-shrink: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
}

.torrent-list {
  font-size: 1em;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
  position: relative;
}

  .torrent-item {
    background: linear-gradient(90deg, #23272f 0%, #181c22 100%);
    padding: 14px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.18s, box-shadow 0.18s, transform 0.18s, border 0.18s;
    cursor: pointer;
    border: 1.5px solid transparent;
    outline: none;
  }

.torrent-item:hover,
.torrent-item:focus {
  background: linear-gradient(90deg, #23272f 0%, #23272f 100%);
  box-shadow: 0 6px 24px rgba(241,196,15,0.10);
  border: 1.5px solid var(--accent);
  transform: translateY(-2px) scale(1.012);
}

.torrent-item h4 {
  margin: 0 0 4px 0;
  color: #fff;
  font-size: 1.08em;
  font-weight: 600;
  letter-spacing: 0.01em;
  word-break: break-word;
  white-space: normal;
}

.torrent-metadata {
  display: flex;
  gap: 7px;
  font-size: 0.97em;
  color: #bfc7cf;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0;
}

.torrent-metadata span {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #23272f;
  color: #bfc7cf;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.97em;
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
  opacity: 0.97;
}
.torrent-metadata span[style*='background: #1e8c3a'] {
  background: #1e8c3a !important;
  color: #fff !important;
}
.torrent-metadata span[style*='background: #c0392b'] {
  background: #c0392b !important;
  color: #fff !important;
}

.torrent-item .torrent-name {
  font-size: 1.08em;
  font-weight: 600;
  color: #fff;
  word-break: break-word;
  white-space: normal;
  line-height: 1.3;
  margin-bottom: 2px;
}

.torrent-item .torrent-extra-info {
  font-size: 0.93em;
  color: #bfc7cf;
  opacity: 0.85;
  margin-top: 2px;
  margin-bottom: 0;
  line-height: 1.2;
}

.loading-torrents {
  text-align: center;
  font-size: 1.1em;
  color: #bfc7cf;
  margin-top: 40px;
  font-weight: 500;
}

/* --- Close Button --- */
#closeButton {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  transition: background-color 0.12s, transform 0.12s;
  z-index: 2;
}
#closeButton:hover { transform: scale(1.05); background: rgba(255,255,255,0.06); }

#closeButton:hover {
    background: rgba(255, 255, 255, 0.3);
}



/* --- SEASONS AND EPISODES STYLES --- */
.seasons-container {
  display: flex;
  overflow-x: auto;
  padding: 10px 0;
  -webkit-overflow-scrolling: touch; /* for smooth scrolling on iOS */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.seasons-container::-webkit-scrollbar {
  display: none;
}

.season-item {
  position: relative;
  width: 120px;
  height: 180px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
  background: linear-gradient(180deg, #23272f 0%, #181c22 100%);
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
  cursor: pointer;
  outline: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.season-item:hover, .season-item:focus {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 8px 32px rgba(241,196,15,0.12);
  background: linear-gradient(180deg, #23272f 0%, #23272f 100%);
}

.spinner {
  border: 4px solid rgba(255,255,255,0.3);
  border-top: 4px solid #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  position: fixed;
  top: 50%;
  left: 50%;
  margin-top: -20px;
  margin-left: -20px;
  z-index: 9999;
}


@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}





/* --- PAGINATION STYLES --- */
#pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
  margin-top: 20px;
  width: 100%;
}

#pagination-container.hidden {
  display: none;
}

.page-btn {
  background-color: #f1c40f;
  color: #1b1b1b;
  border: none;
  padding: 10px 20px;
  font-size: 20px;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.page-btn:hover {
  background-color: #e6b800;
}

.page-btn:focus {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.page-btn.disabled {
  background-color: #333;
  color: #777;
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

#page-indicator {
  font-size: 20px;
  color: #fff;
  min-width: 100px;
  text-align: center;
}