:root {
  --bg: #081120;
  --bg-2: #0f172a;
  --surface: #101a2d;
  --surface-2: #162338;
  --surface-3: #1c2b43;
  --surface-elevated: rgba(15, 23, 42, 0.84);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #e5eefb;
  --muted: #9db0c9;
  --primary: #60a5fa;
  --primary-2: #22d3ee;
  --primary-soft: rgba(96, 165, 250, 0.16);
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 24px 60px rgba(2, 8, 23, 0.45);
  --shadow-soft: 0 14px 36px rgba(2, 8, 23, 0.24);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

body.theme-light {
  --bg: #f3f6fb;
  --bg-2: #e8eef7;
  --surface: #ffffff;
  --surface-2: #f9fbff;
  --surface-3: #edf3fb;
  --surface-elevated: rgba(255, 255, 255, 0.94);
  --line: rgba(148, 163, 184, 0.24);
  --line-strong: rgba(148, 163, 184, 0.34);
  --text: #132238;
  --muted: #5b6d86;
  --primary: #2563eb;
  --primary-2: #38bdf8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 12px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}
body.theme-light {
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), transparent 34%),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 28%),
    linear-gradient(180deg, #eef4fb 0%, #f8fbff 100%);
}
body.lang-fa,
body.lang-fa input,
body.lang-fa textarea,
body.lang-fa select,
body.lang-fa button { font-family: Vazirmatn, Tahoma, Arial, sans-serif; }
body.lang-en,
body.lang-en input,
body.lang-en textarea,
body.lang-en select,
body.lang-en button { font-family: Inter, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.app-shell {
  min-height: 100vh;
  padding: 24px;
}
.page-frame {
  max-width: 1400px;
  margin: 0 auto;
}
.page-frame--login {
  max-width: 1240px;
  display: flex;
  align-items: center;
  min-height: calc(100vh - 48px);
}
.card {
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.portal-header {
  max-width: 1400px;
  margin: 0 auto 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(8, 17, 32, 0.54);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(18px);
}
body.theme-light .portal-header { background: rgba(255, 255, 255, 0.84); }
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow-soft);
}
.brand-logo--placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 1.2rem;
}
.brand-copy { display: grid; gap: 3px; }
.brand-title { font-size: 1rem; }
.brand-subtitle { font-size: 0.88rem; color: var(--muted); }
.portal-header__right,
.header-actions,
.header-switcher-group,
.toolbar-row,
.section-head,
.split-actions,
.streaming-hero,
.catalog-row__head,
.checkbox-row,
.upload-progress-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.portal-header__right { margin-inline-start: auto; flex-wrap: wrap; justify-content: flex-end; }
.header-user-pill,
.count-pill,
.badge,
.meta-tile,
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid rgba(96, 165, 250, 0.18);
  color: var(--text);
}
.header-user-pill { background: rgba(255,255,255,0.05); }
body.theme-light .header-user-pill { background: rgba(15, 23, 42, 0.04); }
.toolbar-switcher { display: grid; gap: 8px; }
.toolbar-switcher__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}
.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 6px;
  padding: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
}
body.theme-light .segmented-control { background: rgba(15, 23, 42, 0.04); }
.segmented-control--full { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented-control__item {
  text-align: center;
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 700;
}
.segmented-control__item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}
.btn-secondary {
  background: rgba(34, 211, 238, 0.12);
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.2);
}
.btn-ghost {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-color: var(--line);
}
body.theme-light .btn-ghost { background: rgba(15, 23, 42, 0.03); }
.btn-danger {
  background: rgba(251, 113, 133, 0.12);
  color: var(--danger);
  border-color: rgba(251, 113, 133, 0.24);
}
.btn-block { width: 100%; }
.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--primary-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hero-copy, .muted, .helper-text, .catalog-row__head p, .poster-card__body p,
.login-panel__heading p, .showcase-bullet span:last-child, .upload-status, .section-head p { color: var(--muted); }

.flash-stack { display: grid; gap: 10px; margin-bottom: 16px; }
.flash {
  border-radius: 16px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.flash-success { border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.12); }
