/* ── Root Variables & Typography ────────────────────────────────────────── */
:root {
  --bg-base: #0a0a0f;
  --bg-card: rgba(18, 18, 26, 0.88);
  --bg-surface: rgba(26, 26, 38, 0.65);
  --bg-surface-hover: rgba(38, 38, 54, 0.85);
  --bg-active: rgba(194, 239, 78, 0.12);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(194, 239, 78, 0.4);
  --border-active: #c2ef4e;

  --accent-lime: #c2ef4e;
  --accent-cyan: #38bdf8;
  --accent-purple: #a855f7;
  
  --text-main: #f4f4f5;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  --shadow-glow: 0 0 25px rgba(194, 239, 78, 0.2);
  --shadow-card: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.15);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(194, 239, 78, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

.hidden {
  display: none !important;
}

/* ── Loading Screen ─────────────────────────────────────────────────────── */
.portal-loading-screen {
  position: fixed;
  inset: 0;
  background-color: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.loader-pulse-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(194, 239, 78, 0.2);
  border-top-color: var(--accent-lime);
  animation: loaderSpin 0.8s linear infinite;
  box-shadow: 0 0 20px rgba(194, 239, 78, 0.25);
}

@keyframes loaderSpin {
  to { transform: rotate(360deg); }
}

.loader-brand {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.loader-status {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ── Unauthorized Screen (life is unfair : ) ───────────────────────────── */
.unfair-screen {
  position: fixed;
  inset: 0;
  background-color: #060709;
  color: #71717a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  user-select: none;
}

.unfair-text {
  font-family: 'Outfit', -apple-system, sans-serif;
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #a1a1aa;
  animation: unfairPulse 4s ease-in-out infinite alternate;
}

@keyframes unfairPulse {
  0% { opacity: 0.7; transform: scale(0.99); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Portal Container & Glass Card ─────────────────────────────────────── */
.portal-container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  animation: cardFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardFadeUp {
  0% { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

.portal-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Top Header Brand ─────────────────────────────────────────────────── */
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.brand-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-lime);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-lime);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  background: rgba(194, 239, 78, 0.1);
  border: 1px solid rgba(194, 239, 78, 0.25);
  border-radius: var(--radius-pill);
  color: var(--accent-lime);
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-lime);
  border-radius: 50%;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

/* ── Drama Hero Info ──────────────────────────────────────────────────── */
.drama-hero {
  display: flex;
  gap: 18px;
  align-items: center;
}

.drama-poster-wrap {
  flex-shrink: 0;
  width: 78px;
  height: 110px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #181822;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.drama-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drama-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ep-badge-wrap {
  display: flex;
}

.quality-active-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  background: rgba(194, 239, 78, 0.15);
  border: 1px solid rgba(194, 239, 78, 0.35);
  color: var(--accent-lime);
  border-radius: var(--radius-sm);
}

.drama-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: #fff;
}

.drama-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Portal Quality Switcher Bar ───────────────────────────────────────── */
.portal-quality-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.bar-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.quality-pills-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.portal-q-pill {
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.portal-q-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.portal-q-pill.active {
  background: rgba(194, 239, 78, 0.16);
  border-color: rgba(194, 239, 78, 0.45);
  color: var(--accent-lime);
  font-weight: 700;
}

/* ── Episodes Download Section ─────────────────────────────────────────── */
.episodes-download-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding-bottom: 4px;
}

.mp4-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  border-radius: 4px;
}

.episodes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.episodes-list::-webkit-scrollbar {
  width: 6px;
}
.episodes-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* ── Individual Episode Row: [ Episode X: Original | English Dub | Hindi Dub ] ── */
.episode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  transition: all 0.2s ease;
  gap: 12px;
}

.episode-row:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}

.ep-badge-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  min-width: 86px;
}

.ep-audio-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ep-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.ep-audio-btn:hover:not(:disabled) {
  background: rgba(194, 239, 78, 0.14);
  border-color: rgba(194, 239, 78, 0.4);
  color: var(--accent-lime);
  transform: translateY(-1px);
}

.ep-audio-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.ep-audio-btn .btn-flag {
  font-size: 0.85rem;
}

.ep-audio-btn.is-loading {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.4);
  color: #c084fc;
}

.ep-audio-btn.is-ready {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.5);
  color: #4ade80;
}

.btn-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Toast / Download Notice ───────────────────────────────────────────── */
.download-notice {
  font-size: 0.82rem;
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  animation: fadeIn 0.2s ease;
}

.download-notice.info {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
}

.download-notice.success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.download-notice.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ── Portal Footer ────────────────────────────────────────────────────── */
.portal-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  letter-spacing: 0.02em;
}

/* ── Responsive Mobile Layout ─────────────────────────────────────────── */
@media (max-width: 600px) {
  body {
    padding: 10px 8px;
  }

  .portal-card {
    padding: 20px 14px;
    gap: 16px;
  }

  .drama-hero {
    gap: 12px;
  }

  .drama-poster-wrap {
    width: 68px;
    height: 96px;
  }

  .drama-title {
    font-size: 1.15rem;
  }

  .episode-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }

  .ep-audio-actions {
    width: 100%;
  }

  .ep-audio-btn {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.74rem;
  }
}
