/* ══════════════════════════════════════════════════════════
   CineFlow — Premium Dark Streaming UI
   ══════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --bg-deep: #06060e;
  --bg-base: #0a0a14;
  --bg-surface: #12121e;
  --bg-card: #16162a;
  --bg-elevated: #1c1c36;
  --glass: rgba(20, 20, 40, 0.6);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-hover: rgba(255, 255, 255, 0.08);

  --accent: #7c5cfc;
  --accent-light: #9b82ff;
  --accent-dim: rgba(124, 92, 252, 0.12);
  --accent-glow: rgba(124, 92, 252, 0.3);

  --red: #ff4757;
  --red-dim: rgba(255, 71, 87, 0.12);
  --green: #2ed573;
  --green-dim: rgba(46, 213, 115, 0.12);
  --gold: #ffa502;
  --gold-dim: rgba(255, 165, 2, 0.12);

  --text-primary: #eef0f6;
  --text-secondary: #8b8fa3;
  --text-muted: #555770;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  --topbar-h: 60px;
  --bnav-h: 64px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; max-width: 100%; }
input { font-family: var(--font); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 3px; }

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(6,6,14,0.95) 0%, rgba(6,6,14,0.7) 100%);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  transition: background var(--transition);
}
.topbar.scrolled { background: rgba(6,6,14,0.98); }
.topbar-left { display: flex; align-items: center; }
.nav-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 800; letter-spacing: -0.5px;
}
.logo-icon { font-size: 24px; color: var(--accent); }
.logo-text {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--text-secondary);
  transition: all var(--transition);
}
.nav-link:hover { color: var(--text-primary); background: var(--glass-hover); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  position: relative;
}

/* ── User Avatar & Dropdown ─────────────────────────────── */
.user-menu-wrap { position: relative; }
.user-avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  border: 2px solid var(--glass-border);
  box-shadow: 0 0 12px var(--accent-dim);
  transition: transform var(--transition), box-shadow var(--transition);
}
.user-avatar-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px var(--accent-glow);
}
.user-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 200px; padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  backdrop-filter: blur(20px);
  display: flex; flex-direction: column; gap: 4px;
  z-index: 200;
  animation: dropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.user-dropdown-header { padding: 8px 12px; }
.user-dropdown-name { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.user-dropdown-sub { font-size: 11px; color: var(--text-muted); }
.user-dropdown-divider { height: 1px; background: var(--glass-border); margin: 4px 0; }
.user-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  transition: all var(--transition);
  width: 100%; text-align: left;
}
.user-dropdown-item:hover {
  background: var(--glass-hover); color: var(--text-primary);
}
.user-dropdown-item.danger:hover {
  background: var(--red-dim); color: var(--red);
}
.search-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: background var(--transition);
}
.search-toggle:hover { background: var(--glass-hover); }
.search-input {
  width: 0; opacity: 0; padding: 0;
  border: none; outline: none;
  background: var(--bg-surface); color: var(--text-primary);
  border-radius: var(--radius-sm); font-size: 14px;
  transition: all 0.3s ease;
}
.search-wrap.open .search-input {
  width: 260px; opacity: 1; padding: 10px 14px;
  border: 1px solid var(--glass-border);
}
.search-wrap.open .search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.search-close { font-size: 16px; color: var(--text-muted); padding: 4px; }

/* ── Mobile Bottom Nav ─────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bnav-h);
  display: none; /* Hidden on desktop */
  align-items: center; justify-content: space-around;
  background: rgba(6,6,14,0.95);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bnav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  transition: all var(--transition); min-width: 56px;
}
.bnav-item.active { color: var(--accent); }
.bnav-icon { font-size: 20px; }

/* ── Main Content ──────────────────────────────────────── */
.main-content {
  min-height: 100dvh;
  padding-top: var(--topbar-h);
  padding-bottom: 20px;
}