.flash-danger { border-color: rgba(251, 113, 133, 0.3); background: rgba(251, 113, 133, 0.12); }
.flash-warning { border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.12); }
.flash-info { border-color: rgba(96, 165, 250, 0.3); background: rgba(96, 165, 250, 0.12); }

.login-screen {
  width: 100%;
  display: grid;
  grid-template-columns: 1.2fr 0.88fr;
  gap: 24px;
  align-items: stretch;
}
.login-showcase {
  position: relative;
  overflow: hidden;
  min-height: 650px;
  padding: 42px;
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.12), rgba(2, 6, 23, 0.58)),
    radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.22), transparent 30%),
    linear-gradient(140deg, #0b1328 0%, #172554 44%, #0f172a 100%);
}
body.theme-light .login-showcase {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.18), transparent 32%),
    linear-gradient(140deg, #dbeafe 0%, #eff6ff 46%, #f8fbff 100%);
}
.login-showcase__content {
  position: relative;
  z-index: 1;
  max-width: 520px;
}
.login-showcase h1 {
  margin: 0 0 12px;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.03;
}
body.theme-light .login-showcase h1 { color: #132238; }
.showcase-bullets {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}
.showcase-bullet {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-soft);
}
body.theme-light .showcase-bullet {
  background: rgba(255,255,255,0.75);
  border-color: rgba(148, 163, 184, 0.24);
}
.showcase-bullet__icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 800;
}
.login-panel {
  padding: 34px;
  align-self: center;
}
.login-toolbar,
.login-form,
.admin-section,
.catalog-stack,
.media-list { display: grid; gap: 18px; }
.login-panel__heading h2,
.streaming-hero__copy h2,
.catalog-row__head h3,
.section-head h3,
.section-head h4 { margin: 0; }

