/* ========== GLOBAL STYLES ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #000;
  color: #fff;
  line-height: 1.6;
}

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

button {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Utility */
.text-shadow {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

/* ========== APP CONTAINER ========== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ========== NAVBAR ========== */
.navbar {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 50;
  transition: all 0.3s ease;
}

.navbar.transparent {
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0.4));
}

.navbar.scrolled {
  background: rgba(0,0,0,0.95);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.navbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.logo img {
  height: 32px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.logo img:hover {
  transform: scale(1.05);
}

/* Links */
.nav-links {
  display: none;
}

.nav-link {
  font-size: 0.9rem;
  font-weight: 400;
  color: #fff;
  margin: 0 1rem;
  padding: 0.5rem 0;
  position: relative;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: #e50914;
}

.nav-link.active {
  font-weight: 600;
  color: #e50914;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #e50914;
  border-radius: 1px;
}

@media (min-width: 768px) {
  .nav-links {
    display: flex;
  }
}

/* Navbar Actions */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.btn-primary {
  background: linear-gradient(135deg, #e50914, #b20710);
  color: #fff;
  box-shadow: 0 4px 12px rgba(229, 9, 20, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #b20710, #8a0508);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(229, 9, 20, 0.4);
}

/* Search */
.search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.25rem;
}

.search-input {
  width: 16rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  color: #fff;
  border-radius: 6px;
  font-size: 0.9rem;
}

.search-input::placeholder {
  color: rgba(255,255,255,0.6);
}

.search-input:focus {
  outline: none;
  background: rgba(255,255,255,0.1);
}

.search-btn, .search-toggle {
  color: #ccc;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.search-btn:hover,
.search-toggle:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* Search Icon */
.search-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Search Suggestions Dropdown */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0 0 8px 8px;
  border-top: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.search-suggestion {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.search-suggestion:hover {
  background: rgba(229, 9, 20, 0.1);
}

.search-suggestion:last-child {
  border-bottom: none;
}

.search-suggestion img {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.search-suggestion-content {
  flex: 1;
  min-width: 0;
}

.search-suggestion-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggestion-meta {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  display: flex;
  gap: 0.5rem;
}

.search-suggestion-type {
  background: rgba(229, 9, 20, 0.2);
  color: #e50914;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
}

/* Profile */
.profile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.profile:hover {
  background: rgba(255,255,255,0.1);
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.profile-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: rgba(0,0,0,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  width: 12rem;
}

.dropdown-item {
  display: block;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: #fff;
  transition: all 0.2s ease;
  border-radius: 6px;
  margin: 0.25rem;
}

.dropdown-item:hover {
  background: rgba(229, 9, 20, 0.2);
  color: #e50914;
}

.dropdown-item.active {
  font-weight: 600;
  color: #e50914;
  background: rgba(229, 9, 20, 0.1);
}

/* ========== MAIN CONTENT ========== */
.main-content {
  flex-grow: 1;
  padding-top: 4rem;
}

/* Section titles */
.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-top: 5rem;
  color: #fff;
  position: relative;
}

.section-title:hover {
  color: #e50914;
  cursor: pointer;
}

/* ========== BANNER ========== */
.banner {
  position: relative;
  width: 100%;
  height: 70vh;
  display: flex;
  align-items: flex-end;
  padding: 4rem 2rem;
  box-sizing: border-box;
  overflow: hidden;
}

.banner-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom, 
    rgba(0,0,0,0.1) 0%, 
    rgba(0,0,0,0.3) 40%, 
    rgba(0,0,0,0.8) 80%, 
    rgba(0,0,0,0.95) 100%
  );
  z-index: 1;
}

.banner-content {
  position: relative;
  z-index: 2;
  max-width: 600px;
}

.banner-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.1;
}

.banner-overview {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.9);
  max-width: 500px;
}

.banner-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-light {
  background: #fff;
  color: #000;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(255,255,255,0.2);
}

.btn-light:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255,255,255,0.3);
}

.btn-dark {
  background: rgba(109, 109, 110, 0.7);
  color: #fff;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-weight: 600;
}

.btn-dark:hover {
  background: rgba(109, 109, 110, 0.9);
  transform: translateY(-1px);
}

/* ========== ROWS (horizontal scrolling) ========== */
.rows {
  padding: 2rem 0;
}

.row {
  margin-bottom: 3rem;
}

