:root {
  --bg-main: #0c0d14;
  --bg-card: #151722;
  --bg-card-hover: #1f2232;
  --bg-surface: #1b1e2c;
  --accent-red: #e50914;
  --accent-red-hover: #b80710;
  --accent-gold: #ffb703;
  --text-main: #ffffff;
  --text-muted: #8e95a5;
  --border-color: rgba(255, 255, 255, 0.08);
  --header-height: 64px;
  --bottom-nav-height: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   Responsive Navigation Header
   ========================================================================== */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(12, 13, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 30px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-badge {
  background: var(--accent-red);
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  padding: 3px 9px;
  border-radius: 6px;
}

.logo-text {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.15s;
}

.nav-link:hover, .nav-link.active {
  color: #fff;
}

/* Desktop Search Box */
.desktop-search-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 7px 16px;
  width: 280px;
  transition: width 0.25s, border-color 0.2s;
}

.desktop-search-box:focus-within {
  width: 360px;
  border-color: var(--accent-red);
}

.desktop-search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  width: 100%;
  margin-left: 10px;
}

/* Mobile search triggers */
.mobile-only {
  display: none !important;
}

.header-icon-btn {
  background: transparent;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Dedicated Search Bar Overlay (Active when search is triggered) */
.search-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-main);
  padding: 8px 24px;
  z-index: 150;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
}

.search-container.active {
  display: flex !important;
}

.search-input-wrapper {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border-radius: 20px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
}

.search-input-wrapper input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 15px;
  width: 100%;
  margin-left: 10px;
}

.search-close-btn {
  background: transparent;
  border: none;
  color: var(--accent-red);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
}

/* ==========================================================================
   Hero Banner Section (Responsive)
   ========================================================================== */
.hero-banner {
  position: relative;
  width: 100%;
  height: 72vh;
  min-height: 480px;
  max-height: 680px;
  margin-top: var(--header-height);
  display: flex;
  align-items: flex-end;
  padding: 0 50px 60px;
  background-size: cover;
  background-position: center top;
}

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--bg-main) 10%, rgba(12, 13, 20, 0.45) 55%, rgba(12, 13, 20, 0.8) 100%),
              linear-gradient(90deg, var(--bg-main) 0%, rgba(12, 13, 20, 0.6) 40%, transparent 80%);
}

.hero-content {
  position: relative;
  z-index: 10;
  max-width: 650px;
}

.hero-title {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 12px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.rating-badge {
  background: var(--accent-gold);
  color: #000;
  font-weight: 800;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 4px;
}

.hero-overview {
  font-size: 14px;
  line-height: 1.6;
  color: #cdd3de;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 22px;
}

.btn-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent-red);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(229, 9, 20, 0.4);
  transition: transform 0.15s, background-color 0.15s;
}

.btn-play:hover {
  background: var(--accent-red-hover);
  transform: scale(1.02);
}

.btn-play:active {
  transform: scale(0.98);
}

/* ==========================================================================
   Content Sections & Cards Slider
   ========================================================================== */
.section-container {
  padding: 24px 45px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cards-slider {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 14px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.cards-slider::-webkit-scrollbar {
  height: 6px;
}

.cards-slider::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.movie-card {
  flex: 0 0 160px;
  height: auto;
  align-self: flex-start;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.movie-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}

.card-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg-surface);
}

.card-info {
  padding: 10px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.card-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Search View */
#searchResultsSection {
  min-height: calc(100vh - var(--header-height));
  padding-top: calc(var(--header-height) + 20px);
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
  padding-top: 10px;
}

.search-grid .movie-card {
  flex: none;
  width: 100%;
}

/* ==========================================================================
   Detail Screen / Modal (Responsive)
   ========================================================================== */
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.detail-backdrop.active {
  display: flex;
}

.detail-container {
  background: var(--bg-card);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  border-radius: 12px;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.9);
  border: 1px solid var(--border-color);
}

.detail-header-bar {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 10;
}

.circle-btn {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.circle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.detail-cover-hero {
  height: 340px;
  background-size: cover;
  background-position: center;
  position: relative;
}

.detail-cover-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--bg-card) 5%, transparent 70%);
}

.detail-body-wrapper {
  padding: 24px 35px 35px;
}

.detail-title {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 10px;
  line-height: 1.2;
}

.detail-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

.tag-item {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 4px 10px;
  border-radius: 5px;
}

.detail-overview {
  font-size: 14px;
  line-height: 1.6;
  color: #cfd5e1;
  margin: 18px 0 24px;
}

/* Season / Episodes */
.season-selector-wrapper {
  margin-top: 20px;
}

.season-tabs-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.season-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.season-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.season-chip:hover {
  color: #fff;
}

.season-chip.active {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
}

.episodes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.episode-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-surface);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
}

.episode-row:hover, .episode-row.active {
  background: rgba(229, 9, 20, 0.18);
  border-color: var(--accent-red);
}

.episode-num-label {
  font-size: 11px;
  color: var(--accent-gold);
  font-weight: 700;
}

.episode-name-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Fullscreen Video Player
   ========================================================================== */
.player-container {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 300;
  display: none;
  flex-direction: column;
}

.player-container.active {
  display: flex;
}

.player-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 310;
}

.player-header-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

.player-selectors {
  display: flex;
  gap: 10px;
  align-items: center;
}

.player-select {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  max-width: 130px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.player-select option {
  background: #111;
  color: #fff;
}

.video-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

video {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  object-fit: contain;
}

.player-loader {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 13px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Mobile Responsive Breakpoint (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
    --bottom-nav-height: 56px;
  }

  body {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 10px);
  }

  header {
    padding: 0 16px;
  }

  .desktop-nav, .desktop-search-box {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  /* Mobile Search Bar padding adjustment */
  .search-container {
    padding: 8px 14px;
    gap: 10px;
  }

  /* Mobile Hero */
  .hero-banner {
    height: 58vh;
    min-height: 380px;
    padding: 0 16px 20px;
  }

  .hero-title {
    font-size: 26px;
  }

  .hero-overview {
    font-size: 13px;
    -webkit-line-clamp: 2;
  }

  .btn-play {
    width: 100%;
    padding: 12px;
  }

  .section-container {
    padding: 14px 16px;
  }

  .section-title {
    font-size: 17px;
    margin-bottom: 12px;
  }

  .movie-card {
    flex: 0 0 120px;
    height: auto !important;
    align-self: flex-start !important;
  }

  .search-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  /* Mobile Detail Screen (Full screen view instead of popup modal) */
  .detail-backdrop {
    padding: 0;
  }

  .detail-container {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
  }

  .detail-header-bar {
    position: fixed;
    top: 12px;
    left: 12px;
    right: auto;
  }

  .detail-cover-hero {
    height: 44vh;
  }

  .detail-body-wrapper {
    padding: 0 16px 30px;
  }

  .detail-title {
    font-size: 22px;
  }

  .episodes-list {
    grid-template-columns: 1fr;
  }

  /* Bottom Navigation Bar */
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(12, 13, 20, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 90;
  }

  .bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }

  .bottom-tab.active {
    color: var(--accent-red);
  }

  .bottom-tab svg {
    width: 22px;
    height: 22px;
  }
}
