/* ═══════════════════════════════════════════════════════════
   FrancyFlix — Private Streaming Library
   Dark-first cinematic UI
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --surface-3: #222;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-muted: #999;
  --text-faint: #666;
  --accent: #e50914;
  --accent-hover: #ff1a25;
  --accent-glow: rgba(229, 9, 20, 0.3);
  --font: 'General Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 6px;
  --radius-lg: 10px;
  --transition: 200ms ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

::selection {
  background: var(--accent);
  color: #fff;
}

/* === Hidden attribute support === */
[hidden] { display: none !important; }

/* === Login Screen === */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 1000;
}

.login-box {
  text-align: center;
  padding: 48px 40px;
  max-width: 380px;
  width: 100%;
}

.login-logo {
  height: 48px;
  width: auto;
  margin-bottom: 8px;
  object-fit: contain;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.input-group {
  display: flex;
  gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}

.input-group:focus-within {
  border-color: var(--accent);
}

#password-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 16px;
  font-size: 15px;
  outline: none;
  color: var(--text);
}

#password-input::placeholder {
  color: var(--text-faint);
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  transition: background var(--transition);
}

.login-btn:hover {
  background: var(--accent-hover);
}

.login-error {
  color: var(--accent);
  font-size: 13px;
  margin-top: 12px;
}

/* === Header === */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4%;
  height: 56px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, transparent 100%);
  transition: background 300ms ease;
}

.header.scrolled {
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.header-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

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

.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color var(--transition);
}

.search-toggle:hover {
  color: #fff;
}

.search-input {
  width: 0;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: width 300ms ease, padding 300ms ease, background 300ms ease, border-color 300ms ease;
}

.search-input.expanded {
  width: 220px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-color: var(--border);
}

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

.upload-btn,
.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.upload-btn:hover,
.logout-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* === Hero Section === */
.hero-section {
  position: relative;
  width: 100%;
  height: 75vh;
  min-height: 480px;
  max-height: 720px;
  overflow: hidden;
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  transition: opacity 600ms ease;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(10,10,10,0.9) 0%, rgba(10,10,10,0.4) 50%, transparent 100%),
    linear-gradient(to top, var(--bg) 0%, transparent 40%);
}

.hero-content {
  position: absolute;
  bottom: 15%;
  left: 4%;
  max-width: 520px;
  z-index: 2;
}

.hero-title {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.hero-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-meta .tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-description {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-actions {
  display: flex;
  gap: 10px;
}

.btn-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn-play:hover {
  background: var(--accent-hover);
  transform: scale(1.03);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
  transition: background var(--transition);
}

.btn-info:hover {
  background: rgba(255,255,255,0.2);
}

/* === Content Rows === */
.content-area {
  position: relative;
  z-index: 2;
  margin-top: -60px;
  padding-bottom: 80px;
}

.content-row {
  margin-bottom: 32px;
}

.row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4%;
  margin-bottom: 12px;
}

.row-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.row-scroll {
  display: flex;
  gap: 10px;
  padding: 0 4%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

/* === Media Card === */
.media-card {
  flex-shrink: 0;
  width: 200px;
  scroll-snap-align: start;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: transform 300ms ease, box-shadow 300ms ease;
}

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

.card-poster {
  aspect-ratio: 2/3;
  width: 100%;
  background: var(--surface-2);
  object-fit: cover;
  display: block;
}

.card-poster-placeholder {
  aspect-ratio: 2/3;
  width: 100%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.25);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 16px;
}

.card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 10px 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 200ms ease;
}

.media-card:hover .card-info {
  opacity: 1;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.card-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* watch progress bar */
.card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255,255,255,0.15);
}

.card-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 300ms ease;
}

/* === Player Overlay === */
.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.player-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  transition: background var(--transition);
}

.player-close:hover {
  background: rgba(255,255,255,0.2);
}

.video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
  z-index: 5;
}

.player-error svg {
  color: var(--accent);
  opacity: 0.8;
}

.player-error p {
  max-width: 460px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

.skip-intro {
  position: absolute;
  bottom: 80px;
  right: 40px;
  padding: 8px 24px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s, border-color 0.2s;
}

.skip-intro:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.6);
}

/* === Detail Modal === */
.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.detail-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  transition: background var(--transition);
}

.detail-close:hover {
  background: rgba(255,255,255,0.2);
}

.detail-hero {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
  position: relative;
}

.detail-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to top, var(--surface) 0%, transparent 100%);
}

.detail-body {
  padding: 20px 28px 28px;
}

.detail-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.detail-meta .tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-description {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 20px;
}

.detail-play-btn {
  margin-bottom: 12px;
}

.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.btn-delete:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(229, 9, 20, 0.08);
}

/* Episodes list */
.detail-episodes {
  margin-bottom: 20px;
}

.episodes-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.episode-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.episode-item:hover {
  background: rgba(255,255,255,0.05);
}

.episode-still {
  width: 130px;
  height: 73px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.episode-still-placeholder {
  width: 130px;
  height: 73px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-faint);
}

.episode-num {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-faint);
  min-width: 28px;
  text-align: center;
}

.episode-info {
  flex: 1;
}

.episode-name {
  font-size: 14px;
  font-weight: 500;
}

.episode-duration {
  font-size: 12px;
  color: var(--text-faint);
}

.episode-play {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 50%;
  border: 1px solid var(--border);
  transition: color var(--transition), border-color var(--transition);
}

.episode-item:hover .episode-play {
  color: #fff;
  border-color: #fff;
}

/* === Upload Modal === */
.upload-modal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.upload-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.upload-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.upload-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 50%;
  transition: color var(--transition);
}

.upload-close-btn:hover {
  color: #fff;
}

.upload-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-muted);
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--accent);
  background: rgba(229, 9, 20, 0.04);
}

.file-drop svg {
  margin: 0 auto 8px;
}

.file-drop p {
  font-size: 14px;
}

.file-drop-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

.file-name {
  font-size: 13px;
  color: var(--accent);
}

.upload-progress-container {
  margin-top: 4px;
}

.upload-progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 200ms ease;
}

.upload-progress-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.upload-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* === Empty State === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.empty-state svg {
  color: var(--text-faint);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  max-width: 320px;
}

/* === Footer === */
.footer {
  padding: 24px 4%;
  text-align: center;
}

.footer a {
  font-size: 12px;
  color: var(--text-faint);
  text-decoration: none;
  transition: color var(--transition);
}

.footer a:hover {
  color: var(--text-muted);
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* === Skeleton Loading === */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

/* === Responsive === */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
    height: 48px;
  }

  .nav-links { display: none; }

  .header-logo {
    height: 20px;
    width: auto;
  }

  .hero-section {
    height: 60vh;
    min-height: 400px;
  }

  .hero-content {
    left: 16px;
    right: 16px;
    bottom: 14%;
  }

  .hero-title {
    font-size: 24px;
  }

  .media-card {
    width: 140px;
  }

  .row-scroll {
    padding: 0 16px;
    gap: 8px;
  }

  .row-header {
    padding: 0 16px;
  }

  .detail-modal,
  .upload-modal {
    padding: 0;
  }

  .detail-content,
  .upload-content {
    max-height: 100vh;
    border-radius: 0;
    height: 100%;
  }

  .upload-content {
    padding: 20px;
  }

  .search-input.expanded {
    width: 160px;
  }
}

@media (min-width: 1400px) {
  .media-card {
    width: 220px;
  }
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.app {
  animation: fadeIn 400ms ease;
}

.detail-content {
  animation: slideUp 300ms ease;
}

.upload-content {
  animation: slideUp 300ms ease;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}
