/* ==================================================================
   قرية الأفلام — Theme
   ================================================================== */

:root {
  --bg: #141414;
  --bg-2: #1a1a1a;
  --bg-3: #232323;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --text: #ffffff;
  --text-muted: #a0a0a0;
  --text-faint: #666;
  --brand: #e50914;
  --brand-hover: #f6121d;
  --brand-soft: rgba(229, 9, 20, 0.18);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --radius: 8px;
  --radius-lg: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { min-height: 100vh; background: var(--bg); }

body {
  font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ============== Header ============== */
.header {
  background: linear-gradient(to bottom, rgba(0,0,0,0.85) 10%, rgba(0,0,0,0.6) 60%, transparent);
  padding: 14px 4%;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  font-family: 'Cairo', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02rem;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-icon { font-size: 1.4rem; }

.nav { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: color 0.2s;
}
.nav a:hover, .nav a.active { color: var(--text); }
.nav a.admin-link { color: var(--brand); }

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  flex: 1;
  max-width: 360px;
  margin-inline-start: auto;
}
.search-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
}
.search-wrap input::placeholder { color: var(--text-faint); }

.user-menu {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s;
}
.user-pill:hover { background: var(--surface-hover); }
.user-pill img,
.user-pill .user-initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-pill .user-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============== Buttons ============== */
.btn-primary {
  background: var(--brand);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.2s;
  display: inline-block;
}
.btn-primary:hover { background: var(--brand-hover); }

.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.2s;
  display: inline-block;
}
.btn-ghost:hover { background: rgba(255,255,255,0.15); }

.btn-block { display: block; width: 100%; text-align: center; padding: 12px; font-size: 14px; }

/* ============== Container & sections ============== */
.container {
  max-width: 1920px;
  margin: 0 auto;
  padding: 24px 4%;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 24px 0 16px;
  color: var(--text);
}

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

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty.error { color: #ffb3b8; }

/* ============== Movie grid ============== */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
}

.movie-card {
  background: var(--bg-2);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  display: block;
}
.movie-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 30px rgba(229,9,20,0.25);
  z-index: 5;
}

.movie-card .poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--bg-3);
  display: block;
}
.movie-card .info { padding: 10px 12px 14px; }
.movie-card .title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.movie-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.rating-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
}

.fav-btn {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  background: rgba(0,0,0,0.65);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 2;
}
.movie-card:hover .fav-btn,
.fav-btn.active { opacity: 1; }
.fav-btn.active { color: var(--brand); }
.fav-btn:hover { background: rgba(0,0,0,0.85); }

.continue-bar {
  position: absolute;
  inset-inline: 0;
  bottom: 56px;
  height: 4px;
  background: rgba(255,255,255,0.18);
}
.continue-bar > span { display: block; height: 100%; background: var(--brand); }

.episode-tag {
  color: var(--text-muted);
  font-size: 11px;
  margin-inline-start: 6px;
}

/* ============== Player page ============== */
.player-page {
  padding: 24px 4%;
  max-width: 1600px;
  margin: 0 auto;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  transition: background 0.2s;
}
.back-btn:hover { background: rgba(255,255,255,0.15); }

.movie-title { font-size: 2rem; font-weight: 700; margin-bottom: 6px; }
.movie-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; }

.video-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 80vh;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}
.video-container iframe,
.video-container video {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  outline: none;
}

.player-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0,0,0,0.85);
  color: var(--text);
  text-align: center;
  padding: 24px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--bg-3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  background: rgba(229,9,20,0.08);
  border: 1px solid rgba(229,9,20,0.4);
  padding: 18px 22px;
  border-radius: var(--radius);
  color: #ffb3b8;
  margin-top: 14px;
}

/* ============== Server picker ============== */
.player-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
  align-items: center;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--text); }
.chip-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-inline-end: 4px;
}

/* ============== Episodes ============== */
.episodes-wrap { margin: 24px 0; }
.season-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.episodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
}
.episode-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}
.episode-btn:hover { background: var(--surface-hover); }
.episode-btn.active { background: var(--brand); border-color: var(--brand); }

/* ============== Auth pages ============== */
.auth-wrap {
  min-height: calc(100vh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
}
.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.auth-card .lead {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.auth-card .field { margin-bottom: 14px; }
.auth-card label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.auth-card input[type=text],
.auth-card input[type=email],
.auth-card input[type=password],
.auth-card input[type=file] {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.auth-card input:focus { border-color: var(--brand); }
.auth-card .alt {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-card .alt a { color: var(--brand); font-weight: 600; }

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.flash.error { background: rgba(229,9,20,0.12); color: #ffb3b8; border: 1px solid rgba(229,9,20,0.3); }
.flash.success { background: rgba(40,180,80,0.12); color: #b3ffc3; border: 1px solid rgba(40,180,80,0.3); }

/* ============== Profile ============== */
.profile-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  margin-top: 12px;
}
@media (max-width: 720px) {
  .profile-grid { grid-template-columns: 1fr; }
}
.profile-side {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}
.avatar-big {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 14px;
  object-fit: cover;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: #fff;
}
.profile-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.profile-username { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }

/* ============== Footer ============== */
.footer {
  text-align: center;
  padding: 24px 4%;
  color: var(--text-faint);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.footer-inner { display: inline-flex; gap: 8px; align-items: center; }
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--brand); }

/* ============== Responsive ============== */
@media (max-width: 860px) {
  .header { flex-wrap: wrap; gap: 10px; }
  .search-wrap { order: 4; max-width: 100%; flex-basis: 100%; }
  .nav { gap: 12px; font-size: 13px; }
  .brand { font-size: 1.3rem; }
  .user-menu { margin-inline-start: auto; }
  .movie-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
  .movie-title { font-size: 1.4rem; }
}

/* ============== Utility ============== */
.hidden { display: none !important; }
.spaced > * + * { margin-top: 14px; }