/* ── Hero Banner ───────────────────────────────────────── */
.hero {
  position: relative; width: 100%; min-height: 520px;
  display: flex; align-items: flex-end;
  overflow: hidden; margin-bottom: 32px;
}
.hero-backdrop {
  position: absolute; inset: 0;
  background-size: cover; background-position: center top;
}
.hero-backdrop::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(0deg, var(--bg-deep) 0%, transparent 40%, rgba(6,6,14,0.3) 100%);
}
.hero-content {
  position: relative; z-index: 2;
  padding: 40px 5%; max-width: 600px;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  background: var(--accent-dim); border: 1px solid var(--accent-glow);
  font-size: 11px; font-weight: 700; color: var(--accent-light);
  margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.hero-title {
  font-family: var(--font-display);
  font-size: 42px; font-weight: 900; line-height: 1.05;
  margin-bottom: 12px; letter-spacing: -1.5px;
}
.hero-overview {
  font-size: 15px; color: var(--text-secondary); line-height: 1.6;
  margin-bottom: 20px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px; font-size: 13px; color: var(--text-secondary);
}
.hero-meta .rating { color: var(--gold); font-weight: 700; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; transition: all var(--transition);
  cursor: pointer;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--accent-glow); }
.btn-glass {
  background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}
.btn-glass:hover { background: var(--glass-hover); border-color: rgba(255,255,255,0.12); }
.btn-icon {
  width: 44px; height: 44px; padding: 0; justify-content: center;
  border-radius: 50%; font-size: 18px;
}
.btn-sm { padding: 8px 14px; font-size: 12px; }

/* ── Content Carousel ──────────────────────────────────── */
.carousel-section { margin-bottom: 32px; padding: 0 5%; }
.carousel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.carousel-title { font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.carousel-more {
  font-size: 13px; font-weight: 600; color: var(--accent);
  padding: 6px 12px; border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.carousel-more:hover { background: var(--accent-dim); }
.carousel-row {
  display: flex; gap: 14px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -ms-overflow-style: none;
  padding-bottom: 4px;
}
.carousel-row::-webkit-scrollbar { display: none; }

/* ── Media Card (Poster) ──────────────────────────────── */
.media-card {
  flex: 0 0 auto; width: 160px;
  scroll-snap-align: start; cursor: pointer;
  transition: transform var(--transition);
}
.media-card:hover { transform: scale(1.04); }
.media-card:active { transform: scale(0.98); }
.card-poster {
  width: 100%; aspect-ratio: 2/3; border-radius: var(--radius-md);
  background: var(--bg-surface); overflow: hidden; position: relative;
}
.card-poster img {
  width: 100%; height: 100%; object-fit: cover;
  transition: opacity 0.3s;
}
.card-poster img[src=""] { opacity: 0; }
.card-rating {
  position: absolute; top: 8px; right: 8px;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  font-size: 11px; font-weight: 700; color: var(--gold);
}
.card-type {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 7px; border-radius: 6px;
  background: var(--accent); font-size: 10px; font-weight: 700;
  color: #fff; text-transform: uppercase;
}
.card-title {
  margin-top: 8px; font-size: 13px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.3;
}
.card-year { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-no-poster {
  position: absolute; inset: 0;
  background: linear-gradient(145deg, var(--bg-elevated) 0%, var(--bg-deep) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 14px; text-align: center; border-radius: var(--radius-md);
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  line-height: 1.3;
}

/* ── Detail Page ───────────────────────────────────────── */
.detail-page { position: relative; }
.detail-backdrop {
  width: 100%; height: 400px; position: relative; overflow: hidden;
}
.detail-backdrop img { width: 100%; height: 100%; object-fit: cover; }
.detail-backdrop::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(0deg, var(--bg-deep) 0%, transparent 50%);
}
.detail-body { padding: 0 5%; margin-top: -80px; position: relative; z-index: 2; }
.detail-header { display: flex; gap: 24px; margin-bottom: 24px; }
.detail-poster {
  width: 180px; flex-shrink: 0; border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.detail-poster img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.detail-info { flex: 1; padding-top: 20px; }
.detail-title { font-family: var(--font-display); font-size: 32px; font-weight: 900; line-height: 1.1; margin-bottom: 10px; letter-spacing: -0.5px; }
.detail-meta {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  font-size: 14px; color: var(--text-secondary); margin-bottom: 16px;
}
.detail-meta .star { color: var(--gold); }
.detail-genres { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.genre-tag {
  padding: 5px 12px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--glass-border);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.detail-overview {
  font-size: 15px; line-height: 1.7; color: var(--text-secondary); margin-bottom: 32px;
  max-width: 700px;
}

/* ── Centered Quality Accordion (Sources) ──────────────── */
.sources-accordion-section {
  max-width: 740px; margin: 0 auto 36px; width: 100%;
}
.sources-header-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding: 0 4px;
}
.sources-title-wrap {
  display: flex; align-items: center; gap: 10px;
}
.sources-title-icon {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--accent-dim); color: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
}
.sources-title { font-size: 18px; font-weight: 800; }
.sources-total-badge {
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  background: var(--bg-surface); padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--glass-border);
}

.accordion-group {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.accordion-group:hover {
  border-color: rgba(255,255,255,0.15);
}
.accordion-group.open {
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--accent-dim);
}

.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; cursor: pointer;
  background: transparent;
  transition: background var(--transition);
  user-select: none;
}
.accordion-header:hover { background: var(--bg-elevated); }
.accordion-header-left {
  display: flex; align-items: center; gap: 12px;
}
.accordion-quality-badge {
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 800;
  min-width: 58px; text-align: center; letter-spacing: 0.3px;
}
.accordion-quality-badge.q-4k {
  background: linear-gradient(135deg, rgba(255, 165, 2, 0.2), rgba(255, 71, 87, 0.2));
  color: var(--gold); border: 1px solid rgba(255, 165, 2, 0.3);
}
.accordion-quality-badge.q-1080p {
  background: var(--green-dim); color: var(--green);
  border: 1px solid rgba(46, 213, 115, 0.3);
}
.accordion-quality-badge.q-720p {
  background: var(--accent-dim); color: var(--accent-light);
  border: 1px solid rgba(124, 92, 252, 0.3);
}
.accordion-quality-badge.q-other {
  background: var(--glass); color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}

.accordion-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.accordion-count { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.accordion-toggle-icon {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), color var(--transition);
}
.accordion-group.open .accordion-toggle-icon {
  transform: rotate(180deg); color: var(--accent-light);
}

.accordion-body {
  display: none; padding: 0 16px 16px;
  animation: fadeIn 0.2s ease;
}
.accordion-group.open .accordion-body { display: flex; flex-direction: column; gap: 8px; }

.source-card {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--glass-border);
  cursor: pointer; transition: all var(--transition);
}
.source-card:hover {
  border-color: var(--accent); background: var(--bg-elevated);
  transform: translateY(-1px);
}
.source-info { flex: 1; min-width: 0; }
.source-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.source-meta {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.source-meta-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-muted); }
.source-seeders-wrap {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--green);
  flex-shrink: 0;
}