.row-scroll {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 0 2rem 1rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.row-scroll::-webkit-scrollbar {
  display: none;
}

.card {
  flex: 0 0 auto;
  width: 200px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@media (min-width: 768px) {
  .card {
    width: 280px;
    height: 160px;
  }
}

.card:hover {
  transform: scale(1.05) translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 10;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card:hover img {
  transform: scale(1.1);
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  opacity: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  transition: opacity 0.3s ease;
  padding: 1rem;
}

.card:hover .card-overlay {
  opacity: 1;
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.card-buttons {
  display: flex;
  gap: 0.5rem;
}

.card-buttons .btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* ========== PAGE TITLES ========== */
.page-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 2rem 2rem 1rem;
  color: #fff;
}

/* ========== LOADER ========== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50vh;
}

.loader::after {
  content: "";
  width: 3rem;
  height: 3rem;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: #e50914;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== FLEX LAYOUTS (replacing grid) ========== */
.movie-grid,
.tv-grid,
.search-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0 2rem;
  justify-content: flex-start;
}

.movie-grid .card,
.tv-grid .card,
.search-grid .card {
  flex: 0 0 auto;
  width: calc(50% - 0.75rem);
}

@media (min-width: 480px) {
  .movie-grid .card,
  .tv-grid .card,
  .search-grid .card {
    width: calc(33.333% - 1rem);
  }
}

@media (min-width: 768px) {
  .movie-grid .card,
  .tv-grid .card,
  .search-grid .card {
    width: calc(25% - 1.125rem);
  }
}

@media (min-width: 1024px) {
  .movie-grid .card,
  .tv-grid .card,
  .search-grid .card {
    width: calc(20% - 1.2rem);
  }
}

@media (min-width: 1200px) {
  .movie-grid .card,
  .tv-grid .card,
  .search-grid .card {
    width: calc(16.666% - 1.25rem);
  }
}

/* ========== CARD VARIANTS ========== */
.movie-grid .card,
.tv-grid .card,
.search-grid .card {
  height: 240px;
  border-radius: 12px;
}

.card-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  border-radius: 0 0 12px 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.card-subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
}

/* ========== DETAIL VIEW ========== */
.detail-view {
  position: relative;
  min-height: 100vh;
  padding-top: 4rem;
}

.detail-banner {
  position: relative;
  height: 70vh;
  overflow: hidden;
}

.detail-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.95), transparent 60%);
}

.detail-content {
  position: relative;
  margin-top: -12rem;
  padding: 0 2rem 4rem;
  z-index: 2;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.detail-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.1;
}

.detail-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.detail-meta .match {
  color: #46d369;
  font-weight: 600;
}

.detail-meta span {
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(255,255,255,0.4);
  font-size: 0.75rem;
  border-radius: 4px;
}

.detail-buttons {
  display: flex;
  gap: 1rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.detail-overview {
  max-width: 700px;
  margin-top: 2rem;
  line-height: 1.6;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.9);
}

.cast-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 2rem;
}

.cast-grid > div {
  flex: 0 0 auto;
  width: calc(50% - 0.75rem);
  text-align: center;
}

@media (min-width: 480px) {
  .cast-grid > div {
    width: calc(33.333% - 1rem);
  }
}

@media (min-width: 768px) {
  .cast-grid > div {
    width: calc(25% - 1.125rem);
  }
}

@media (min-width: 1024px) {
  .cast-grid > div {
    width: calc(16.666% - 1.25rem);
  }
}

.cast-grid img {
  border-radius: 12px;
  width: 100%;
  height: 0;
  position: relative;
  object-fit: cover;
}

/* Fix for the padding hack */
.cast-grid > div {
  position: relative;
}

.cast-grid img {
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.actor-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.actor-role {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  margin-top: 0.25rem;
  margin-bottom: 5rem;
}

/* ========== WATCH VIEW ========== */
.watch-view {
  min-height: 100vh;
  background: #000;
  padding-top: 4rem;
}

.watch-title {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  margin: 2rem 0;
  color: #fff;
}

.watch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0 2rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.watch-frame {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  flex: 1 1 100%;
  min-width: 300px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

@media (min-width: 768px) {
  .watch-frame {
    flex: 1 1 calc(50% - 0.75rem);
  }
}

.watch-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

.watch-error, .watch-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  border-radius: 12px;
}

.watch-error p {
  color: #e50914;
  font-weight: 600;
  font-size: 1.1rem;
}

/* ========== SEARCH + MY LIST ========== */
.search-title,
.mylist-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 2rem 2rem 1.5rem;
  color: #fff;
}

