/* TV Page Styles */
:root {
  --tv-primary: #82cfe2;
  --tv-bg: #0a0e13;
  --tv-surface: #1a2332;
  --tv-text: #ffffff;
  --tv-muted: #8899a6;
  --tv-border: #2d3748;
  --tv-radius: 12px;
  --header-height: 60px;
  --controls-height: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: 'Cairo', sans-serif; 
  background: var(--tv-bg); 
  color: var(--tv-text); 
  min-height: 100vh;
  overflow: hidden;
}

.container { max-width: 1400px; margin: 0 auto; padding: 0 1rem; }

/* ============================================
   Fixed Header
   ============================================ */
.tv-header { 
  background: var(--tv-surface); 
  padding: 0.75rem 0; 
  border-bottom: 1px solid var(--tv-border); 
  position: fixed; 
  top: 0; 
  left: 0; 
  right: 0; 
  z-index: 200;
  height: var(--header-height);
}
.tv-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.back-btn { color: var(--tv-primary); text-decoration: none; display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.9rem; }
.header-brand { display: flex; align-items: center; gap: 0.5rem; }
.header-logo { width: 35px; height: 35px; border-radius: 50%; }
.header-brand h1 { font-size: 1.1rem; }
.header-controls { display: flex; gap: 0.5rem; }
.header-controls button { background: var(--tv-border); border: none; color: var(--tv-text); width: 35px; height: 35px; border-radius: 50%; cursor: pointer; transition: all 0.3s; }
.header-controls button:hover { background: var(--tv-primary); color: #000; }

/* ============================================
   Fixed Controls Bar - صف واحد
   ============================================ */
.controls-bar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--tv-surface);
  border-bottom: 1px solid var(--tv-border);
  height: var(--controls-height);
  display: flex;
  align-items: center;
  padding: 0 1rem;
}

/* Main Tabs */
.main-tabs { 
  display: flex; 
  gap: 0.35rem; 
  flex-shrink: 0;
}
.tab-btn { 
  background: transparent; 
  border: 2px solid var(--tv-border); 
  color: var(--tv-muted); 
  padding: 0.4rem 0.9rem; 
  border-radius: 50px; 
  cursor: pointer; 
  font-family: inherit; 
  font-size: 0.85rem; 
  display: flex; 
  align-items: center; 
  gap: 0.4rem; 
  transition: all 0.3s;
  white-space: nowrap;
}
.tab-btn:hover, .tab-btn.active { background: var(--tv-primary); border-color: var(--tv-primary); color: #000; }

/* Search & Filters Row - في نفس الصف */
.search-filters-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  margin-right: 1rem;
  justify-content: flex-end;
}

.search-box { 
  display: flex; 
  align-items: center; 
  background: var(--tv-bg); 
  border: 1px solid var(--tv-border); 
  border-radius: 50px; 
  padding: 0.4rem 0.9rem; 
  gap: 0.5rem;
  width: 220px;
  flex-shrink: 0;
}
.search-box i { color: var(--tv-muted); font-size: 0.85rem; }
.search-box input { flex: 1; background: none; border: none; color: var(--tv-text); font-size: 0.85rem; outline: none; width: 100%; }

/* Filters Group */
.filters-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.filter-select { 
  background: var(--tv-bg); 
  border: 1px solid var(--tv-border); 
  color: var(--tv-text); 
  padding: 0.4rem 0.6rem; 
  border-radius: 8px; 
  font-family: inherit; 
  font-size: 0.8rem;
  cursor: pointer; 
}
.filter-select:focus { border-color: var(--tv-primary); outline: none; }

/* ============================================
   Scrollable Content Area
   ============================================ */
.content-area {
  position: fixed;
  top: calc(var(--header-height) + var(--controls-height));
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 1rem;
}

/* Content Grid */
.tab-content { display: none; max-width: 1400px; margin: 0 auto; }
.tab-content.active { display: block; }
.content-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
  gap: 1.25rem; 
}
.tv-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* Cards */
.media-card { background: var(--tv-surface); border-radius: var(--tv-radius); overflow: hidden; transition: transform 0.3s, box-shadow 0.3s; cursor: pointer; }
.media-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(130,207,226,0.2); }
.media-card-image { position: relative; aspect-ratio: 3/4; overflow: hidden; }
.media-card-image img { width: 100%; height: 100%; object-fit: cover; }