/* ── Season/Episode Picker ─────────────────────────────── */
.season-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.season-tab {
  padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--bg-surface); border: 1px solid var(--glass-border);
  font-size: 13px; font-weight: 700; transition: all var(--transition);
}
.season-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.episode-list { display: flex; flex-direction: column; gap: 8px; }
.episode-card {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--bg-surface); border: 1px solid var(--glass-border);
  cursor: pointer; transition: all var(--transition);
}
.episode-card:hover { border-color: var(--accent); background: var(--accent-dim); }
.episode-num {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--glass); display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; flex-shrink: 0;
}
.episode-info { flex: 1; }
.episode-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.episode-overview {
  font-size: 12px; color: var(--text-muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Player Page & Controls ────────────────────────────── */
.player-page {
  position: fixed; inset: 0; z-index: 999;
  background: #000; display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none;
}
.player-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.player-topbar.hide { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.player-topbar-left { display: flex; align-items: center; gap: 14px; }
.player-back {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; background: rgba(255,255,255,0.1);
  transition: all var(--transition);
}
.player-back:hover { background: rgba(255,255,255,0.25); transform: scale(1.08); }
.player-title-info { display: flex; flex-direction: column; }
.player-now-title { font-size: 16px; font-weight: 700; color: #fff; line-height: 1.2; }
.player-now-sub { font-size: 13px; color: var(--text-secondary); }
.player-topbar-right { display: flex; align-items: center; gap: 10px; }

.player-video-wrap {
  position: relative; flex: 1; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #000; overflow: hidden;
}
.player-video-wrap video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}

/* Arabic Subtitle Cues — transparent bg with heavy text-shadow for legibility */
video::cue {
  font-family: 'Noto Sans Arabic', 'Inter', sans-serif;
  font-weight: 700;
  color: #ffffff;
  background-color: transparent !important;
  background: transparent !important;
  font-size: clamp(18px, 2.8vw, 28px);
  line-height: 1.6;
  direction: rtl;
  unicode-bidi: isolate;
  text-shadow:
    0 0 4px rgba(0,0,0,1),
    0 1px 6px rgba(0,0,0,0.95),
    0 2px 12px rgba(0,0,0,0.9),
    -1px -1px 0 rgba(0,0,0,0.95),
    1px -1px 0 rgba(0,0,0,0.95),
    -1px 1px 0 rgba(0,0,0,0.95),
    1px 1px 0 rgba(0,0,0,0.95),
    0 0 20px rgba(0,0,0,0.7);
}

/* Double-tap Gesture Zones */
.gesture-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; width: 100%; height: 100%;
}
.gesture-zone {
  flex: 1; height: 100%; position: relative;
}
.seek-ripple {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 90px; height: 90px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.seek-ripple.left { left: 20%; }
.seek-ripple.right { right: 20%; }
.seek-ripple.animate {
  opacity: 1; transform: translateY(-50%) scale(1.1);
  animation: rippleFade 0.5s ease forwards;
}
@keyframes rippleFade {
  0% { opacity: 0.9; transform: translateY(-50%) scale(0.9); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.1); }
  100% { opacity: 0; transform: translateY(-50%) scale(1.2); }
}

/* Buffering Spinner */
.player-buffering {
  position: absolute; inset: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.3); pointer-events: none;
  transition: opacity 0.2s ease;
}
.player-buffering.hidden { opacity: 0; visibility: hidden; }
.buffering-ring {
  width: 54px; height: 54px; border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Bottom Controls */
.player-controls {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 30;
  padding: 12px 24px 20px;
  background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.player-controls.hide { opacity: 0; transform: translateY(10px); pointer-events: none; }

/* Fat Draggable Progress Bar */
.player-progress-wrap {
  position: relative; width: 100%; height: 32px;
  display: flex; align-items: center; cursor: pointer;
  touch-action: none;
}
.player-progress-track {
  width: 100%; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.2); position: relative;
  transition: height 0.15s ease;
}
.player-progress-wrap:hover .player-progress-track,
.player-progress-wrap.scrubbing .player-progress-track {
  height: 8px; border-radius: 4px;
}
.player-progress-buffer {
  position: absolute; top: 0; left: 0; height: 100%; border-radius: inherit;
  background: rgba(255,255,255,0.25); width: 0%;
}
.player-progress-fill {
  position: absolute; top: 0; left: 0; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  width: 0%;
}
.player-progress-thumb {
  position: absolute; top: 50%; left: 0%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px rgba(0,0,0,0.6);
  opacity: 0; transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
.player-progress-wrap:hover .player-progress-thumb,
.player-progress-wrap.scrubbing .player-progress-thumb {
  opacity: 1; transform: translate(-50%, -50%) scale(1.2);
}
.player-time-tooltip {
  position: absolute; bottom: 34px; transform: translateX(-50%);
  padding: 4px 8px; border-radius: 4px;
  background: rgba(18, 18, 30, 0.9); border: 1px solid var(--glass-border);
  color: #fff; font-size: 12px; font-weight: 700;
  pointer-events: none; opacity: 0; transition: opacity 0.15s ease;
  white-space: nowrap;
}
.player-progress-wrap:hover .player-time-tooltip,
.player-progress-wrap.scrubbing .player-time-tooltip { opacity: 1; }

/* Control Buttons Row */
.player-btns {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.player-btns-left { display: flex; align-items: center; gap: 8px; }
.player-btns-right { display: flex; align-items: center; gap: 10px; }

.player-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; background: transparent;
  transition: all var(--transition);
  cursor: pointer; position: relative;
}
.player-btn:hover { background: rgba(255,255,255,0.15); transform: scale(1.08); }
.player-btn:active { transform: scale(0.95); }
.player-btn.active { color: var(--accent); background: var(--accent-dim); }

.player-play-btn {
  width: 48px; height: 48px;
  background: rgba(255,255,255,0.12);
}
.player-play-btn:hover {
  background: var(--accent); color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}

.player-time {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.75);
  margin-left: 8px; font-variant-numeric: tabular-nums;
}

/* Volume Control */
.player-volume-wrap {
  display: flex; align-items: center; gap: 6px;
  position: relative;
}
.player-volume-slider {
  width: 0px; opacity: 0; height: 4px; border-radius: 2px;
  -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,0.3); outline: none;
  transition: width 0.2s ease, opacity 0.2s ease;
  cursor: pointer;
}
.player-volume-wrap:hover .player-volume-slider,
.player-volume-slider:focus {
  width: 70px; opacity: 1;
}
.player-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; cursor: pointer;
}

