/* ==========================================================================
   Movie Database - Netflix Dark Theme
   ========================================================================== */

/* --- Custom Properties --- */
:root {
  --mdb-bg: #141414;
  --mdb-card: #1a1a1a;
  --mdb-surface: #2a2a2a;
  --mdb-accent: #e50914;
  --mdb-text: #e5e5e5;
  --mdb-text-secondary: #b3b3b3;
  --mdb-text-muted: #808080;
  --mdb-border: #404040;
  --mdb-radius: 4px;
}

/* --- Reset / Base --- */
*, *::before, *::after {
  box-sizing: border-box;
}

.movie-db-page {
  margin: 0;
  padding: 0;
  background-color: var(--mdb-bg);
  color: var(--mdb-text);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.movie-db-page img { max-width: 100%; display: block; }
.movie-db-page a { color: var(--mdb-text); text-decoration: none; }
.movie-db-page a:hover { color: var(--mdb-accent); }

/* --- Utility --- */
.hidden { display: none !important; }

/* --- Focus Accessibility --- */
.movie-db-page :focus-visible {
  outline: 2px solid var(--mdb-accent);
  outline-offset: 2px;
}

/* --- Header --- */
.movie-db-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 2rem;
  background: var(--mdb-card);
  border-bottom: 1px solid var(--mdb-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.movie-db-header nav { display: flex; gap: 1.5rem; }
.movie-db-header nav a {
  color: var(--mdb-text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
}
.movie-db-header nav a:hover { color: var(--mdb-text); }
.movie-db-header nav a.active { color: var(--mdb-accent); }

/* --- Controls Bar --- */
.mdb-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.mdb-search {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  background: var(--mdb-surface);
  border: 1px solid var(--mdb-border);
  border-radius: var(--mdb-radius);
  color: var(--mdb-text);
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}
.mdb-search::placeholder { color: var(--mdb-text-muted); }
.mdb-search:focus { border-color: var(--mdb-accent); outline: none; }

.mdb-view-toggle { display: flex; gap: 0; }
.mdb-view-toggle button {
  padding: 0.5rem 0.75rem;
  background: var(--mdb-surface);
  border: 1px solid var(--mdb-border);
  color: var(--mdb-text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.mdb-view-toggle button:first-child { border-radius: var(--mdb-radius) 0 0 var(--mdb-radius); }
.mdb-view-toggle button:last-child { border-radius: 0 var(--mdb-radius) var(--mdb-radius) 0; border-left: 0; }
.mdb-view-toggle button.active {
  background: var(--mdb-accent);
  border-color: var(--mdb-accent);
  color: #fff;
}

.mdb-count {
  color: var(--mdb-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* --- Genre Pills --- */
.mdb-genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.mdb-pill {
  padding: 0.3rem 0.75rem;
  background: var(--mdb-surface);
  border: 1px solid var(--mdb-border);
  border-radius: var(--mdb-radius);
  color: var(--mdb-text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.mdb-pill:hover { border-color: var(--mdb-text-muted); }
.mdb-pill.active {
  background: var(--mdb-accent);
  border-color: var(--mdb-accent);
  color: #fff;
}

/* --- Sort Controls --- */
.mdb-sort {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 0.5rem 0;
  color: var(--mdb-text-muted);
  font-size: 0.8rem;
}

.mdb-sort-option {
  cursor: pointer;
  transition: color 0.2s ease;
}
.mdb-sort-option:hover { color: var(--mdb-text-secondary); }
.mdb-sort-option.active { color: var(--mdb-accent); font-weight: 600; }

/* --- Filter Chips --- */
.mdb-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.mdb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  background: var(--mdb-surface);
  border: 1px solid var(--mdb-border);
  border-radius: var(--mdb-radius);
  color: var(--mdb-text-secondary);
  font-size: 0.8rem;
}

.mdb-chip button {
  background: none;
  border: none;
  color: var(--mdb-text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: color 0.2s ease;
}
.mdb-chip button:hover { color: var(--mdb-accent); }

/* ==========================================================================
   Catalogue Page
   ========================================================================== */
/* --- Content Container --- */
.mdb-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem 2rem;
}

.movie-db-catalogue {}

/* --- Grid View --- */
.mdb-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.6rem;
}

.mdb-card {
  position: relative;
  background: var(--mdb-card);
  border-radius: var(--mdb-radius);
  overflow: hidden;
  transition: transform 0.2s ease, brightness 0.2s ease;
  cursor: pointer;
}
.mdb-card:hover {
  transform: scale(1.03);
  filter: brightness(1.15);
}

.mdb-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.mdb-card-info { padding: 0.5rem; }

.mdb-card-title {
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mdb-card-actors {
  color: var(--mdb-text-muted);
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.mdb-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--mdb-text-muted);
  margin-top: 0.25rem;
}

.mdb-card-meta .dvd-code {
  color: var(--mdb-accent);
  font-family: 'Courier New', Courier, monospace;
  font-weight: 600;
}

/* --- Table View --- */
.mdb-table tbody tr {
  cursor: pointer;
  transition: background 0.2s ease;
}
.mdb-table tbody tr:hover {
  background: var(--mdb-surface);
}

.mdb-table {
  width: 100%;
  border-collapse: collapse;
}

.mdb-table th {
  text-align: left;
  color: var(--mdb-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--mdb-border);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}
.mdb-table th:hover { color: var(--mdb-text-secondary); }

.mdb-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(64, 64, 64, 0.4);
  font-size: 0.85rem;
}

.mdb-table tr:nth-child(even) { background: var(--mdb-card); }

.mdb-table .clickable {
  cursor: pointer;
  transition: color 0.2s ease;
}
.mdb-table .clickable:hover { color: var(--mdb-accent); text-decoration: underline; }

.mdb-table .rating {
  color: var(--mdb-accent);
  font-weight: 700;
}

/* Hide mobile-only elements on desktop */
.mdb-table-mobile-list { display: none; }
.mdb-discovery-scroll { display: none; }

/* ==========================================================================
   Discovery Page
   ========================================================================== */
.movie-db-discovery {
  text-align: center;
}

.mdb-discovery-header {
  padding: 1rem 0 0.75rem;
}
.mdb-discovery-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.movie-db-discovery .mdb-genre-pills {
  margin-bottom: 1.5rem;
}

.mdb-discovery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.mdb-reroll-btn {
  display: inline-block;
  padding: 0.7rem 2rem;
  background: var(--mdb-accent);
  color: #fff;
  border: none;
  border-radius: var(--mdb-radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s ease;
}
.mdb-reroll-btn:hover { filter: brightness(1.2); }

/* ==========================================================================
   Detail Page
   ========================================================================== */
.movie-db-detail {}
.movie-db-detail .mdb-container { max-width: 1100px; }

/* Hero */
.mdb-hero {
  position: relative;
  display: flex;
  gap: 2rem;
  align-items: flex-end;
  min-height: 450px;
  padding: 2rem;
  background-size: cover;
  background-position: center;
}
.mdb-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--mdb-bg) 0%, rgba(20, 20, 20, 0.6) 50%, rgba(20, 20, 20, 0.3) 100%);
}

.mdb-hero-poster {
  position: relative;
  width: 200px;
  flex-shrink: 0;
  border-radius: var(--mdb-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.mdb-hero-poster img { width: 100%; display: block; }

.mdb-hero-info {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.mdb-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

.mdb-original-title {
  color: var(--mdb-text-muted);
  font-size: 1rem;
  font-style: italic;
}

.mdb-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.mdb-meta .rating {
  color: var(--mdb-accent);
  font-size: inherit;
  font-weight: 700;
}
.mdb-meta .year,
.mdb-meta .runtime { color: var(--mdb-text-secondary); }
.mdb-stars {
  color: var(--mdb-accent);
  letter-spacing: 1px;
  font-size: 1.1em;
}

.mdb-meta .dvd-badge {
  background: var(--mdb-surface);
  color: var(--mdb-accent);
  font-family: 'Courier New', Courier, monospace;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--mdb-radius);
  font-size: 0.8rem;
}

.mdb-genre-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--mdb-surface);
  border: 1px solid var(--mdb-border);
  border-radius: var(--mdb-radius);
  color: var(--mdb-text-secondary);
  font-size: 0.75rem;
  margin-right: 0.3rem;
}

/* Action Buttons */
.mdb-action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.mdb-btn-primary {
  padding: 0.6rem 1.5rem;
  background: var(--mdb-accent);
  color: #fff;
  border: none;
  border-radius: var(--mdb-radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease;
}
.mdb-btn-primary:hover { filter: brightness(1.2); }

.mdb-btn-secondary {
  padding: 0.6rem 1.5rem;
  background: var(--mdb-surface);
  color: var(--mdb-text-muted);
  border: 1px solid var(--mdb-border);
  border-radius: var(--mdb-radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.mdb-btn-secondary:hover {
  border-color: var(--mdb-text-muted);
  color: var(--mdb-text);
}

/* Content Sections */
.mdb-content-section {
  padding: 1.5rem 2rem;
  max-width: 900px;
}

.mdb-description {
  color: var(--mdb-text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
}

.mdb-tag {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  background: var(--mdb-surface);
  border: 1px solid var(--mdb-border);
  border-radius: var(--mdb-radius);
  color: var(--mdb-text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  margin: 0.2rem;
  transition: all 0.2s ease;
}
.mdb-tag:hover {
  border-color: var(--mdb-accent);
  color: var(--mdb-text);
}

/* Watch History */
.mdb-watch-history {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mdb-watch-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(64, 64, 64, 0.4);
  color: var(--mdb-text-secondary);
  font-size: 0.85rem;
}
.mdb-watch-history li button {
  background: none;
  border: none;
  color: var(--mdb-text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: color 0.2s ease;
}
.mdb-watch-history li button:hover { color: var(--mdb-accent); }

.mdb-back-link {
  display: block;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--mdb-border);
  color: var(--mdb-text-muted);
  font-size: 0.85rem;
  transition: color 0.2s ease;
}
.mdb-back-link:hover { color: var(--mdb-text); }

/* --- Correction Panel --- */
.mdb-correction-panel {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--mdb-border);
  background: var(--mdb-card);
  border-radius: var(--mdb-radius);
  margin: 1rem 0;
}
.mdb-correction-panel h2 {
  font-size: 1rem;
  margin: 0 0 1rem 0;
}
.mdb-correction-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.mdb-correction-search .mdb-search { flex: 1; }
.mdb-correct-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.mdb-correct-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--mdb-surface);
  border: 1px solid var(--mdb-border);
  border-radius: var(--mdb-radius);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.mdb-correct-card:hover { border-color: var(--mdb-accent); }
.mdb-correct-card img {
  width: 46px;
  height: 69px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}
.mdb-correct-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: hidden;
}
.mdb-correct-card-info strong {
  font-size: 0.85rem;
  color: var(--mdb-text);
}
.mdb-correct-card-info span {
  font-size: 0.75rem;
  color: var(--mdb-text-muted);
  line-height: 1.3;
}

/* ==========================================================================
   Watchlist Toggle on Cards
   ========================================================================== */
.mdb-watchlist-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  border: none;
  color: var(--mdb-text-muted);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2;
  opacity: 0;
}
.mdb-card:hover .mdb-watchlist-toggle,
.mdb-watchlist-toggle.active { opacity: 1; }
.mdb-watchlist-toggle.active { color: var(--mdb-accent); }
.mdb-watchlist-toggle:hover { color: var(--mdb-accent); opacity: 1; }

/* Detail page watchlist button active state */
.mdb-btn-watchlist-active {
  color: var(--mdb-accent) !important;
  border-color: var(--mdb-accent) !important;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.movie-db-footer {
  text-align: center;
  padding: 1rem 2rem;
  border-top: 1px solid var(--mdb-border);
  color: var(--mdb-text-muted);
  font-size: 0.75rem;
}

/* ==========================================================================
   Responsive - Tablet (768-1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .mdb-grid { grid-template-columns: repeat(4, 1fr); }
  .mdb-discovery-grid { grid-template-columns: repeat(2, 1fr); }

  .mdb-hero { min-height: 380px; padding: 1.5rem; }
  .mdb-title { font-size: 1.8rem; }

  .mdb-container { padding: 1rem 1.5rem 2rem; }
}

/* ==========================================================================
   Responsive - Mobile (<768px)
   ========================================================================== */
@media (max-width: 767px) {
  .movie-db-header { padding: 0.6rem 1rem; }
  .movie-db-header nav { gap: 1rem; }
  .movie-db-header nav a { font-size: 0.8rem; }

  .mdb-container { padding: 0.75rem 1rem 1.5rem; }

  .mdb-controls { flex-direction: column; align-items: stretch; }
  .mdb-search { width: 100%; min-width: 0; }

  .mdb-grid { grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
  .mdb-card-title { font-size: 0.7rem; }
  .mdb-card-meta { font-size: 0.6rem; }

  /* Table -> mobile cards */
  .mdb-table,
  .mdb-table thead { display: none; }
  .mdb-table-mobile-list { display: block; }

  .mdb-table-mobile-card {
    cursor: pointer;
    background: var(--mdb-card);
    border-radius: var(--mdb-radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--mdb-border);
  }

  /* Discovery mobile scroll */
  .mdb-discovery-grid { display: none; }
  .mdb-discovery-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
  }
  .mdb-discovery-scroll > * {
    flex: 0 0 70%;
    scroll-snap-align: start;
  }
  .mdb-discovery-scroll::-webkit-scrollbar { height: 4px; }
  .mdb-discovery-scroll::-webkit-scrollbar-track { background: var(--mdb-surface); }
  .mdb-discovery-scroll::-webkit-scrollbar-thumb { background: var(--mdb-border); border-radius: 2px; }

  /* Detail page mobile */
  .mdb-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: auto;
    padding: 0;
  }
  .mdb-hero-poster {
    width: 100%;
    border-radius: 0;
  }
  .mdb-hero-poster img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
  }
  .mdb-hero-info {
    padding: 1rem;
    align-items: center;
  }
  .mdb-title { font-size: 1.5rem; }
  .mdb-meta { justify-content: center; }

  .mdb-action-buttons {
    flex-direction: column;
    width: 100%;
  }
  .mdb-btn-primary { width: 100%; text-align: center; }
  .mdb-action-buttons .mdb-btn-secondary { flex: 1; text-align: center; }

  .mdb-content-section { padding: 1rem; }
  .mdb-back-link { padding: 1rem; }

  .movie-db-discovery { padding: 1rem; }
  .mdb-discovery-header h1 { font-size: 1.4rem; }
}