.media-card-badge { position: absolute; top: 10px; right: 10px; background: var(--tv-primary); color: #000; padding: 0.25rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.media-card-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.3s; }
.media-card:hover .media-card-play { opacity: 1; }
.media-card-play i { font-size: 3rem; color: var(--tv-primary); }
.media-card-body { padding: 1rem; }
.media-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.media-card-desc { font-size: 0.8rem; color: var(--tv-muted); margin-bottom: 0.5rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.media-card-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.8rem; color: var(--tv-muted); }
.media-card-meta span { display: flex; align-items: center; gap: 0.25rem; }

/* TV Card Special */
.tv-card .media-card-image { aspect-ratio: 16/9; }
.tv-card .media-card-rating { position: absolute; bottom: 10px; left: 10px; background: rgba(0,0,0,0.8); color: #ffc107; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.8rem; display: flex; align-items: center; gap: 0.25rem; }

/* Empty State */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--tv-muted); }
.empty-state i { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; }

/* Footer */
.tv-footer { text-align: center; padding: 2rem; color: var(--tv-muted); border-top: 1px solid var(--tv-border); margin-top: 2rem; }


/* Modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal.active { display: flex; }
.modal-content { background: var(--tv-surface); border-radius: var(--tv-radius); max-width: 900px; width: 100%; max-height: 90vh; overflow: auto; position: relative; }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: rgba(0,0,0,0.5); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; z-index: 100; font-size: 1.25rem; }

/* Video Modal */
.video-modal-content { max-width: 1000px; }
.video-container { aspect-ratio: 16/9; background: #000; }
.video-container iframe, .video-container video { width: 100%; height: 100%; border: none; }
.video-info { padding: 1.5rem; }
.video-info h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.video-info p { color: var(--tv-muted); }

/* Audio Modal */
.audio-modal-content { max-width: 500px; }
.audio-player { padding: 2rem; text-align: center; }
.audio-player img { width: 200px; height: 200px; border-radius: var(--tv-radius); margin-bottom: 1.5rem; object-fit: cover; }
.audio-player h3 { margin-bottom: 0.5rem; }
.audio-player p { color: var(--tv-muted); margin-bottom: 1rem; }
.audio-player audio { width: 100%; }

/* PDF Modal */
.pdf-modal-content { max-width: 1000px; height: 90vh; }
.pdf-modal-content iframe { width: 100%; height: calc(100% - 60px); border: none; margin-top: 50px; }

/* Responsive */
@media (max-width: 1024px) {
  .tab-btn span { display: none; }
  .tab-btn { padding: 0.5rem; }
  .search-box { width: 180px; }
  .filter-select { font-size: 0.75rem; padding: 0.35rem 0.5rem; }
}

@media (max-width: 768px) {
  :root {
    --controls-height: 100px;
  }
  
  .controls-bar {
    flex-direction: column;
    height: auto;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  
  .main-tabs {
    width: 100%;
    justify-content: center;
  }
  
  .search-filters-row {
    width: 100%;
    margin-right: 0;
    justify-content: center;
  }
  
  .search-box {
    flex: 1;
    width: auto;
    max-width: 200px;
  }
  
  .content-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
  .tv-grid { grid-template-columns: 1fr; }
  .header-brand h1 { display: none; }
}

@media (max-width: 480px) {
  :root {
    --controls-height: 110px;
  }
  
  .search-box { max-width: 150px; }
  .filter-select { font-size: 0.7rem; padding: 0.3rem 0.4rem; }
}


/* Live Badge */
.live-badge { background: #ef4444 !important; animation: pulse-live 1.5s infinite; }
.live-badge i { font-size: 0.5rem; margin-left: 0.25rem; }
@keyframes pulse-live { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.live-card .media-card-image { aspect-ratio: 16/9; }

/* Live Grid - Same as TV Grid */
#live-grid.live-grid,
.live-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  gap: 1.25rem !important;
}

/* Live Grid Responsive - Side by Side */
@media (max-width: 768px) {
  #live-grid.live-grid,
  .live-grid { 
    grid-template-columns: repeat(2, 1fr) !important; 
    gap: 0.75rem !important;
  }
  .live-grid .media-card-title { font-size: 0.85rem; }
  .live-grid .media-card-body { padding: 0.75rem; }
}

@media (max-width: 400px) {
  #live-grid.live-grid,
  .live-grid { 
    grid-template-columns: repeat(2, 1fr) !important; 
    gap: 0.5rem !important;
  }
  .live-grid .media-card-title { font-size: 0.75rem; }
  .live-grid .media-card-body { padding: 0.5rem; }
}


/* Download Button */
.media-card-actions { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.download-btn { background: var(--tv-primary); color: #000; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: calc(50% - 0.25rem); justify-content: center; transition: all 0.3s; }
.download-btn:hover { background: #6bc4d9; transform: translateY(-2px); }
.download-btn i { font-size: 0.9rem; }
.download-btn.watch { background: #2ed573; }
.download-btn.watch:hover { background: #26b85f; }
/* Single button takes full width */
.media-card-actions .download-btn:only-child { min-width: 100%; }


/* ============================================
   Collection Cards (للمجموعات)
   ============================================ */
.collection-card { border: 2px solid var(--tv-primary); }
.collection-card .media-card-badge.collection-badge { background: linear-gradient(135deg, var(--tv-primary), #5ba3b3); }

/* ============================================
   Audio Collection Modal (القرآن والمجموعات)
   ============================================ */
.collection-modal-content {
  max-width: 700px;
  max-height: 90vh;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.collection-modal-title {
  padding: 1.5rem;
  margin: 0;
  border-bottom: 1px solid var(--tv-border);
  color: var(--tv-primary);
  font-size: 1.5rem;
  text-align: center;
}

.collection-info {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--tv-border);
  align-items: flex-start;
}

.collection-info img {
  width: 120px;
  height: 120px;
  border-radius: var(--tv-radius);
  object-fit: cover;
  flex-shrink: 0;
}

.collection-details {
  flex: 1;
}

.collection-details p {
  margin: 0.5rem 0;
  color: var(--tv-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.collection-details p i {
  color: var(--tv-primary);
  width: 20px;
}

/* Album Download Links */
.album-download-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tv-border);
}

.album-download-links .download-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.collection-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  min-height: 350px;
}

.collection-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(130, 207, 226, 0.05);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.3s;
}

.collection-item:hover {
  background: rgba(130, 207, 226, 0.15);
  transform: translateX(-5px);
}

.item-number {
  width: 35px;
  height: 35px;
  background: var(--tv-primary);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.item-info {
  flex: 1;
}

/* Item Actions (multiple buttons) */
.item-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.item-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.item-duration {
  font-size: 0.8rem;
  color: var(--tv-muted);
}

.item-play-btn {
  background: var(--tv-primary);
  color: #000;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.item-play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(130, 207, 226, 0.5);
}

/* ============================================
   TV Collection Modal (المواسم والأجزاء)
   ============================================ */
.tv-collection-modal-content {
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.tv-collection-info {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--tv-border);
  align-items: flex-start;
}

.tv-collection-info img {
  width: 150px;
  height: 100px;
  border-radius: var(--tv-radius);
  object-fit: cover;
  flex-shrink: 0;
}

.tv-collection-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Seasons Tabs */
.seasons-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--tv-border);
  margin-bottom: 1rem;
}

.season-tab {
  background: var(--tv-border);
  border: none;
  color: var(--tv-text);
  padding: 0.6rem 1.25rem;
  border-radius: 25px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.season-tab:hover {
  background: rgba(130, 207, 226, 0.3);
}

.season-tab.active {
  background: var(--tv-primary);
  color: #000;
  font-weight: 600;
}

/* Season Download Links */
.season-download-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(130, 207, 226, 0.1);
  border-radius: 10px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.season-download-label {
  color: var(--tv-primary);
  font-size: 0.9rem;
  font-weight: 500;
}

.season-download-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.season-dl-btn {
  background: var(--tv-border);
  border: none;
  color: var(--tv-text);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.3s;
}

.season-dl-btn:hover {
  background: var(--tv-primary);
  color: #000;
}

/* Episodes List */
.episodes-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.episode-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(130, 207, 226, 0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.episode-item:hover {
  background: rgba(130, 207, 226, 0.15);
  transform: translateX(-5px);
}

.episode-number {
  width: 40px;
  height: 40px;
  background: var(--tv-primary);
  color: #000;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.episode-info {
  flex: 1;
}

.episode-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.episode-duration {
  font-size: 0.8rem;
  color: var(--tv-muted);
}

.episode-play-btn {
  background: var(--tv-primary);
  color: #000;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.episode-play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(130, 207, 226, 0.5);
}

/* Parts List (للأفلام) */
.parts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.part-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: rgba(130, 207, 226, 0.05);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
  border: 1px solid transparent;
}

.part-item:hover {
  background: rgba(130, 207, 226, 0.1);
  border-color: var(--tv-primary);
  transform: translateX(-5px);
}

.part-number {
  background: linear-gradient(135deg, var(--tv-primary), #5ba3b3);
  color: #000;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
}

.part-info {
  flex: 1;
}

.part-title {
  display: block;
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.part-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--tv-muted);
}

.part-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.part-play-btn {
  background: var(--tv-primary);
  color: #000;
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.3s;
}

.part-play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(130, 207, 226, 0.5);
}

/* Responsive for Modals */
@media (max-width: 768px) {
  .collection-info,
  .tv-collection-info {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .collection-info img,
  .tv-collection-info img {
    width: 100px;
    height: 100px;
  }
  
  .seasons-tabs {
    justify-content: center;
  }
  
  .episode-item:hover,
  .collection-item:hover,
  .part-item:hover {
    transform: none;
  }
}


/* ============================================
   Light Theme
   ============================================ */
body.light-theme {
  --tv-bg: #f5f7fa;
  --tv-surface: #ffffff;
  --tv-text: #1a202c;
  --tv-muted: #718096;
  --tv-border: #e2e8f0;
}

body.light-theme .media-card {
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.light-theme .media-card:hover {
  box-shadow: 0 10px 30px rgba(130,207,226,0.3);
}

body.light-theme .collection-item,
body.light-theme .episode-item,
body.light-theme .part-item {
  background: rgba(130, 207, 226, 0.1);
}

body.light-theme .collection-item:hover,
body.light-theme .episode-item:hover,
body.light-theme .part-item:hover {
  background: rgba(130, 207, 226, 0.2);
}


/* ============================================
   Player Controls (Next/Prev)
   ============================================ */
.player-counter {
  background: rgba(130, 207, 226, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  margin: 0.5rem 0;
  display: inline-block;
}

.player-controls {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.player-btn {
  background: var(--tv-border);
  border: none;
  color: var(--tv-text);
  padding: 0.6rem 1rem;
  border-radius: 25px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.3s;
  font-weight: 500;
}

.player-btn:hover:not(.disabled) {
  background: var(--tv-primary);
  color: #000;
  transform: scale(1.05);
}

.player-btn.download {
  background: linear-gradient(135deg, var(--tv-primary), #5ba3b3);
  color: #000;
}

.player-btn.download:hover {
  background: linear-gradient(135deg, #6bc4d9, var(--tv-primary));
  box-shadow: 0 5px 15px rgba(130, 207, 226, 0.4);
}

.player-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Download button in collection items */
.item-download-btn {
  background: var(--tv-border);
  border: none;
  color: var(--tv-text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  margin-left: 0.5rem;
}

.item-download-btn:hover {
  background: var(--tv-primary);
  color: #000;
}

.item-download-btn.watch {
  background: rgba(46, 213, 115, 0.2);
  color: #2ed573;
}

.item-download-btn.watch:hover {
  background: #2ed573;
  color: #000;
}

/* Text buttons for collection items */
.item-link-btn {
  background: var(--tv-border);
  border: none;
  color: var(--tv-text);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.3s;
  font-size: 0.75rem;
  margin-left: 0.3rem;
}

.item-link-btn:hover {
  background: var(--tv-primary);
  color: #000;
}

.item-link-btn.main-play {
  background: var(--tv-primary);
  color: #000;
}

.item-link-btn.main-play:hover {
  background: #9ee0f0;
  box-shadow: 0 0 15px rgba(130, 207, 226, 0.5);
}

.item-link-btn.watch {
  background: rgba(46, 213, 115, 0.2);
  color: #2ed573;
}

.item-link-btn.watch:hover {
  background: #2ed573;
  color: #000;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
}

/* ============================================
   Modal Z-Index Fix
   ============================================ */
.modal {
  z-index: 10000 !important;
}

.modal-content {
  z-index: 10001;
}

/* Video info styling */
.video-info {
  text-align: center;
}

.video-info h3 {
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.video-info p {
  color: var(--tv-muted);
  margin-bottom: 0.5rem;
}

/* Audio player improvements */
.audio-player {
  text-align: center;
}

.audio-artwork-container {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 1rem;
  cursor: pointer;
  border-radius: var(--tv-radius);
  overflow: hidden;
}

.audio-artwork-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.audio-artwork-container:hover img {
  transform: scale(1.05);
}

.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  transition: all 0.3s ease;
}

.play-overlay i {
  font-size: 3rem;
  color: white;
  transition: transform 0.2s ease;
}

.audio-artwork-container:hover .play-overlay {
  background: rgba(0,0,0,0.5);
}

.audio-artwork-container:hover .play-overlay i {
  transform: scale(1.1);
}

.play-overlay.playing {
  background: rgba(0,0,0,0.2);
}

.play-overlay.playing i {
  opacity: 0;
}

.audio-artwork-container:hover .play-overlay.playing i {
  opacity: 1;
}

.audio-player h3 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.audio-player p {
  color: var(--tv-muted);
  margin-bottom: 0.5rem;
}

.audio-player audio {
  display: none;
}

.audio-progress-container {
  margin: 1rem 0;
  padding: 0 1rem;
}

.audio-progress {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--tv-border);
  border-radius: 3px;
  cursor: pointer;
}

.audio-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--tv-primary);
  border-radius: 50%;
  cursor: pointer;
}

.audio-progress::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--tv-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.audio-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--tv-muted);
  margin-top: 0.5rem;
}

/* Fullscreen styles */
.audio-player:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--tv-bg);
  padding: 2rem;
}

.audio-player:fullscreen .audio-artwork-container {
  width: 300px;
  height: 300px;
}

/* Responsive player controls */
@media (max-width: 480px) {
  .player-controls {
    flex-direction: column;
  }
  
  .player-btn {
    width: 100%;
    justify-content: center;
  }
}


/* ============================================
   Custom Scrollbar
   ============================================ */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--tv-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--tv-primary);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #6bc4d9;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--tv-primary) var(--tv-bg);
}

/* Content area scrollbar */
.content-area::-webkit-scrollbar {
  width: 10px;
}

.content-area::-webkit-scrollbar-track {
  background: var(--tv-surface);
  border-radius: 0;
}

.content-area::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--tv-primary), #5ba3b3);
  border-radius: 10px;
  border: 2px solid var(--tv-surface);
}

.content-area::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #6bc4d9, var(--tv-primary));
}

/* Collection modal scrollbar */
.collection-items-list::-webkit-scrollbar,
.tv-collection-content::-webkit-scrollbar {
  width: 6px;
}

.collection-items-list::-webkit-scrollbar-track,
.tv-collection-content::-webkit-scrollbar-track {
  background: rgba(130, 207, 226, 0.1);
  border-radius: 10px;
}

.collection-items-list::-webkit-scrollbar-thumb,
.tv-collection-content::-webkit-scrollbar-thumb {
  background: var(--tv-primary);
  border-radius: 10px;
}

/* Light theme scrollbar */
body.light-theme::-webkit-scrollbar-track,
body.light-theme .content-area::-webkit-scrollbar-track {
  background: #e2e8f0;
}

body.light-theme {
  scrollbar-color: var(--tv-primary) #e2e8f0;
}


/* ============================================
   UNIVERSAL MEDIA PLAYER - Professional Design
   ============================================ */

/* Modal Override */
#media-player-modal {
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
}

.media-player-content {
  max-width: 900px;
  width: 95%;
  max-height: 95vh;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 100px rgba(130, 207, 226, 0.1);
  display: flex;
  flex-direction: column;
}

/* Player Screen */
.media-player-wrapper {
  position: relative;
  background: #000;
  aspect-ratio: 16/9;
  max-height: 50vh;
}

.media-player-screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
}

