/* ===========================
   Arab TV - Stylesheet
   Mobile-First RTL Design
   =========================== */

/* --- CSS Variables --- */
:root {
  --bg-primary: #0a1628;
  --bg-secondary: #0f1f35;
  --bg-card: #152238;
  --bg-card-hover: #1c2d48;
  --bg-card-active: #243a5c;
  --bg-surface: #1a2d4a;
  --bg-input: #162236;
  --text-primary: #e8edf4;
  --text-secondary: #8899b0;
  --text-muted: #5a6d85;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --accent-purple: #8b5cf6;
  --border: rgba(255,255,255,0.07);
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --transition: 0.2s ease;
  --font-family: 'Cairo', sans-serif;
  --sidebar-w: 240px;
  --channels-w: 360px;
  --navbar-h: 56px;
  --bottom-nav-h: 56px;
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-card-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* --- Utilities --- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  height: var(--navbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.navbar .logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.navbar .logo img { width: 100%; height: 100%; object-fit: cover; }
.navbar .logo svg { width: 100%; height: 100%; }

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
}
.search-box input {
  width: 100%;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border var(--transition);
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }
.search-box .search-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  margin-right: auto;
}
.nav-tabs a, .nav-tabs button {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-tabs a:hover, .nav-tabs button:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-tabs a.active, .nav-tabs button.active {
  color: var(--accent);
  background: rgba(59,130,246,0.1);
}

/* --- Home Page --- */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem 1rem;
  position: relative;
}
.home-settings {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.5rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  background: transparent;
}
.home-settings:hover { color: var(--text-primary); transform: rotate(45deg); }

.home-cards {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 1200px;
  width: 100%;
}
.home-card {
  position: relative;
  width: 320px;
  height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;
}
.home-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.home-card .card-icon {
  font-size: 3.5rem;
  color: #fff;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}
.home-card .card-icon svg { width: 70px; height: 70px; }
.home-card .card-label {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Card Gradients */
.card-series { background: linear-gradient(135deg, #a855f7, #6366f1, #3b82f6); }
.card-movies { background: linear-gradient(135deg, #f97316, #ef4444, #ec4899); }
.card-live   { background: linear-gradient(135deg, #10b981, #06b6d4, #3b82f6); }

/* --- Live TV Layout --- */
.live-container {
  display: flex;
  height: calc(100vh - var(--navbar-h));
  height: calc(100dvh - var(--navbar-h));
  overflow: hidden;
}

/* Category Sidebar (Right side in RTL) */
.category-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.category-sidebar .sidebar-header {
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.category-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
}
.category-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: auto 44px;
}
.category-item:hover { background: var(--bg-card-hover); }
.category-item.active {
  background: var(--bg-card-active);
  border-right: 3px solid var(--accent);
}
.category-item .cat-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
}
.category-item .cat-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
}
.category-item .cat-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Channel List */
.channel-panel {
  width: var(--channels-w);
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.channel-panel .panel-header {
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.channel-list {
  flex: 1;
  overflow-y: auto;
}
.channel-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  content-visibility: auto;
  contain-intrinsic-size: auto 56px;
}
.channel-item:hover { background: var(--bg-card-hover); }
.channel-item.active {
  background: var(--bg-card-active);
  border-right: 3px solid var(--accent);
}
.channel-item .ch-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.channel-item .ch-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.channel-item .ch-info {
  flex: 1;
  min-width: 0;
}
.channel-item .ch-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-item .ch-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.channel-item .ch-num {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 32px;
  text-align: center;
}

/* Player Area */
.player-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  min-width: 0;
}
.player-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}
.player-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.player-info {
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.player-info .info-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--bg-surface);
  flex-shrink: 0;
}
.player-info .info-logo img { width: 100%; height: 100%; object-fit: contain; }
.player-info .info-text h3 {
  font-size: 1.1rem;
  font-weight: 700;
}
.player-info .info-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
}
.player-controls button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1rem;
  transition: all var(--transition);
  color: var(--text-secondary);
}
.player-controls button:hover { background: var(--bg-card); color: var(--text-primary); }

/* Player Overlay */
.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10,22,40,0.85);
  z-index: 5;
  gap: 1rem;
}
.player-overlay .overlay-icon {
  font-size: 4rem;
  color: var(--text-muted);
}
.player-overlay .overlay-text {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* Loading spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bottom Action Bar (Live TV) */
.bottom-bar {
  display: none;
  align-items: center;
  justify-content: space-around;
  height: var(--bottom-nav-h);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}
.bottom-bar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0.5rem;
  transition: color var(--transition);
}
.bottom-bar button i { font-size: 1.2rem; }
.bottom-bar button.active, .bottom-bar button:hover { color: var(--accent); }

