/* ═══════════════════════════════════════════════════════════════════════════
   MASKALI — Full Streaming Portal
   Dark red + deep black + nebula glow
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-nav: rgba(8, 3, 3, 0.78);
  --accent: #e50914;
  --accent-glow: rgba(229, 9, 20, 0.35);
  --accent-dark: #8b0000;
  --text: #e5e5e5;
  --text-dim: #888;
  --border: #1a1a1a;
  --glass: rgba(20, 5, 5, 0.6);
  --radius: 8px;
  --nav-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ─── Starfield ──────────────────────────────────────────────────────────── */
#starfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); z-index: 1000;
  background: var(--bg-nav); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border-bottom: 1px solid rgba(229, 9, 20, 0.1);
}
.nav-inner {
  max-width: 1500px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; padding: 0 24px; gap: 20px;
}
.logo { font-size: 22px; font-weight: 900; color: #fff; text-decoration: none; letter-spacing: 1px; flex-shrink: 0; }
.logo:hover { color: var(--accent); }

/* Nav Links */
.nav-links { display: flex; gap: 6px; }
.nav-link {
  color: var(--text-dim); text-decoration: none; padding: 8px 16px;
  border-radius: 6px; font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(229,9,20,0.18); }

/* Search */
.search-box { position: relative; flex: 1; max-width: 480px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-dim); pointer-events: none; }
#searchInput {
  width: 100%; padding: 10px 16px 10px 42px; border-radius: 24px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.08);
  color: #fff; font-size: 14px; outline: none; transition: all 0.2s;
}
#searchInput:focus { border-color: var(--accent); background: rgba(255,255,255,0.1); }
#searchInput::placeholder { color: var(--text-dim); }