.media-player-screen video,
.media-player-screen audio {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-player-screen iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Audio Mode - Show artwork */
.media-player-wrapper.audio-mode {
  aspect-ratio: auto;
  max-height: none;
  height: auto;
}

.media-player-wrapper.audio-mode .media-player-screen {
  padding: 2rem;
  min-height: 200px;
}

.audio-artwork {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: rotate-artwork 20s linear infinite paused;
}

.audio-artwork.playing {
  animation-play-state: running;
}

@keyframes rotate-artwork {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Overlay */
.media-player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s;
  cursor: pointer;
  z-index: 50;
}

.media-player-wrapper:hover .media-player-overlay {
  opacity: 1;
}

/* Hide overlay when controls are hidden in fullscreen */
.media-player-wrapper.controls-hidden .media-player-overlay {
  opacity: 0 !important;
  pointer-events: none;
}

/* Show overlay when controls are visible in fullscreen */
.media-player-wrapper:fullscreen.controls-visible .media-player-overlay,
.media-player-wrapper:-webkit-full-screen.controls-visible .media-player-overlay {
  opacity: 1;
}

.overlay-center-btn {
  width: 80px;
  height: 80px;
  background: rgba(130, 207, 226, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #000;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 10px 40px rgba(130, 207, 226, 0.4);
}

.overlay-center-btn:hover {
  transform: scale(1.1);
  background: var(--tv-primary);
}

/* Player Info Section */
.media-player-info {
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(26, 35, 50, 0.8) 0%, rgba(26, 35, 50, 1) 100%);
}

.media-player-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.media-player-thumb {
  position: relative;
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}

.media-player-thumb img {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
}

.media-type-badge {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 24px;
  height: 24px;
  background: var(--tv-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.media-player-details {
  flex: 1;
  min-width: 0;
}

.media-player-details h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-player-details p {
  color: var(--tv-primary);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.media-player-meta {
  font-size: 0.8rem;
  color: var(--tv-muted);
}

/* Progress Bar */
.media-progress-container {
  margin-bottom: 1rem;
}

.media-progress-bar {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  cursor: pointer;
  overflow: visible;
}

.media-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--tv-primary), #5ba3b3);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.media-progress-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: var(--tv-primary);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(130, 207, 226, 0.5);
  opacity: 0;
  transition: opacity 0.2s;
  left: 0%;
}

.media-progress-bar:hover .media-progress-handle {
  opacity: 1;
}

.media-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--tv-muted);
  margin-top: 0.5rem;
}