.form-grid { display: grid; gap: 14px; }
.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.single-column { grid-template-columns: 1fr; }
.compact-form { gap: 10px; }
.full-width { grid-column: 1 / -1; }
label { display: grid; gap: 8px; font-size: 0.95rem; }
input, textarea, select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus {
  border-color: rgba(56, 189, 248, 0.58);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.16);
}
.checkbox-row { justify-content: flex-start; }
.checkbox-row input { width: auto; }
.checkbox-stack { display: grid; gap: 10px; }
.media-checkboxes {
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.streaming-hero {
  justify-content: space-between;
  padding: 26px;
  margin-bottom: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
    linear-gradient(140deg, rgba(96, 165, 250, 0.12), rgba(34, 211, 238, 0.06));
}
body.theme-light .streaming-hero {
  background: linear-gradient(140deg, rgba(37, 99, 235, 0.08), rgba(56, 189, 248, 0.06));
}
.streaming-hero__copy { max-width: 720px; }
.streaming-hero__meta,
.admin-hero__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
}
.meta-tile {
  min-width: 130px;
  min-height: 82px;
  padding: 18px;
  border-radius: 20px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  background: rgba(255,255,255,0.06);
}
body.theme-light .meta-tile { background: rgba(255,255,255,0.82); }
.meta-tile strong { font-size: 1.5rem; }
.meta-tile span { color: var(--muted); }
.catalog-stack { gap: 28px; }
.catalog-row__head {
  justify-content: space-between;
  margin-bottom: 14px;
}
.streaming-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}
.poster-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  min-height: 100%;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.poster-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.45);
}
.poster-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(96,165,250,0.24), rgba(34,211,238,0.14));
}
.thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #fff;
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(59,130,246,0.86), rgba(34,211,238,0.6));
}
.poster-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 34%, rgba(2, 6, 23, 0.66) 100%);
  display: flex;
  align-items: flex-end;
  padding: 14px;
}
.play-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-weight: 800;
}
.poster-card__body {
  display: grid;
  gap: 10px;
  padding: 16px;
}
.progress-meta { display: grid; gap: 8px; }
.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.admin-shell { padding: 26px; }
.admin-tab-bar {
  margin-bottom: 22px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.tab-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
}
.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.admin-section {
  padding: 22px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 24px;
}
.section-head {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.section-head.compact { margin-bottom: 10px; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search-input { max-width: 420px; }
.media-list { gap: 16px; }
.media-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 18px;
}
.media-card__main {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 18px;
}
.media-card__poster {
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.media-card__poster--category { background: linear-gradient(135deg, #8b5cf6, #60a5fa); }
.media-card__content { min-width: 0; }
.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-warning { background: rgba(251, 191, 36, 0.12); color: #f59e0b; }
.badge-danger { background: rgba(251, 113, 133, 0.12); color: var(--danger); }
.badge-primary { background: rgba(56, 189, 248, 0.12); color: var(--primary); }
.upload-dropzone {
  border: 1px dashed rgba(56, 189, 248, 0.42);
  border-radius: 20px;
  padding: 16px;
  background: rgba(56, 189, 248, 0.05);
}
body.theme-light .upload-dropzone { background: rgba(37, 99, 235, 0.04); }
.upload-dropzone.dragover,
.upload-dropzone.has-file {
  border-color: rgba(52, 211, 153, 0.68);
  background: rgba(52, 211, 153, 0.08);
}
.upload-progress {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  display: grid;
  gap: 12px;
}
.upload-progress.hidden { display: none; }
.large-progress { height: 11px; }
.upload-progress.success-state { border-color: rgba(52, 211, 153, 0.42); }
.upload-progress.error-state { border-color: rgba(251, 113, 133, 0.42); }
.upload-progress.success-state .large-progress span { background: linear-gradient(135deg, #34d399, #10b981); }
.upload-progress.error-state .large-progress span { background: linear-gradient(135deg, #fb7185, #f43f5e); }
.upload-submit.is-loading { opacity: 0.75; pointer-events: none; }
.empty-state {
  padding: 28px;
  text-align: center;
  border-radius: 22px;
  border: 1px dashed var(--line-strong);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
}
.admin-video-stack { gap: 22px; }
.admin-streaming-row { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.admin-poster-card .poster-card__body { gap: 12px; }
.video-player-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px;
}
.video-player {
  width: 100%;
  max-height: 72vh;
  border-radius: 18px;
  background: #000;
}
.narrow-card {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 26px;
}
.center-text { text-align: center; }
.spaced-top { margin-top: 24px; }
.hidden-by-filter { display: none !important; }
.bidi-text { unicode-bidi: plaintext; }
body.rtl { text-align: right; }
body.rtl .portal-header,
body.rtl .portal-header__right,
body.rtl .header-actions,
body.rtl .header-switcher-group,
body.rtl .toolbar-row,
body.rtl .section-head,
body.rtl .split-actions,
body.rtl .streaming-hero,
body.rtl .catalog-row__head,
body.rtl .checkbox-row,
body.rtl .upload-progress-head,
body.rtl .brand-lockup,
body.rtl .media-card__main { direction: rtl; }
body.rtl .portal-header__right { justify-content: flex-start; }
body.rtl .media-card__main { grid-template-columns: minmax(0, 1fr) 90px; }

@media (max-width: 1100px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-showcase { min-height: 360px; }
}
@media (max-width: 900px) {
  .app-shell { padding: 14px; }
  .page-frame--login { min-height: auto; }
  .portal-header,
  .portal-header__right,
  .header-actions,
  .header-switcher-group,
  .streaming-hero,
  .catalog-row__head,
  .section-head,
  .split-actions,
  .toolbar-row,
  .upload-progress-head { flex-direction: column; align-items: stretch; }
  .portal-header__right { margin-inline-start: 0; }
  .two-column { grid-template-columns: 1fr; }
  .streaming-hero__meta,
  .admin-hero__stats { grid-template-columns: 1fr 1fr; }
  .media-card__main { grid-template-columns: 1fr; }
  body.rtl .media-card__main { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .login-panel, .login-showcase, .admin-shell, .streaming-hero, .admin-section, .narrow-card { padding: 20px; }
  .streaming-row, .admin-streaming-row { grid-template-columns: 1fr; }
  .streaming-hero__meta,
  .admin-hero__stats { grid-template-columns: 1fr; }
}
