/* ============================================
   FILM FUSION - Design System
   Modern, Premium, Accessible UI
   ============================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");

/* ============================================
   CSS Variables / Design Tokens
   ============================================ */
:root {
  /* Colors - Dark Theme */
  --bg-primary: #0b1015;
  --bg-secondary: #12191f;
  --bg-card: #1a2330;
  --bg-elevated: #222d3a;
  --bg-hover: #2a3744;

  /* Accent Colors */
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: rgba(16, 185, 129, 0.15);
  --accent-glow: rgba(16, 185, 129, 0.4);

  /* Text Colors */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  /* Status Colors */
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.6);

  /* Typography */
  --font: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  /* Spacing (8px grid) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-fast: 150ms ease;
  --ease-normal: 250ms ease;
  --ease-slow: 350ms ease;

  /* Z-Index */
  --z-dropdown: 50;
  --z-header: 100;
  --z-modal: 200;
  --z-toast: 300;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-secondary);
  transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

::-webkit-scrollbar-corner {
  background: var(--bg-secondary);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) var(--bg-secondary);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

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

ul,
ol {
  list-style: none;
}

/* Focus states */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: var(--accent);
  color: var(--bg-primary);
}

/* ============================================
   Header & Navigation
   ============================================ */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  z-index: var(--z-header);
  flex-shrink: 0;
  background: linear-gradient(
    180deg,
    var(--bg-secondary) 0%,
    rgba(18, 25, 31, 0.95) 100%
  );
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

nav {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

/* Logo */
.logo a {
  display: flex;
  align-items: center;
}

.logo img {
  height: 44px;
  width: auto;
  transition: opacity var(--ease-fast);
}

.logo:hover img {
  opacity: 0.85;
}

/* Nav Links */
.nav-links {
  display: flex;
  gap: var(--sp-1);
  margin-left: auto;
}

.nav-links a {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--ease-fast);
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-light);
}

/* Search */
.search-box {
  display: flex;
  flex: 1;
  max-width: 360px;
}

.search-box input {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  outline: none;
  transition: all var(--ease-fast);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.search-box button {
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--bg-primary);
  background: var(--accent);
  border: none;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transition: background var(--ease-fast);
}

.search-box button:hover {
  background: var(--accent-hover);
}

/* Profile */
.profile-btn img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  transition: border-color var(--ease-fast);
}

.profile-btn:hover img {
  border-color: var(--accent);
}

/* Mobile Menu */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: var(--sp-2);
  background: none;
  border: none;
}

.menu-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--ease-normal);
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-name {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  min-width: 160px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.user-menu:hover .dropdown {
  display: block;
}

.dropdown a {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: all var(--ease-fast);
}

.dropdown a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ============================================
   Main Content
   ============================================ */
main {
  flex: 1;
  margin-top: 70px;
  padding-top: var(--sp-6);
  padding-bottom: var(--sp-16);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

/* Section Headers */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-10) auto var(--sp-6);
  padding: 0 var(--sp-6);
  max-width: 1400px;
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
}

.section-title::before {
  content: "";
  width: 4px;
  height: 28px;
  background: linear-gradient(180deg, var(--accent) 0%, #06b6d4 100%);
  border-radius: var(--radius-full);
}

.section-title a {
  transition: color var(--ease-fast);
}

.section-title a:hover {
  color: var(--accent);
}

/* ============================================
   Cards Grid
   ============================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-6);
  padding: 0 var(--sp-6);
  max-width: 1400px;
  margin: 0 auto;
  justify-items: center;
}

/* Card */
.card {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--ease-normal);
}

.card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg), 0 0 30px var(--accent-glow);
}

.card-poster {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
}

.card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all var(--ease-slow);
}

.card:hover .card-poster img {
  transform: scale(1.08);
  filter: brightness(0.35);
}

/* Card Overlay */
.card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  transition: opacity var(--ease-normal);
}

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

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* Watchlist Button */
.watchlist-btn {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: none;
  border-radius: var(--radius-full);
  z-index: 10;
  transition: all var(--ease-fast);
}

.watchlist-btn:hover {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.8);
}

.watchlist-btn.active .heart {
  color: var(--error);
}

.heart {
  color: var(--text-primary);
  transition: color var(--ease-fast);
}

/* Badge */
.badge {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  background: var(--accent);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   Loading & Error States
   ============================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16);
  gap: var(--sp-4);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Skeleton Loaders */
.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-poster {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-title {
  height: 16px;
  margin: var(--sp-3);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Button Spinner */
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  }
}

.loading p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-16);
  gap: var(--sp-4);
  text-align: center;
}

.error-state p {
  color: var(--error);
  font-size: var(--text-lg);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: none;
  transition: all var(--ease-fast);
}

.btn-primary {
  color: var(--bg-primary);
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-10) var(--sp-6);
}

.page-btn {
  padding: var(--sp-3) var(--sp-6);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--ease-fast);
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: var(--sp-5);
}

.form-group label {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: all var(--ease-fast);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input.error {
  border-color: var(--error);
}

.form-error {
  display: none;
  margin-top: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--error);
}

.form-error.show {
  display: block;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16);
  text-align: center;
}

.empty-state h3 {
  margin-bottom: var(--sp-2);
  font-size: var(--text-xl);
  color: var(--text-primary);
}

.empty-state p {
  margin-bottom: var(--sp-6);
  color: var(--text-muted);
}

/* ============================================
   Footer
   ============================================ */
footer {
  flex-shrink: 0;
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

footer p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-toast);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--sp-4);
  }
}

@media (max-width: 768px) {
  nav {
    padding: var(--sp-3) var(--sp-4);
  }

  .menu-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: var(--sp-4);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links a {
    padding: var(--sp-3) var(--sp-4);
  }

  .search-box {
    display: none;
  }

  main {
    padding-top: 64px;
  }

  .section-title {
    font-size: var(--text-xl);
    padding: 0 var(--sp-4);
    margin: var(--sp-8) 0 var(--sp-4);
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--sp-3);
    padding: 0 var(--sp-4);
  }

  .pagination {
    padding: var(--sp-8) var(--sp-4);
    gap: var(--sp-3);
  }
}

@media (max-width: 480px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card:hover {
    transform: translateY(-4px);
  }

  .page-btn {
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-xs);
  }
}