/* Main Controls */
.media-player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.media-ctrl-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--tv-text);
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s;
  position: relative;
}

.media-ctrl-btn:hover {
  background: rgba(130, 207, 226, 0.3);
  transform: scale(1.1);
}

.media-ctrl-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.media-ctrl-btn.main-play-btn {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--tv-primary), #5ba3b3);
  color: #000;
  font-size: 1.3rem;
  box-shadow: 0 5px 25px rgba(130, 207, 226, 0.4);
}

.media-ctrl-btn.main-play-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 8px 35px rgba(130, 207, 226, 0.6);
}

.media-ctrl-btn span {
  position: absolute;
  font-size: 0.6rem;
  font-weight: 700;
  bottom: 8px;
}

/* Secondary Controls */
.media-player-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

.media-sec-btn {
  background: transparent;
  border: none;
  color: var(--tv-muted);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.media-sec-btn:hover {
  background: rgba(130, 207, 226, 0.2);
  color: var(--tv-primary);
}

.media-sec-btn.active {
  color: var(--tv-primary);
  background: rgba(130, 207, 226, 0.15);
}

/* Volume Control */
.media-volume-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--tv-primary);
  border-radius: 50%;
  cursor: pointer;
}

/* Playlist Info */
.media-playlist-info {
  text-align: center;
  margin-top: 1rem;
}

