/**
 * static/css/style.css
 * CineSwipe Core Design System & Theme Tokens.
 * Aesthetic: Ultra-clean Dark Matte UI with Signature Electric Blue Accent.
 * Inspired by: Vseti.app, Hirehi.ru, Mate.me.
 * Zero neon glow, crisp 1px hairline borders, high-legibility Plus Jakarta Sans & Inter.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Surface & Background Palette (Deep Matte Graphite & Charcoal) */
  --bg-base: #0d0f14;
  --bg-primary: #0d0f14;
  --bg-surface: #141720;
  --bg-surface-elevated: #1a1e2a;
  --bg-card: #181c26;
  --bg-card-hover: #202534;
  --bg-glass: rgba(20, 23, 32, 0.92);
  --bg-glass-strong: rgba(20, 23, 32, 0.98);
  --bg-input: #10121a;
  --bg-overlay: rgba(13, 15, 20, 0.88);
  --bg-chip: rgba(255, 255, 255, 0.05);
  --bg-chip-hover: rgba(255, 255, 255, 0.09);

  /* Border Tokens (Crisp 1px hairline borders) */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-default: rgba(255, 255, 255, 0.12);
  --border-hover: rgba(255, 255, 255, 0.20);
  --border-focus: #3b82f6;
  --border-color: rgba(255, 255, 255, 0.08);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);

  /* Typography Colors */
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;
  --text-inverse: #0d0f14;

  /* Single Signature Brand Accent (Electric Blue) */
  --accent-brand: #3b82f6;
  --accent-brand-hover: #2563eb;
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-like: #10b981;
  --accent-rose: #ef4444;
  --accent-dislike: #ef4444;
  --accent-amber: #f59e0b;
  --accent-undo: #f59e0b;
  --accent-purple: #8b5cf6;

  /* Typography Stack */
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Geometry & Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  --radius-card: 20px;
  --radius-btn: 12px;

  /* Restrained Elevation Shadows (ZERO Neon Glow) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
  --shadow-card: 0 20px 40px -10px rgba(0, 0, 0, 0.8);

  /* Animation Timings */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --transition-exit: 400ms cubic-bezier(0.25, 1, 0.5, 1);

  /* Layer Z-Indexes */
  --z-card-deck: 10;
  --z-header: 100;
  --z-drawer-backdrop: 150;
  --z-drawer: 160;
  --z-modal-backdrop: 200;
  --z-modal: 210;
  --z-toast: 300;
}

/* =============================================================================
   1. Modern Baseline & Global Styles
   ============================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  height: 100%;
}

body {
  min-height: 100%;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--accent-brand);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

a {
  color: var(--accent-brand);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: #60a5fa;
}

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-brand);
  background-color: #141722;
}

/* =============================================================================
   2. App Header & Navigation
   ============================================================================= */
.app-header, .header-bar, header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  width: 100%;
  height: 64px;
  background-color: var(--bg-glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.header-brand, .brand-wrap, .logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
}

.brand-icon-svg, .brand-icon {
  width: 24px;
  height: 24px;
  color: var(--accent-brand);
}

.header-nav, .nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.nav-link, .nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}
.nav-link:hover, .nav-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-chip);
}
.nav-link.active, .nav-btn.active {
  color: #ffffff;
  background-color: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.health-pill, .stat-pill, .user-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background-color: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
}
.health-dot.degraded {
  background: var(--accent-amber);
}
.health-dot.offline {
  background: var(--accent-rose);
}

/* =============================================================================
   3. Buttons & Component Badges
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--accent-brand);
  color: #ffffff;
  border: 1px solid var(--accent-brand);
}
.btn-primary:hover {
  background-color: var(--accent-brand-hover);
  border-color: var(--accent-brand-hover);
}

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

.btn-pill {
  border-radius: var(--radius-full);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background-color: var(--bg-chip);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--accent-rose);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.20);
}

/* Chip Badges & Genre Pills (Restrained Matte Slate) */
.badge, .genre-badge, .genre-chip, .tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.775rem;
  font-weight: 500;
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  color: #cbd5e1;
  line-height: 1.3;
  transition: all var(--transition-fast);
}
.genre-chip:hover, .tag-pill:hover {
  background: var(--bg-chip-hover);
  border-color: var(--border-hover);
}

.badge-cyan, .badge-blue {
  background-color: rgba(59, 130, 246, 0.12);
  color: var(--accent-brand);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-emerald {
  background-color: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-rose {
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--accent-rose);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-amber {
  background-color: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* IMDb Rating Badge (Restrained Matte Gold) */
.imdb-badge, .card-rating-badge.imdb-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.30);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.775rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Clamped Plot Overview */
.card-overview, .movie-overview {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #cbd5e1;
  margin-top: 8px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  word-break: break-word;
}

/* Social Friends Indicator */
.card-friends-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--accent-brand);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-top: 6px;
  width: fit-content;
}

/* =============================================================================
   4. Recommendations Slide-In Drawer & Panel
   ============================================================================= */
.drawer-backdrop, .recs-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer-backdrop);
  background-color: var(--bg-overlay);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.drawer-backdrop.active, .recs-drawer.open, .recs-drawer.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-drawer);
  width: 460px;
  max-width: 92vw;
  background-color: var(--bg-surface);
  border-left: var(--glass-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translate3d(100%, 0, 0);
  transition: transform var(--transition-spring);
}
.drawer.active, .drawer.open {
  transform: translate3d(0, 0, 0);
}

.recs-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-drawer);
  background-color: var(--bg-surface);
  border-top: var(--glass-border);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  transform: translate3d(0, 100%, 0);
  transition: transform var(--transition-spring);
  box-shadow: var(--shadow-lg);
}
.recs-drawer.open .recs-panel, .recs-drawer.active .recs-panel {
  transform: translate3d(0, 0, 0);
}

.drawer-header, .recs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: var(--glass-border);
  position: sticky;
  top: 0;
  background-color: var(--bg-surface);
  z-index: 5;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.recs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.rec-item-card, .rec-item {
  display: flex;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.rec-item-card:hover, .rec-item:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.rec-thumb, .rec-poster {
  width: 60px;
  height: 90px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background-color: var(--bg-base);
  border: 1px solid var(--border-subtle);
}

.rec-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.rec-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-meta {
  font-size: 0.775rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rec-match-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-emerald);
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  width: fit-content;
}

/* =============================================================================
   5. Toast Notification System
   ============================================================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  animation: toastFadeIn 250ms ease-out forwards;
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.toast-success {
  border-left: 4px solid var(--accent-emerald);
}
.toast-error {
  border-left: 4px solid var(--accent-rose);
}
.toast-info {
  border-left: 4px solid var(--accent-brand);
}