/* Color System & Theme Variables */
:root {
  --bg-primary: #141414;
  --bg-surface: #1f1f1f;
  --bg-card: #272727;
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --accent-color: #e50914;
  --accent-hover: #f40612;
  --border-color: #333333;
  --nav-bg: rgba(20, 20, 20, 0.98);
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-surface: #ffffff;
  --bg-card: #e5e5ea;
  --text-primary: #1c1c1e;
  --text-secondary: #636366;
  --accent-color: #e50914;
  --accent-hover: #b80710;
  --border-color: #d1d1d6;
  --nav-bg: rgba(255, 255, 255, 0.98);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* 2-Row Navbar */
.navbar {
  display: flex;
  flex-direction: column;
  background-color: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1.5rem;
  width: 100%;
}

.bottom-row {
  border-top: 1px solid var(--border-color);
  padding: 0.4rem 1.5rem;
  background-color: rgba(128, 128, 128, 0.05);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-brand {
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--accent-color);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-link {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.2s, color 0.2s;
}

.nav-link:hover, .nav-link.active {
  background-color: rgba(128, 128, 128, 0.2);
}

/* Dropdown Menu & Categories */
.menu-dropdown-container {
  position: relative;
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
  min-width: 250px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 1100;
}

.menu-dropdown.show {
  display: block;
}

.menu-item-link, .menu-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  border-radius: 6px;
  transition: background-color 0.2s;
  cursor: pointer;
}

.menu-item-link:hover, .menu-item-row:hover {
  background-color: rgba(128, 128, 128, 0.15);
}

.menu-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 6px 0;
}

.category-trigger {
  font-weight: 600;
}

.menu-category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px 12px 12px 12px;
}

.menu-category-grid a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.menu-category-grid a:hover {
  background-color: rgba(128, 128, 128, 0.2);
}

/* 18+ Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  margin: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #555;
  transition: .3s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px; 
  width: 14px;
  left: 3px; 
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent-color);
}

input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* Search Box */
.search-box-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2px 8px 2px 14px;
}

.search-box-wrapper input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 150px;
  transition: width 0.2s ease;
}

.search-box-wrapper input:focus {
  width: 200px;
}

.nav-icon-btn, .theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  color: inherit;
}

.lang-switch select {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

/* Main Content & Shelves */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding-bottom: 4rem;
}

.home-category-section {
  margin: 2rem 1.5rem;
}

.category-header, .category-page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.category-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.more-link {
  font-size: 0.85rem;
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.more-link:hover {
  color: var(--accent-hover);
  transform: translateX(4px);
}

.back-home-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
}

.back-home-btn:hover {
  color: var(--text-primary);
}

/* Responsive Grid */
.movie-shelf-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

@media (min-width: 1300px) { .movie-shelf-grid { grid-template-columns: repeat(7, 1fr); } }
@media (min-width: 1024px) and (max-width: 1299px) { .movie-shelf-grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 768px) and (max-width: 1023px) { .movie-shelf-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 767px) {
  .movie-shelf-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}
@media (max-width: 480px) {
  .nav-row { padding: 0.6rem 0.8rem; }
  .bottom-row { padding: 0.4rem 0.8rem; }
  .nav-left, .nav-right { gap: 0.75rem; }
  .search-box-wrapper input { width: 100px; }
  .search-box-wrapper input:focus { width: 140px; }
  .movie-shelf-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .category-title { font-size: 1.1rem; }
}

/* Movie Card */
.movie-card {
  background-color: var(--bg-surface);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--border-color);
}

.movie-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.poster-wrapper {
  width: 100%;
  aspect-ratio: 2 / 3;
  background-color: var(--bg-card);
  overflow: hidden;
}

.poster-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-meta { padding: 8px; }
.movie-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.movie-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* Pagination */
.pagination-wrapper { text-align: center; margin: 2.5rem 0; }
.load-more-btn {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 10px 24px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.load-more-btn:hover { background-color: var(--accent-color); color: #fff; border-color: var(--accent-color); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-width: 600px;
  width: 100%;
  position: relative;
  overflow: hidden;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
  z-index: 10;
}
.modal-body { padding: 1.5rem; }