#playlist-counter {
  background: rgba(130, 207, 226, 0.2);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--tv-primary);
}

/* Speed Menu */
.speed-menu {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tv-surface);
  border-radius: 10px;
  padding: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 100;
}

.speed-menu.active {
  display: block;
}

.speed-option {
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 5px;
  white-space: nowrap;
  font-size: 0.85rem;
}

.speed-option:hover {
  background: rgba(130, 207, 226, 0.2);
}

.speed-option.active {
  color: var(--tv-primary);
  font-weight: 600;
}

/* YouTube/External Embed Mode - Hide all our controls */
.media-player-wrapper.youtube-mode .media-player-overlay {
  display: none;
}

.media-player-wrapper.youtube-mode .media-progress-container {
  display: none;
}

.media-player-wrapper.youtube-mode .fullscreen-controls {
  display: none !important;
}

/* Hide controls for external embeds */
.media-player-controls.hidden {
  display: none !important;
}

/* For embed mode - show only download button */
.media-player-secondary.embed-mode {
  justify-content: center;
}

.media-player-secondary.embed-mode > *:not(#btn-download) {
  display: none !important;
}

.media-player-secondary.embed-mode #btn-download {
  display: flex !important;
}

.media-player-wrapper.youtube-fullscreen {
  cursor: auto !important;
}