/* --- Movies & Series Pages --- */
.content-page {
  min-height: 100vh;
  min-height: 100dvh;
}
.content-header {
  padding: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}
.content-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}
.genre-filter {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}
.genre-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
  white-space: nowrap;
}
.genre-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.genre-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  padding: 0 1.5rem 2rem;
}
.media-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.media-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.media-card .poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--bg-surface);
}
.media-card .card-body {
  padding: 0.6rem;
}
.media-card .card-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-card .card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}
.media-card .card-rating {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--accent-orange);
}
.media-card .card-year { color: var(--text-muted); }
.media-card .card-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
}
.media-card .play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}
.media-card:hover .play-overlay { opacity: 1; }
.media-card .play-overlay i {
  font-size: 2.5rem;
  color: #fff;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

/* --- Player Page --- */
.player-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: #000;
}
.player-page .main-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  max-height: 70vh;
  background: #000;
}
.player-page .main-player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.player-page .player-bottom {
  flex: 1;
  background: var(--bg-primary);
  overflow-y: auto;
}
.media-details {
  padding: 1.5rem;
}
.media-details h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.media-details .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.media-details .meta-row span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.media-details .overview {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1rem;
}
.media-details .action-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); }

/* Subtitle Display */
.subtitle-overlay {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
  pointer-events: none;
}
.subtitle-text {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 1.1rem;
  border-radius: var(--radius-xs);
  max-width: 80vw;
  line-height: 1.5;
}

/* Episode List */
.episode-section { padding: 0 1.5rem 2rem; }
.episode-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}
.season-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.season-tab {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all var(--transition);
}
.season-tab.active { background: var(--accent); color: #fff; }
.episode-list { display: flex; flex-direction: column; gap: 0.5rem; }
.episode-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
}
.episode-item:hover { background: var(--bg-card-hover); }
.episode-item.active { background: var(--bg-card-active); border: 1px solid var(--accent); }
.episode-item .ep-thumb {
  width: 110px;
  height: 62px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-surface);
}
.episode-item .ep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.episode-item .ep-info { flex: 1; min-width: 0; }
.episode-item .ep-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.episode-item .ep-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Settings Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.modal-backdrop.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem;
  border: 1px solid var(--border);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}
.modal-backdrop.show .modal { transform: translateY(0); }
.modal h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal h2 button {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: color var(--transition);
}
.modal h2 button:hover { color: var(--text-primary); }
.setting-group {
  margin-bottom: 1.25rem;
}
.setting-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.setting-group select,
.setting-group input[type="range"] {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
}
.setting-group select:focus { border-color: var(--accent); }
.setting-group .font-preview {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-xs);
  text-align: center;
  font-size: 1rem;
}
.font-size-display {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* --- Loading & Empty States --- */
.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 1rem;
  color: var(--text-muted);
}
.loading-state .spinner { margin-bottom: 0.5rem; }
.empty-state i { font-size: 3rem; }

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
.toast {
  padding: 0.6rem 1.2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* --- Favorites Badge --- */
.fav-btn {
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: color var(--transition);
}
.fav-btn:hover, .fav-btn.active { color: var(--accent-red); }

/* --- Mobile Bottom Navigation --- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
}
.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 0.4rem;
  transition: color var(--transition);
}
.mobile-nav a i { font-size: 1.15rem; }
.mobile-nav a.active { color: var(--accent); }

/* --- Pagination / Load More --- */
.load-more {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}
.load-more button {
  padding: 0.6rem 2rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 600;
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.load-more button:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* --- Back Button --- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  transition: color var(--transition);
}
.back-btn:hover { color: var(--text-primary); }

/* --- Custom Video Controls --- */
.custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 1rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s;
}
.player-wrapper:hover .custom-controls,
.main-player:hover .custom-controls { opacity: 1; }
.custom-controls button {
  color: #fff;
  font-size: 1.1rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition);
}
.custom-controls button:hover { background: rgba(255,255,255,0.15); }
.progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.progress-bar .progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s;
}
.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  outline: none;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
}
.time-display {
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  min-width: 80px;
  text-align: center;
  direction: ltr;
}