/* Slide-up Menus (Subtitles & Speed) */
.player-sheet-menu {
  position: absolute; bottom: 80px; right: 24px; z-index: 40;
  width: 280px; max-height: 320px; overflow-y: auto;
  background: rgba(18, 18, 30, 0.95); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); padding: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.8);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: flex; flex-direction: column; gap: 4px;
  animation: slideUpMenu 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUpMenu {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.player-menu-title {
  font-size: 12px; font-weight: 800; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px; padding: 6px 10px 4px;
}
.player-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  cursor: pointer; transition: background var(--transition);
  text-align: left;
}
.player-menu-item:hover { background: var(--glass-hover); }
.player-menu-item.selected {
  color: var(--accent); background: var(--accent-dim);
}
.player-badge-speed {
  font-size: 13px; font-weight: 800; padding: 2px 6px;
  border-radius: 4px; border: 1px solid var(--glass-border);
}

.player-btn:hover { background: rgba(255,255,255,0.1); }
.player-time { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-left: 8px; }
.player-spacer { flex: 1; }

/* ── Continue Watching Card Upgrades ──────────────────── */
.continue-card { position: relative; }
.continue-fallback-cover {
  position: absolute; inset: 0;
  background: linear-gradient(145deg, #1c1c36 0%, #0d0d1e 100%);
  display: none; align-items: center; justify-content: center;
  padding: 12px; text-align: center;
  border-radius: var(--radius-md);
  z-index: 1;
}
.continue-fallback-cover.show { display: flex; }
.fallback-title {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 800; color: var(--text-primary);
  line-height: 1.3;
}
.continue-play-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--transition);
  border-radius: var(--radius-md);
}
.continue-card:hover .continue-play-overlay { opacity: 1; }
.continue-play-circle {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px var(--accent-glow);
  transform: scale(0.9); transition: transform var(--transition);
}
.continue-card:hover .continue-play-circle { transform: scale(1); }
.continue-progress-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  overflow: hidden;
}
.continue-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
}