/* ============================================
   FULLSCREEN MODE - Auto-hide controls
   ============================================ */
.media-player-wrapper:fullscreen,
.media-player-wrapper:-webkit-full-screen {
  background: #000;
  display: flex;
  flex-direction: column;
  max-height: none;
  aspect-ratio: auto;
}

.media-player-wrapper:fullscreen .media-player-screen,
.media-player-wrapper:-webkit-full-screen .media-player-screen {
  flex: 1;
  max-height: none;
}

.media-player-wrapper:fullscreen video,
.media-player-wrapper:-webkit-full-screen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Fullscreen Controls Container */
.fullscreen-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.9));
  padding: 2rem 1.5rem 1.5rem;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 100;
  display: none;
}

.media-player-wrapper:fullscreen .fullscreen-controls,
.media-player-wrapper:-webkit-full-screen .fullscreen-controls {
  display: block;
}

.media-player-wrapper.controls-visible .fullscreen-controls {
  transform: translateY(0);
}

/* Fullscreen Title */
.fullscreen-title {
  color: #fff;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

/* Fullscreen Progress */
.fullscreen-progress-bar {
  position: relative;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: 1rem;
}

.fullscreen-progress-bar:hover {
  height: 8px;
}

.fullscreen-progress {
  height: 100%;
  background: var(--tv-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.fullscreen-progress-bar:hover .fullscreen-progress-handle {
  opacity: 1;
}

.fullscreen-progress-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: var(--tv-primary);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.2s;
  left: 0%;
}

/* Fullscreen Controls Row */
.fullscreen-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.fullscreen-controls-center {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fullscreen-controls-left,
.fullscreen-controls-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.fullscreen-time {
  color: #fff;
  font-size: 0.85rem;
  min-width: 100px;
}

.fs-ctrl-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}

.fs-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.fs-ctrl-btn.main-btn {
  width: 50px;
  height: 50px;
  background: var(--tv-primary);
  color: #000;
  font-size: 1.2rem;
}

.fs-ctrl-btn.main-btn:hover {
  background: #fff;
  transform: scale(1.15);
}

.fs-ctrl-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Fullscreen Volume */
.fs-volume-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fs-volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  cursor: pointer;
}

.fs-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
}

