:root {
  --bg: #0a0a0f;
  --surface: #141420;
  --surface-hover: #1c1c30;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --text: #ffffff;
  --text-secondary: #9090a8;
  --star: #ffd700;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --transition: 0.25s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* Loader */
.loader {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 20px;
  gap: 8px;
}
.loader span {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s ease-in-out infinite;
}
.loader span:nth-child(2) { animation-delay: 0.2s; }
.loader span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Header */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  cursor: pointer;
  user-select: none;
}
.logo span { color: inherit; }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  max-width: 400px;
  margin: 0 24px;
}
.search-wrap input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px 0 0 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border var(--transition);
}
.search-wrap input:focus {
  border-color: var(--accent);
}
.search-wrap button {
  padding: 9px 18px;
  border: none;
  border-radius: 0 8px 8px 0;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-wrap button:hover {
  background: var(--accent-light);
}

/* Search suggestions */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0 0 10px 10px;
  max-height: 380px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.search-suggestions.visible { display: block; }
.ss-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.ss-item:hover { background: var(--surface-hover); }
.ss-poster {
  flex-shrink: 0;
  width: 36px;
  height: 54px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-hover);
}
.ss-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ss-poster-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 700;
}
.ss-info { flex: 1; min-width: 0; }
.ss-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ss-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.ss-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1.2;
}
.ss-badge.movie { background: var(--accent); color: #fff; }
.ss-badge.tv { background: #e74c3c; color: #fff; }
.ss-year {
  font-size: 12px;
  color: var(--text-secondary);
}
.ss-loading, .ss-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Main */
main {
  padding-top: 68px;
  min-height: calc(100vh - 60px);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Hero Carousel */
.hero-carousel {
  position: relative;
  width: 100%;
  height: 480px;
  overflow: hidden;
  margin-bottom: 32px;
}
.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
  z-index: 0;
  pointer-events: none;
}
.hero-slide.active {
  opacity: 1;
  z-index: 1;
  pointer-events: auto;
}
.hero-backdrop {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 60%, rgba(10,10,15,0.6) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px 40px;
}
.hero-title {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 8px;
  max-width: 600px;
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--text-secondary);
}
.hero-rating { color: var(--star); font-weight: 600; }
.hero-overview {
  font-size: 15px;
  color: #c0c0d0;
  max-width: 550px;
  margin-bottom: 18px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  width: fit-content;
}
.hero-btn:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
}
.hero-arrows {
  position: absolute;
  bottom: 60px;
  right: 16px;
  z-index: 3;
  display: flex;
  gap: 10px;
}
.hero-arrow {
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  line-height: 1;
}
.hero-arrow:hover {
  background: rgba(0,0,0,0.8);
  transform: scale(1.1);
}

@media (hover: none) {
  .hero-arrows { display: none; }
}

.hero-dots {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3;
}
.hero-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  padding: 0;
}
.hero-dot.active {
  background: #fff;
  transform: scale(1.25);
  box-shadow: 0 0 6px rgba(255,255,255,0.4);
}
.hero-dot:hover {
  background: rgba(255,255,255,0.7);
}

/* Section */
.section {
  margin-bottom: 40px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 22px;
  font-weight: 600;
}
.see-all {
  font-size: 13px;
  color: var(--accent-light);
  cursor: pointer;
  transition: color var(--transition);
}
.see-all:hover { color: var(--accent); }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
}

/* Card */
.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow);
}
.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--surface-hover);
}
.card-body {
  padding: 10px 12px 14px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.card-badge.movie { background: var(--accent); }
.card-badge.tv { background: #e74c3c; }
.card-rating {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.75);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--star);
}

/* Detail page */
.detail-header {
  position: relative;
  width: 100%;
  height: 420px;
  overflow: hidden;
}
.detail-backdrop {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-header-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 70%);
}
.detail-content {
  position: relative;
  max-width: 1200px;
  margin: -160px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 32px;
  z-index: 2;
}
.detail-poster {
  flex-shrink: 0;
  width: 260px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.detail-poster img {
  width: 100%;
  display: block;
}
.detail-info {
  padding-top: 20px;
  flex: 1;
}
.detail-info h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 6px;
}
.detail-info .tagline {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-style: italic;
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}
.detail-meta .rating { color: var(--star); font-weight: 600; }
.detail-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.detail-genres span {
  padding: 4px 14px;
  background: var(--surface);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}
.detail-overview {
  font-size: 15px;
  color: #c0c0d0;
  line-height: 1.8;
  margin-bottom: 24px;
  max-width: 700px;
}
.detail-watch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.detail-watch-btn:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
}
.detail-selectors {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.detail-selectors select {
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}
.detail-selectors select:focus {
  border-color: var(--accent);
}

/* Cast */
.cast-section {
  max-width: 1200px;
  margin: 32px auto 0;
  padding: 0 24px;
}
.cast-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 14px;
}
.cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}
.cast-card {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 8px;
  transition: background var(--transition);
}
.cast-card:hover { background: var(--surface-hover); }
.cast-card img {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 8px;
}
.cast-name {
  font-size: 13px;
  font-weight: 600;
}
.cast-role {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Player overlay */
#player-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}
#player-overlay.hidden {
  display: none;
}
.player-container {
  position: relative;
  width: 90vw;
  max-width: 1100px;
  aspect-ratio: 16/9;
}
.player-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
}
.player-close:hover { background: rgba(0,0,0,0.8); }


#player-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius);
}

/* Error / empty states */
.state-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.state-msg h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--text);
}
.state-msg p { font-size: 14px; }
.state-msg a {
  color: var(--accent-light);
  text-decoration: underline;
}

/* Footer */
footer {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin-top: 40px;
}

/* Responsive */
@media (max-width: 768px) {
  header { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .search-wrap { order: 3; margin: 0; max-width: 100%; flex-basis: 100%; }
  .hero-carousel { height: 320px; }
  .hero-overlay { padding: 24px 20px; }
  .hero-title { font-size: 26px; }
  .hero-overview { -webkit-line-clamp: 2; }
  .hero-dots { right: 8px; gap: 8px; }
  .hero-dot { width: 8px; height: 8px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
  .detail-content { flex-direction: column; margin-top: -80px; align-items: center; }
  .detail-poster { width: 180px; }
  .detail-info { padding-top: 12px; text-align: center; }
  .detail-info h1 { font-size: 24px; }
  .detail-overview { max-width: 100%; }
  .detail-selectors { justify-content: center; }
  .container { padding: 0 16px; }
  .cast-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hero-carousel { height: 260px; }
  .hero-title { font-size: 22px; }
  .hero-dots { right: 6px; gap: 6px; }
  .hero-dot { width: 6px; height: 6px; }
  .player-container { width: 98vw; }
}