/* ── Premium Search Page Layout ────────────────────────── */
.search-page-wrapper {
  padding: 24px 5%;
  max-width: 1200px;
  margin: 0 auto;
}
.search-hero-bar {
  display: flex; flex-direction: column; gap: 14px;
  margin-bottom: 28px;
}
.search-input-box {
  position: relative; width: 100%;
  display: flex; align-items: center;
}
.search-box-icon {
  position: absolute; left: 18px;
  color: var(--text-muted); pointer-events: none;
  display: flex; align-items: center;
}
.search-box-field {
  width: 100%;
  padding: 16px 50px 16px 50px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 16px; font-weight: 500;
  outline: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all var(--transition);
}
.search-box-field:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px var(--accent-dim), 0 12px 40px rgba(0, 0, 0, 0.5);
}
.search-box-clear {
  position: absolute; right: 16px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--glass-hover); border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer;
  transition: all var(--transition);
}
.search-box-clear:hover { background: var(--red-dim); color: var(--red); }
.search-filter-pills {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.search-filter-pill {
  padding: 8px 18px; border-radius: 999px;
  background: var(--bg-surface); border: 1px solid var(--glass-border);
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
}
.search-filter-pill:hover {
  background: var(--glass-hover); color: var(--text-primary);
}
.search-filter-pill.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent-light);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.search-trending-section { margin-top: 24px; margin-bottom: 32px; }
.search-trending-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.trending-chip {
  padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--glass-border);
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  cursor: pointer; transition: all var(--transition);
}
.trending-chip:hover {
  background: var(--accent-dim); border-color: var(--accent);
  color: var(--accent-light); transform: translateY(-2px);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px;
}
.results-grid .media-card { width: 100%; }