/* Hide cursor when controls hidden */
.media-player-wrapper:fullscreen.controls-hidden {
  cursor: none;
}

/* Responsive */
@media (max-width: 768px) {
  .media-player-content {
    max-height: 100vh;
    border-radius: 0;
  }
  
  .media-player-wrapper {
    max-height: 40vh;
  }
  
  .media-player-header {
    flex-direction: column;
    text-align: center;
  }
  
  .media-player-controls {
    gap: 0.25rem;
  }
  
  .media-ctrl-btn {
    width: 40px;
    height: 40px;
  }
  
  .media-ctrl-btn.main-play-btn {
    width: 55px;
    height: 55px;
  }
  
  .media-player-secondary {
    gap: 0.5rem;
  }
  
  #volume-slider {
    width: 60px;
  }
  
  .audio-artwork {
    width: 120px;
    height: 120px;
  }
  
  .fullscreen-controls-row {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .fs-volume-control {
    display: none;
  }
}

@media (max-width: 480px) {
  .media-player-info {
    padding: 1rem;
  }
  
  .media-sec-btn span {
    display: none;
  }
  
  .media-volume-control {
    display: none;
  }
}


/* ============================================
   LIVE GRID OVERRIDE - Force Side by Side
   ============================================ */
#live-section #live-grid.content-grid.live-grid,
#live-section .live-grid,
.content-grid.live-grid,
#live-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  gap: 1.25rem !important;
}

@media screen and (max-width: 768px) {
  #live-section #live-grid.content-grid.live-grid,
  #live-section .live-grid,
  .content-grid.live-grid,
  #live-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }
}

@media screen and (max-width: 400px) {
  #live-section #live-grid.content-grid.live-grid,
  #live-section .live-grid,
  .content-grid.live-grid,
  #live-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }
}

/* ============================================
   Collection Header & Search Styles
   ============================================ */
.collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.5rem 1rem;
  flex-wrap: wrap;
}

.collection-modal-title {
  margin: 0;
  font-size: 1.5rem;
  color: var(--tv-text);
  flex: 1;
  min-width: 200px;
}

.collection-search-inline {
  flex: 0 0 auto;
  min-width: 250px;
}

.collection-search-inline .search-box {
  background: var(--tv-bg);
  border: 2px solid var(--tv-border);
  border-radius: 25px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s;
  width: 100%;
}

.collection-search-inline .search-box:focus-within {
  border-color: var(--tv-primary);
  box-shadow: 0 0 0 3px rgba(130, 207, 226, 0.1);
}

.collection-search-inline .search-box i {
  color: var(--tv-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.collection-search-inline .search-box input {
  background: transparent;
  border: none;
  color: var(--tv-text);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
}

.collection-search-inline .search-box input::placeholder {
  color: var(--tv-muted);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .collection-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .collection-modal-title {
    text-align: center;
    margin-bottom: 0.5rem;
  }
  
  .collection-search-inline {
    min-width: auto;
  }
}

/* Collection Items - Hidden state for search */
.collection-item.hidden,
.episode-item.hidden,
.part-item.hidden {
  display: none !important;
}

/* Search highlight */
.search-highlight {
  background: rgba(130, 207, 226, 0.3);
  color: var(--tv-primary);
  font-weight: 600;
  border-radius: 3px;
  padding: 0 2px;
}

/* ============================================
   Frame Modal (PDF/Video Viewer)
   ============================================ */
.frame-modal-content {
  max-width: 95vw;
  width: 95vw;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.frame-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--tv-surface);
  border-bottom: 1px solid var(--tv-border);
}

.frame-header h2 {
  font-size: 1.1rem;
  margin: 0;
}

.frame-modal-content .modal-close {
  position: static;
  flex-shrink: 0;
}

#content-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #000;
}

/* ============================================
   Link Dropdown (for books)
   ============================================ */
.link-dropdown {
  position: relative;
  display: inline-block;
}

.link-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: 8px;
  min-width: 150px;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.3);
  z-index: 100;
  margin-bottom: 5px;
}

.link-dropdown.open .dropdown-menu {
  display: block;
}