.search-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: rgba(20,8,8,0.97); backdrop-filter: blur(20px);
  border: 1px solid rgba(229,9,20,0.12); border-radius: 12px;
  max-height: 400px; overflow-y: auto; display: none; z-index: 1100;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7);
}
.search-dropdown.active { display: block; }
.search-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  cursor: pointer; transition: background 0.15s;
}
.search-item:hover { background: rgba(229,9,20,0.12); }
.search-item-img { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--bg-card); }
.search-item-title { font-size: 14px; font-weight: 600; color: #fff; }
.search-item-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.search-empty { padding: 20px; text-align: center; color: var(--text-dim); font-size: 13px; }

.nav-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.user-name { font-size: 13px; color: var(--text-dim); }
.btn-request {
  background: var(--accent); color: #fff; border: none; padding: 10px 22px;
  border-radius: 50px; font-size: 14px; font-weight: 800; cursor: pointer;
  letter-spacing: 1px; box-shadow: 0 4px 20px var(--accent-glow); transition: all 0.2s;
}
.btn-request:hover { background: #b20710; transform: scale(1.04); }
.btn-logout {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 4px; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.btn-logout:hover { color: #fff; border-color: var(--accent); }

/* ─── Login ───────────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0; z-index: 2000; display: flex;
  align-items: center; justify-content: center; background: var(--bg);
}
.login-card {
  background: var(--glass); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(229,9,20,0.15); border-radius: 16px; padding: 48px 40px;
  width: 400px; max-width: 90vw; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 80px rgba(229,9,20,0.08);
}
.login-logo { font-size: 32px; font-weight: 900; color: #fff; margin-bottom: 8px; }
.login-tagline { color: var(--text-dim); font-size: 14px; margin-bottom: 32px; }
#loginForm { display: flex; flex-direction: column; gap: 14px; }
#loginForm input {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: #fff; padding: 14px 18px; border-radius: 8px; font-size: 15px; outline: none; transition: border 0.2s;
}
#loginForm input:focus { border-color: var(--accent); }
.btn-login {
  background: var(--accent); color: #fff; border: none; padding: 14px; border-radius: 8px;
  font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 4px;
  box-shadow: 0 4px 20px var(--accent-glow); transition: all 0.2s;
}
.btn-login:hover { background: #b20710; }
.login-error { color: var(--accent); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ─── Main Content ────────────────────────────────────────────────────────── */
#mainContent { position: relative; z-index: 2; padding-top: var(--nav-h); }

/* ─── Hero ────────────────────────────────────────────────────────────────── */
#heroSection {
  position: relative; min-height: 65vh; display: flex; align-items: flex-end;
  padding: 40px 48px 64px; margin-bottom: 4px; overflow: hidden;
}
.hero-backdrop {
  position: absolute; inset: 0; background-size: cover; background-position: center 20%;
  filter: brightness(0.4); transition: background-image 0.8s ease;
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, var(--bg) 0%, transparent 35%, rgba(10,0,0,0.6) 100%);
}
.hero-content { position: relative; z-index: 2; max-width: 650px; }
.hero-content h1 { font-size: 44px; font-weight: 900; color: #fff; text-shadow: 0 2px 24px rgba(0,0,0,0.9); margin-bottom: 6px; line-height: 1.1; }
#heroMeta { font-size: 15px; color: var(--text-dim); margin-bottom: 12px; }
#heroOverview { font-size: 15px; color: rgba(255,255,255,0.72); line-height: 1.5; max-width: 500px; margin-bottom: 20px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-buttons { display: flex; gap: 12px; }
.btn-play {
  background: var(--accent); color: #fff; border: none; padding: 14px 32px; border-radius: 8px;
  font-size: 16px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 28px var(--accent-glow); transition: all 0.2s;
}
.btn-play:hover { background: #b20710; transform: scale(1.04); }
.btn-secondary {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.15);
  padding: 14px 28px; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: rgba(255,255,255,0.18); }

/* ─── Genre Chips ─────────────────────────────────────────────────────────── */
.genre-bar { display: flex; gap: 8px; padding: 16px 48px 8px; flex-wrap: wrap; position: relative; z-index: 2; }
.genre-chip {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  color: var(--text); padding: 8px 18px; border-radius: 20px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.genre-chip:hover { background: rgba(229,9,20,0.2); border-color: var(--accent); color: #fff; }

/* ─── Content Rows ────────────────────────────────────────────────────────── */
.content-row { position: relative; z-index: 2; padding: 16px 48px 8px; }
.row-title { font-size: 19px; font-weight: 700; color: #fff; margin-bottom: 12px; }
.page-title { font-size: 26px; font-weight: 800; color: #fff; padding: 24px 48px 8px; position: relative; z-index: 2; }

.card-row {
  display: flex; gap: 12px; overflow-x: auto; padding: 8px 0 16px;
  scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.06) transparent;
}
.card-row::-webkit-scrollbar { height: 4px; }
.card-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  flex-shrink: 0; width: 170px; cursor: pointer; transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative; border-radius: var(--radius); overflow: hidden; background: var(--bg-card);
}
.card:hover { transform: scale(1.14) translateY(-6px); z-index: 10; box-shadow: 0 12px 40px rgba(0,0,0,0.8), 0 0 20px var(--accent-glow); }
.card-img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--bg-card); }
.card-info {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 10px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.92) 30%); opacity: 0; transition: opacity 0.25s;
}
.card:hover .card-info { opacity: 1; }
.card-title { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.card-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,0.1); }
.card-progress-bar { height: 100%; background: var(--accent); box-shadow: 0 0 6px rgba(229,9,20,0.5); transition: width 0.3s; }

/* ─── Loading / Empty ─────────────────────────────────────────────────────── */
.loader { text-align: center; padding: 40px; color: var(--text-dim); width: 100%; }
.loader::after { content:''; display:inline-block; width:22px;height:22px;border:2px solid rgba(229,9,20,0.15);border-top-color:var(--accent);border-radius:50%;animation:spin 0.7s linear infinite;vertical-align:middle;margin-left:8px; }
@keyframes spin { to{transform:rotate(360deg)} }
.empty-state { text-align: center; padding: 40px; color: var(--text-dim); width: 100%; font-size: 14px; }