/* ── Favorites Grid ────────────────────────────────────── */
.favorites-page { padding: 20px 5%; }
.favorites-page h2 { font-family: var(--font-display); font-size: 24px; font-weight: 900; margin-bottom: 20px; }

/* ── Loading Overlay ───────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(6,6,14,0.85); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.loading-spinner {
  width: 44px; height: 44px; border: 3px solid var(--glass-border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ── Toasts ────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-md);
  background: var(--bg-elevated); border: 1px solid var(--glass-border);
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ── Empty States ──────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; font-weight: 600; }

/* ── Stream Status Bar ─────────────────────────────────── */
.stream-status {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--bg-surface); border: 1px solid var(--glass-border);
  font-size: 12px; font-weight: 600; margin-bottom: 12px;
}
.stream-dot {
  width: 8px; height: 8px; border-radius: 50%;
  animation: pulse 1.5s infinite;
}
.stream-dot.buffering { background: var(--gold); }
.stream-dot.streaming { background: var(--green); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Search History Chips ──────────────────────────────── */
.search-history-section { margin-bottom: 24px; }
.search-history-title {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.search-history-clear {
  font-size: 12px; color: var(--accent-light); font-weight: 600; cursor: pointer;
}
.search-history-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.search-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--bg-surface); border: 1px solid var(--glass-border);
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  cursor: pointer; transition: all var(--transition);
}
.search-chip:hover {
  background: var(--bg-elevated); border-color: var(--accent); transform: translateY(-1px);
}
.search-chip-del {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-muted); background: rgba(255,255,255,0.05);
  transition: all var(--transition);
}
.search-chip-del:hover {
  background: var(--red-dim); color: var(--red);
}

