/* ============================================================
   Netflix-style Video Player – Global Styles
   ============================================================ */

/* ---------- Reset & Base ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --netflix-red:   #e50914;
  --netflix-red-h: #f40612;
  --bg:            #141414;
  --surface:       #1f1f1f;
  --surface-2:     #2f2f2f;
  --text:          #ffffff;
  --text-muted:    #b3b3b3;
  --radius:        6px;
  --transition:    0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Netflix Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { display: block; max-width: 100%; }
input, select { font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 4%;
  height: 68px;
  background: linear-gradient(to bottom, rgba(0,0,0,.9) 0%, transparent 100%);
  transition: background var(--transition);
}
.navbar.scrolled { background: var(--bg) !important; }

.navbar__logo {
  color: var(--netflix-red);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -1px;
  flex-shrink: 0;
}

.navbar__links {
  display: flex;
  gap: 16px;
  list-style: none;
  font-size: .85rem;
}
.navbar__links a { color: var(--text-muted); transition: color var(--transition); }
.navbar__links a:hover,
.navbar__links a.active { color: var(--text); }

.navbar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,.7);
  border: 1px solid var(--text-muted);
  border-radius: var(--radius);
  padding: 6px 12px;
  transition: border-color var(--transition);
}
.navbar__search:focus-within { border-color: var(--text); }
.navbar__search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .85rem;
  width: 160px;
}
.navbar__search svg { color: var(--text-muted); flex-shrink: 0; }

.btn-api-key {
  font-size: .8rem;
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
  border-radius: var(--radius);
  padding: 5px 10px;
  transition: all var(--transition);
}
.btn-api-key:hover { color: var(--text); border-color: var(--text); }

/* ============================================================
   HERO BANNER
   ============================================================ */
.hero {
  position: relative;
  height: 80vh;
  min-height: 500px;
  overflow: hidden;
  background: var(--surface);
}

.hero__backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  transition: background-image .5s;
}

.hero__gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(20,20,20,.95) 0%,
    rgba(20,20,20,.5) 50%,
    transparent 100%
  ),
  linear-gradient(
    to top,
    rgba(20,20,20,1) 0%,
    transparent 40%
  );
}

.hero__content {
  position: absolute;
  bottom: 15%;
  left: 4%;
  max-width: 480px;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.hero__badge span { color: var(--netflix-red); font-size: 1rem; }

.hero__title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 14px;
  text-shadow: 2px 2px 8px rgba(0,0,0,.8);
}

.hero__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.hero__meta .rating { color: #46d369; font-weight: 700; }
.hero__meta .year,
.hero__meta .type { color: var(--text-muted); }

.hero__overview {
  font-size: .9rem;
  line-height: 1.6;
  color: #e5e5e5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 20px;
}

.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn { border-radius: var(--radius); font-weight: 700; font-size: .95rem; padding: 10px 24px; display: inline-flex; align-items: center; gap: 8px; transition: all var(--transition); }
.btn--primary { background: var(--netflix-red); color: var(--text); }
.btn--primary:hover { background: var(--netflix-red-h); }
.btn--secondary { background: rgba(109,109,110,.7); color: var(--text); }
.btn--secondary:hover { background: rgba(109,109,110,.4); }
.btn svg { width: 18px; height: 18px; }

/* ============================================================
   CONTENT ROWS / CAROUSELS
   ============================================================ */
.content-section { padding: 0 4% 40px; }

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}
.carousel::-webkit-scrollbar { height: 4px; }

/* ---------- Movie Card ------------------------------------ */
.card {
  flex: 0 0 180px;
  scroll-snap-align: start;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform .25s, z-index 0s .25s;
  background: var(--surface);
}

@media (min-width: 768px) { .card { flex: 0 0 200px; } }
@media (min-width: 1200px) { .card { flex: 0 0 220px; } }

.card:hover {
  transform: scale(1.08);
  z-index: 10;
  transition: transform .25s, z-index 0s 0s;
}

.card__img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--surface-2);
}

.card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.9) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
}
.card:hover .card__overlay { opacity: 1; }

.card__title { font-size: .8rem; font-weight: 700; line-height: 1.2; margin-bottom: 6px; }
.card__meta { font-size: .7rem; color: var(--text-muted); display: flex; gap: 8px; }
.card__rating { color: #46d369; font-weight: 700; }

.card__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.card__btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  font-size: 12px;
}
.card__btn:hover { background: rgba(255,255,255,.4); }
.card__btn--play { background: var(--text); color: var(--bg); }
.card__btn--play:hover { background: rgba(255,255,255,.8); }