/* --- Mobile Sidebar Drawer --- */
.sidebar-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.sidebar-drawer-overlay.open { opacity: 1; visibility: visible; }
.sidebar-drawer {
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100%;
  background: var(--bg-secondary);
  z-index: 151;
  transition: right 0.3s ease;
  overflow-y: auto;
}
.sidebar-drawer-overlay.open .sidebar-drawer { right: 0; }

/* --- Responsive --- */

/* Tablet */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
    --channels-w: 280px;
  }
  .nav-tabs { display: none; }
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --navbar-h: 50px; }

  .mobile-nav { display: flex; }
  .bottom-bar { display: flex; }

  .content-page { padding-bottom: var(--bottom-nav-h); }

  /* Home */
  .home-cards { flex-direction: column; align-items: center; }
  .home-card { width: 100%; max-width: 360px; height: 160px; }

  /* Live TV */
  .live-container {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--navbar-h) - var(--bottom-nav-h));
    min-height: calc(100dvh - var(--navbar-h) - var(--bottom-nav-h));
  }
  .category-sidebar { display: none; }
  .channel-panel {
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .player-area { width: 100%; min-height: 220px; }
  .player-wrapper { aspect-ratio: 16/9; flex: none; }

  /* Grid */
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    padding: 0 1rem 5rem;
  }
  .content-header { padding: 1rem; }
  .content-header h1 { font-size: 1.2rem; }

  /* Player Page */
  .player-page .main-player { max-height: 40vh; }
  .media-details { padding: 1rem; }

  /* Search */
  .search-box { max-width: none; }
  .navbar { padding: 0 0.75rem; gap: 0.5rem; }
}

/* Small mobile */
@media (max-width: 480px) {
  .media-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    padding: 0 0.75rem 5rem;
  }
  .home-card { height: 140px; }
  .home-card .card-label { font-size: 1.1rem; }
  .home-card .card-icon svg { width: 50px; height: 50px; }
}

/* Large desktop */
@media (min-width: 1400px) {
  :root {
    --sidebar-w: 260px;
    --channels-w: 400px;
  }
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease; }
.slide-up { animation: slideUp 0.4s ease; }

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- Install PWA Banner --- */
.install-banner {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: 90%;
}
.install-banner .install-text { flex: 1; font-size: 0.85rem; }
.install-banner .install-close {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* Subtitle settings dropdown */
.subtitle-menu {
  position: absolute;
  bottom: 50px;
  left: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0;
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}
.subtitle-menu.show { display: block; }
.subtitle-menu .sub-item {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition);
}
.subtitle-menu .sub-item:hover { background: var(--bg-card-hover); }
.subtitle-menu .sub-item.active { color: var(--accent); }

/* Quality selector */
.quality-menu {
  position: absolute;
  bottom: 50px;
  left: 5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0;
  min-width: 150px;
  z-index: 20;
  display: none;
}
.quality-menu.show { display: block; }
.quality-menu .q-item {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition);
}
.quality-menu .q-item:hover { background: var(--bg-card-hover); }
.quality-menu .q-item.active { color: var(--accent); }