/* ─── Detail Modal ────────────────────────────────────────────────────────── */
.detail-modal {
  position: fixed; inset: 0; z-index: 5000; display: none; overflow-y: auto;
}
.detail-modal.active { display: block; }
.detail-backdrop { position: fixed; inset: 0; background-size: cover; background-position: center 15%; filter: brightness(0.3); }
.detail-overlay { position: fixed; inset: 0; background: linear-gradient(180deg, rgba(10,0,0,0.5) 0%, var(--bg) 85%); }
.detail-content { position: relative; z-index: 2; padding: 80px 48px 48px; max-width: 1200px; margin: 0 auto; }
.detail-close {
  position: fixed; top: 20px; right: 28px; z-index: 5001;
  background: rgba(0,0,0,0.5); border: none; color: #fff; width: 44px; height: 44px;
  border-radius: 50%; font-size: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.detail-close:hover { background: var(--accent); }
.detail-body { display: flex; gap: 36px; }
.detail-poster { width: 280px; border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,0.6); flex-shrink: 0; object-fit: cover; background: var(--bg-card); }
.detail-info { flex: 1; min-width: 0; }
.detail-info h1 { font-size: 32px; font-weight: 900; color: #fff; margin-bottom: 10px; }
.detail-meta { font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }
.detail-genres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tag {
  background: rgba(229,9,20,0.15); border: 1px solid rgba(229,9,20,0.25);
  color: var(--text); padding: 4px 12px; border-radius: 14px; font-size: 12px; font-weight: 600;
}
.detail-overview { font-size: 15px; color: rgba(255,255,255,0.7); line-height: 1.65; margin-bottom: 20px; }
.detail-actions { display: flex; gap: 12px; margin-bottom: 24px; }
.detail-subtitle { font-size: 18px; font-weight: 700; color: #fff; margin: 24px 0 12px; }
.season-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.season-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); color: var(--text-dim);
  padding: 6px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.season-btn:hover, .season-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.detail-similar { margin-top: 40px; }
.detail-similar .card-row { padding: 0 0 16px; }

/* ─── Jellyseerr Overlay ──────────────────────────────────────────────────── */
#jellyseerrOverlay {
  position: fixed; inset: 0; z-index: 9998; background: rgba(10,10,10,0.9);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: none; justify-content: center; align-items: center;
}
#jellyseerrOverlay.active { display: flex; }
#jellyseerrFrame { width: 95vw; max-width: 1300px; height: 92vh; border: none; border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,0.9); background: #141414; }
#jellyseerrClose {
  position: absolute; top: 24px; right: 36px; background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.25); color: #fff; width: 48px; height: 48px;
  border-radius: 50%; font-size: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 9999; transition: all 0.15s;
}
#jellyseerrClose:hover { background: var(--accent); border-color: var(--accent); transform: scale(1.08); }

/* ─── Footer ──────────────────────────────────────────────────────────────── */
footer { position: relative; z-index: 2; text-align: center; padding: 48px 24px 32px; color: var(--text-dim); font-size: 13px; }
.footer-sub { font-size: 12px; margin-top: 4px; opacity: 0.5; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #heroSection { min-height: 45vh; padding: 24px 20px 40px; }
  .hero-content h1 { font-size: 26px; }
  .content-row { padding: 12px 20px; }
  .genre-bar { padding: 10px 20px; }
  .card { width: 130px; }
  .detail-body { flex-direction: column; align-items: center; }
  .detail-poster { width: 200px; }
  .detail-content { padding: 60px 20px 32px; }
  .detail-info h1 { font-size: 24px; text-align: center; }
  .search-box { max-width: 200px; }
}