.link-dropdown .dropdown-menu button {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  color: var(--tv-text);
  text-align: right;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.link-dropdown .dropdown-menu button:hover {
  background: rgba(130, 207, 226, 0.15);
}

.link-dropdown .dropdown-menu button:first-child {
  border-radius: 8px 8px 0 0;
}

.link-dropdown .dropdown-menu button:last-child {
  border-radius: 0 0 8px 8px;
}

/* ============================================
   Episode/Part Links (with text)
   ============================================ */
.ep-link-btn {
  background: var(--tv-border);
  border: none;
  color: var(--tv-text);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.ep-link-btn:hover {
  background: var(--tv-primary);
  color: #000;
}

.ep-link-btn.main-play {
  background: var(--tv-primary);
  color: #000;
}

.ep-link-btn.main-play:hover {
  background: #9ee0f0;
  box-shadow: 0 0 15px rgba(130, 207, 226, 0.5);
}

.ep-link-btn.watch {
  background: rgba(46, 213, 115, 0.2);
  color: #2ed573;
}

.ep-link-btn.watch:hover {
  background: #2ed573;
  color: #000;
}

/* ============================================
   Content Links (in TV modal header)
   ============================================ */
.content-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tv-border);
}

.content-links .download-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.content-links .download-btn i {
  font-size: 0.75rem;
}

/* Links rows (watch/download separation) */
.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.links-row.watch-row {
  margin-bottom: 0.3rem;
}

/* Episode/Part links container */
.episode-links,
.part-links {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Close dropdown when clicking outside */
@media (max-width: 768px) {
  .frame-modal-content {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .episode-links,
  .part-links {
    flex-direction: column;
  }
  
  .ep-link-btn {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
  }
}

/* ============================================
   Single Movie Play Button
   ============================================ */
.single-movie-play {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.play-movie-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, var(--tv-primary), #5ba3b5);
  color: #000;
  border: none;
  padding: 1rem 2.5rem;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(130, 207, 226, 0.4);
}

.play-movie-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 30px rgba(130, 207, 226, 0.6);
}

.play-movie-btn i {
  font-size: 1.5rem;
}

/* ============================================
   Book Modal
   ============================================ */
.book-modal-content {
  max-width: 600px;
  padding: 1.5rem;
}

.book-modal-title {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--tv-border);
}

.book-modal-info {
  display: flex;
  gap: 1.5rem;
}

.book-modal-info img {
  width: 150px;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.book-details {
  flex: 1;
}

.book-details p {
  margin: 0.5rem 0;
  color: var(--tv-muted);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.book-details p i {
  color: var(--tv-primary);
  width: 18px;
  margin-top: 3px;
}

.book-details strong {
  color: var(--tv-text);
  margin-left: 0.3rem;
}

.book-description {
  margin-top: 1rem !important;
  padding-top: 0.5rem;
  border-top: 1px solid var(--tv-border);
  line-height: 1.6;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tv-border);
}

@media (max-width: 500px) {
  .book-modal-info {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .book-modal-info img {
    width: 120px;
  }
  
  .book-details p {
    justify-content: center;
  }
  
  .book-actions {
    justify-content: center;
  }
}


/* ============================================
   Mobile Improvements for Collection Player
   ============================================ */

/* تحسين عرض قائمة السور/العناصر على الموبايل */
@media (max-width: 768px) {
  /* تكبير منطقة قائمة العناصر */
  .collection-modal-content {
    max-height: 95vh;
    height: 95vh;
  }
  
  .collection-items-list {
    flex: 1;
    min-height: 40vh;
    max-height: none;
    padding: 0.75rem;
  }
  
  /* تكبير عناصر القائمة */
  .collection-item {
    padding: 0.85rem;
    gap: 0.75rem;
  }
  
  .item-number {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  
  .item-title {
    font-size: 0.95rem;
  }
  
  .item-duration {
    font-size: 0.75rem;
  }
  
  .item-play-btn {
    width: 36px;
    height: 36px;
  }
  
  /* تصغير معلومات المجموعة لإعطاء مساحة أكبر للقائمة */
  .collection-info {
    padding: 1rem;
    gap: 1rem;
  }
  
  .collection-info img {
    width: 80px;
    height: 80px;
  }
  
  .collection-info h2 {
    font-size: 1.1rem;
  }
  
  /* تحسين أزرار العناصر */
  .item-actions {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  
  .item-link-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
  
  .item-link-btn.main-play {
    padding: 0.5rem 0.8rem;
  }
}

/* شاشات أصغر */
@media (max-width: 480px) {
  .collection-items-list {
    min-height: 50vh;
    padding: 0.5rem;
  }
  
  .collection-item {
    padding: 0.75rem;
    gap: 0.5rem;
  }
  
  .item-number {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }
  
  .item-info {
    min-width: 0;
  }
  
  .item-title {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* إخفاء بعض الأزرار الثانوية على الشاشات الصغيرة */
  .item-actions .item-link-btn:not(.main-play) {
    display: none;
  }
  
  .item-play-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
}

/* ============================================
   تحسين Frame Modal للكتب على الموبايل
   ============================================ */
@media (max-width: 768px) {
  .frame-modal-content {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .frame-header {
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  .frame-header h2 {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
  }
  
  #content-frame {
    height: calc(100vh - 60px);
  }
}