/* loading skeleton */
.card--skeleton .card__img {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   CONTENT MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface-2);
  border-radius: 12px;
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal__header {
  position: relative;
  height: 380px;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  background: var(--surface);
}
.modal__header img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.modal__header-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--surface-2) 0%, transparent 60%);
}
.modal__title-block {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 24px;
}
.modal__title { font-size: 1.8rem; font-weight: 800; margin-bottom: 10px; }
.modal__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.modal__close {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(20,20,20,.8);
  color: var(--text);
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  transition: background var(--transition);
}
.modal__close:hover { background: var(--surface-2); }

.modal__body { padding: 20px 24px 28px; }

.modal__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: .88rem;
  margin-bottom: 16px;
}
.modal__meta .rating { color: #46d369; font-weight: 700; }
.modal__meta .badge {
  border: 1px solid var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .75rem;
  color: var(--text-muted);
}

.modal__overview {
  font-size: .9rem;
  line-height: 1.7;
  color: #ddd;
  margin-bottom: 16px;
}

.modal__section-title { font-size: .9rem; color: var(--text-muted); margin-bottom: 8px; }
.modal__genres { display: flex; gap: 8px; flex-wrap: wrap; }
.modal__genre-tag {
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 50px;
  font-size: .78rem;
  color: var(--text-muted);
}

/* Season / Episode Selector in Modal */
.modal__seasons {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.modal__select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--text-muted);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: .85rem;
  outline: none;
  cursor: pointer;
}
.modal__select:focus { border-color: var(--text); }

/* ============================================================
   API KEY MODAL
   ============================================================ */
.api-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.api-modal {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 36px;
  max-width: 480px;
  width: 100%;
  text-align: center;
}
.api-modal h2 { font-size: 1.4rem; margin-bottom: 8px; }
.api-modal p { color: var(--text-muted); font-size: .88rem; line-height: 1.6; margin-bottom: 20px; }
.api-modal a { color: var(--netflix-red); }

.api-modal__input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--text-muted);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: .95rem;
  outline: none;
  margin-bottom: 14px;
  transition: border-color var(--transition);
}
.api-modal__input:focus { border-color: var(--text); }

.api-modal__error {
  color: var(--netflix-red);
  font-size: .82rem;
  margin-bottom: 10px;
  min-height: 18px;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: 30px; right: 30px;
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: all .3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  padding: 40px 4%;
  color: var(--text-muted);
  font-size: .82rem;
  text-align: center;
  border-top: 1px solid #333;
  margin-top: 20px;
}
footer a { color: var(--text-muted); margin: 0 8px; }
footer a:hover { text-decoration: underline; }

/* ============================================================
   PLAYER PAGE
   ============================================================ */
.player-page { display: flex; flex-direction: column; min-height: 100vh; }
.player-page .navbar { position: relative; background: var(--bg); }

.player-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: .9rem;
  padding: 12px 4%;
  transition: color var(--transition);
}
.player-back:hover { color: var(--text); }

.player-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 0 4% 40px;
}
@media (min-width: 960px) {
  .player-container { grid-template-columns: 1fr 320px; }
}

.player-iframe-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.player-iframe-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Episode selector (player page) */
.player-sidebar { display: flex; flex-direction: column; gap: 20px; }

.player-info { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.player-info__title { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.player-info__meta { font-size: .82rem; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.player-info__overview { font-size: .85rem; color: #ccc; line-height: 1.6; }

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 22px;
  background: var(--netflix-red);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.download-btn:hover { background: var(--netflix-red-h); }
.download-btn svg { flex-shrink: 0; }

.episode-selector { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.episode-selector h3 { font-size: .95rem; font-weight: 700; margin-bottom: 12px; }
.episode-selector select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid #444;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: .85rem;
  outline: none;
  margin-bottom: 10px;
  cursor: pointer;
}
.episode-list { display: flex; flex-direction: column; gap: 6px; max-height: 400px; overflow-y: auto; }

.episode-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}
.episode-item:hover { background: var(--surface-2); }
.episode-item.active { border-color: var(--netflix-red); background: rgba(229,9,20,.08); }
.episode-item__num { font-size: .75rem; color: var(--text-muted); min-width: 22px; padding-top: 2px; }
.episode-item__info { flex: 1; }
.episode-item__name { font-size: .85rem; font-weight: 600; margin-bottom: 2px; }
.episode-item__runtime { font-size: .75rem; color: var(--text-muted); }

/* Progress bar */
.progress-bar-wrap { height: 3px; background: #333; border-radius: 2px; margin-top: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--netflix-red); border-radius: 2px; transition: width .5s ease; }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--netflix-red);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: .9rem;
}
.error-msg strong { color: var(--netflix-red); display: block; font-size: 1.1rem; margin-bottom: 8px; }

/* no-scroll lock when modal open */
body.modal-open { overflow: hidden; }

/* Responsive nav collapse */
@media (max-width: 640px) {
  .navbar__links { display: none; }
  .navbar__search input { width: 100px; }
}