/* ── Auth Overlay & Profile Selector ───────────────────── */
.auth-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: radial-gradient(circle at 50% 30%, #16162e 0%, #06060e 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.auth-card {
  width: 100%; max-width: 480px;
  text-align: center;
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.auth-logo {
  font-family: var(--font-display);
  font-size: 48px; font-weight: 900; letter-spacing: -2px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-subtitle {
  font-size: 16px; color: var(--text-secondary); margin-bottom: 32px; font-weight: 500;
}

/* Profile Grid */
.profiles-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 20px;
  margin-bottom: 32px;
}
.profile-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  cursor: pointer; transition: transform var(--transition);
  background: transparent;
}
.profile-card:hover { transform: translateY(-4px); }
.profile-avatar {
  width: 96px; height: 96px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 900; color: #fff;
  border: 3px solid transparent;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  transition: all var(--transition);
  position: relative; overflow: hidden;
}
.profile-avatar::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.2) 100%);
}
.profile-card:hover .profile-avatar {
  border-color: #fff;
  box-shadow: 0 0 24px rgba(255,255,255,0.25);
  transform: scale(1.05);
}
.profile-name {
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.profile-add-avatar {
  background: var(--bg-surface) !important;
  border: 2px dashed var(--glass-border) !important;
  color: var(--text-muted) !important;
  font-size: 32px !important;
}
.profile-card:hover .profile-add-avatar {
  border-color: var(--accent) !important; color: var(--accent) !important;
}

/* PIN Screen */
.pin-view {
  display: flex; flex-direction: column; align-items: center;
  animation: fadeIn 0.2s ease;
}
.pin-target-avatar {
  width: 72px; height: 72px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 900; color: #fff;
  margin-bottom: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.pin-target-name { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.pin-instruction { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }

.pin-dots {
  display: flex; gap: 16px; margin-bottom: 28px;
}
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg-elevated); border: 2px solid var(--glass-border);
  transition: all 0.15s ease;
}
.pin-dot.filled {
  background: var(--accent); border-color: var(--accent-light);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: scale(1.15);
}
.pin-dots.error {
  animation: shake 0.4s ease;
}
.pin-dots.error .pin-dot {
  background: var(--red); border-color: var(--red);
  box-shadow: 0 0 12px var(--red-dim);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.pin-keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  width: 260px; margin-bottom: 20px;
}
.pin-key {
  height: 56px; border-radius: var(--radius-md);
  background: var(--bg-surface); border: 1px solid var(--glass-border);
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  user-select: none; -webkit-user-select: none;
}
.pin-key:active, .pin-key:hover {
  background: var(--bg-elevated); border-color: var(--accent);
  transform: scale(0.96);
}
.pin-back-link {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: color var(--transition);
  margin-top: 8px;
}
.pin-back-link:hover { color: var(--text-primary); }

/* Create Profile Form */
.create-profile-form {
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl); padding: 28px 24px;
  display: flex; flex-direction: column; gap: 16px; text-align: left;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.form-input {
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-surface); border: 1px solid var(--glass-border);
  color: var(--text-primary); font-size: 15px; outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.color-picker-row { display: flex; gap: 10px; margin-top: 4px; }
.color-option {
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: all var(--transition);
}
.color-option.selected {
  border-color: #fff; transform: scale(1.15); box-shadow: 0 0 12px rgba(255,255,255,0.4);
}


/* ── Mobile Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .topbar-nav { display: none; }
  .bottom-nav { display: flex; }
  .main-content { padding-bottom: calc(var(--bnav-h) + 10px); }
  .hero { min-height: 400px; }
  .hero-title { font-size: 28px; }
  .hero-overview { font-size: 13px; -webkit-line-clamp: 2; }
  .detail-header { flex-direction: column; align-items: center; text-align: center; }
  .detail-poster { width: 140px; }
  .detail-title { font-size: 24px; }
  .detail-genres { justify-content: center; }
  .detail-actions { justify-content: center; }
  .media-card { width: 130px; }
  .carousel-section { padding: 0 16px; }
  .search-page, .favorites-page { padding: 16px; }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }

  /* Mobile Search Bar — full-width topbar takeover */
  .search-wrap { position: static; }
  .search-input {
    position: fixed; top: 0; left: 0; right: 0; width: 100% !important;
    height: var(--topbar-h); border-radius: 0;
    padding: 0 56px 0 20px !important;
    font-size: 16px; background: rgba(6,6,14,0.98) !important;
    border: none !important; border-bottom: 1px solid var(--glass-border) !important;
    box-shadow: none !important;
    z-index: 110; opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease !important;
  }
  .search-wrap.open .search-input {
    opacity: 1 !important; pointer-events: all !important;
    border-color: var(--accent) !important;
  }
  .search-close {
    position: fixed; top: 0; right: 12px; height: var(--topbar-h);
    display: flex; align-items: center; z-index: 120;
    color: var(--text-secondary);
  }
  .search-close.hidden { display: none; }

  /* Mobile Player — controls stay visible longer */
  .player-topbar, .player-controls { transition: opacity 0.4s ease, transform 0.4s ease; }

  /* Subtitle sheet smaller on mobile */
  .player-sheet-menu { right: 0; left: 0; width: auto; bottom: 90px; }
}

@media (min-width: 769px) {
  .bottom-nav { display: none; }
  .search-wrap.open .search-input { width: 320px; }
  .hero-content { padding: 60px 5%; }
}

@media (min-width: 1200px) {
  .media-card { width: 180px; }
  .carousel-section { padding: 0 60px; }
  .search-page, .favorites-page { padding: 20px 60px; }
  .detail-body { padding: 0 60px; }
}

/* ── Typography: Display Font Applications ───────────────
   Plus Jakarta Sans applied to major headings & labels
   ──────────────────────────────────────────────────────── */
.sources-title,
.accordion-title,
.auth-subtitle,
.pin-target-name,
.player-now-title {
  font-family: var(--font-display);
}

::cue {
  background: transparent;
  background-color: transparent !important;
  color: white;
  text-shadow: 0px 2px 4px rgba(0,0,0,0.8), 0px -2px 4px rgba(0,0,0,0.8), 2px 0px 4px rgba(0,0,0,0.8), -2px 0px 4px rgba(0,0,0,0.8);
  font-family: 'Inter', 'Dubai', 'Tajawal', 'Almarai', sans-serif;
  font-size: 1.2rem;
}