.no-results,
.empty-list {
  text-align: center;
  padding: 4rem 2rem;
  font-size: 1.2rem;
  color: rgba(255,255,255,0.6);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.5;
}

.card-hover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  opacity: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1rem;
  transition: opacity 0.3s ease;
  border-radius: 12px;
}

.card:hover .card-hover-overlay {
  opacity: 1;
}

.card-hover-buttons {
  display: flex;
  gap: 0.5rem;
}

.card-hover-buttons .btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* ========== FOOTER ========== */
.footer {
  background: linear-gradient(to top, #000, #111);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 3rem 2rem;
  text-align: center;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1200px;
  margin: auto;
}

.footer-text {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.footer-link {
  color: #e50914;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: #b20710;
  text-decoration: underline;
}

.footer-copy {
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
}

/* ========== RESPONSIVE IMPROVEMENTS ========== */
@media (max-width: 767px) {
  .navbar-content {
    padding: 1rem;
  }
  
  .banner {
    height: 60vh;
    padding: 2rem 1rem;
  }
  
  .banner-title {
    font-size: 2rem;
  }
  
  .banner-overview {
    font-size: 1rem;
  }
  
  .banner-actions {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .btn-light,
  .btn-dark {
    padding: 0.6rem 1.5rem;
  }
  
  .search-input {
    width: 12rem;
  }
  
  .page-title {
    font-size: 2rem;
    margin: 1.5rem 1rem 1rem;
  }
  
  .section-title {
    font-size: 1.2rem;
  }
  
  .row-scroll {
    padding: 0 1rem 1rem;
  }
  
  .movie-grid,
  .tv-grid,
  .search-grid {
    padding: 0 1rem;
  }
  
  .detail-content {
    padding: 0 1rem 4rem;
    margin-top: -8rem;
  }
  
  .watch-grid {
    padding: 0 1rem 2rem;
  }
  
  /* Fix cast grid spacing on mobile */
  .cast-grid img {
    margin-bottom: 0.5rem;
  }
  
  .actor-name {
    margin-top: 0.5rem;
  }
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.5s ease-out;
}

/* ========== ACCESSIBILITY ========== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
button:focus,
a:focus,
input:focus {
  outline: 2px solid #e50914;
  outline-offset: 2px;
}

/* ========== ANDROID 9 COMPATIBILITY FIXES ========== */

/* Remove modern CSS features that might not be supported */
.search-form,
.dropdown,
.btn-dark {
  /* Fallback for backdrop-filter */
  background: rgba(0,0,0,0.9);
}

/* Ensure proper flexbox support */
.navbar-content,
.banner-actions,
.detail-buttons,
.card-actions,
.card-buttons,
.card-hover-buttons,
.search-suggestion,
.cast-grid,
.movie-grid,
.tv-grid,
.search-grid {
  display: -webkit-flex;
  display: flex;
}

.navbar-content {
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
}

.banner-actions,
.detail-buttons {
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

.movie-grid,
.tv-grid,
.search-grid {
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-justify-content: flex-start;
  justify-content: flex-start;
}

/* Ensure transitions work on older browsers */
.card,
.btn,
.nav-link,
.search-btn,
.search-toggle,
.profile {
  -webkit-transition: all 0.2s ease;
  -moz-transition: all 0.2s ease;
  -o-transition: all 0.2s ease;
  transition: all 0.2s ease;
}

.navbar {
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
}

/* Ensure transforms work */
.card:hover {
  -webkit-transform: scale(1.05) translateY(-4px);
  -moz-transform: scale(1.05) translateY(-4px);
  -ms-transform: scale(1.05) translateY(-4px);
  -o-transform: scale(1.05) translateY(-4px);
  transform: scale(1.05) translateY(-4px);
}

.card:hover img {
  -webkit-transform: scale(1.1);
  -moz-transform: scale(1.1);
  -ms-transform: scale(1.1);
  -o-transform: scale(1.1);
  transform: scale(1.1);
}

.btn-primary:hover,
.btn-light:hover {
  -webkit-transform: translateY(-1px);
  -moz-transform: translateY(-1px);
  -ms-transform: translateY(-1px);
  -o-transform: translateY(-1px);
  transform: translateY(-1px);
}

/* Ensure border-radius works */
.card,
.btn,
.search-form,
.search-input,
.dropdown,
.profile-avatar {
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  border-radius: 8px;
}

.cast-grid img,
.watch-frame,
.watch-frame iframe {
  -webkit-border-radius: 12px;
  -moz-border-radius: 12px;
  border-radius: 12px;
}

.card-buttons .btn {
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;
}