@font-face {
  font-family: "Alexandria";
  src: url("/fonts/alexandria-arabic.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
}

@font-face {
  font-family: "Alexandria";
  src: url("/fonts/alexandria-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122;
}

:root {
  color-scheme: dark;
  --screen: #05070b;
  --rail: #0a0d13;
  --surface: #151923;
  --raised: #202637;
  --focus: #2e6cf6;
  --focus-bright: #4b7ef4;
  --text: #f7f8fa;
  --muted: #b3b8c2;
  --line: #2b303a;
  --danger: #f06a73;
  font-family: "Alexandria", sans-serif;
  background: var(--screen);
  color: var(--text);
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--focus) var(--rail); }
body { margin: 0; min-width: 320px; background: var(--screen); color: var(--text); line-height: 1.6; }
::selection { background: var(--focus); color: #fff; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus-bright);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  inset: 12px auto auto 12px;
  translate: 0 -160%;
  padding: 8px 14px;
  border-radius: 8px;
  background: #fff;
  color: #05070b;
}

.skip-link:focus { translate: 0; }
.admin-brand { color: var(--text); font-size: 1.9rem; font-weight: 900; text-decoration: none; letter-spacing: -.03em; }

.login-body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(5, 7, 11, .95), rgba(5, 7, 11, .66)),
    url("/media/hero_midnight.png") center / cover;
}

.login-shell {
  width: min(100%, 980px);
  min-height: 570px;
  display: grid;
  grid-template-columns: 1fr 430px;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(5, 7, 11, .92);
  box-shadow: 0 34px 90px rgba(0, 0, 0, .5);
}

.login-intro,
.login-panel { padding: clamp(38px, 6vw, 72px); }
.login-intro { display: flex; align-items: flex-start; justify-content: center; flex-direction: column; }
.login-intro h1 { max-width: 8ch; margin: 56px 0 18px; font-size: clamp(2.8rem, 5vw, 4.8rem); line-height: 1.08; letter-spacing: -.04em; }
.login-intro p { max-width: 38ch; color: var(--muted); }
.back-link { margin-top: auto; color: var(--muted); text-underline-offset: .35em; }
.login-panel { display: flex; justify-content: center; flex-direction: column; background: var(--surface); }
.login-panel h2 { margin: 0 0 8px; font-size: 1.8rem; }
.login-panel > p { margin: 0 0 34px; color: var(--muted); font-size: .9rem; }

form label { display: grid; gap: 8px; color: var(--muted); font-size: .82rem; }
form { display: grid; gap: 20px; }

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #353b48;
  border-radius: 10px;
  background: #0d1016;
  color: var(--text);
  padding: 10px 12px;
  caret-color: var(--focus-bright);
}

textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #737a88; }
input:hover, textarea:hover, select:hover { border-color: #50596a; }

.admin-button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  background: var(--raised);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.admin-button:hover { background: #2a3246; }
.admin-button.primary { background: var(--focus); color: #fff; }
.admin-button.primary:hover { background: var(--focus-bright); }
.admin-button.danger { background: transparent; color: var(--danger); border: 1px solid #6d343b; }
.admin-button:disabled { opacity: .52; cursor: wait; }
.form-status, .page-status { min-height: 24px; margin: 0; color: var(--muted); font-size: .82rem; }
.form-status.error, .page-status.error { color: #ff9da4; }
.form-status.success, .page-status.success { color: #8fc7a1; }

.admin-shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}

.admin-rail {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
  background: var(--rail);
  border-left: 1px solid #171b23;
}

.admin-rail nav { display: grid; gap: 7px; margin-top: 58px; }
.rail-item, .rail-footer button {
  min-height: 46px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  text-align: right;
  padding: 9px 13px;
  cursor: pointer;
}
.rail-item:hover, .rail-footer button:hover { color: var(--text); background: var(--surface); }
.rail-item.active { color: var(--focus-bright); background: #10182b; font-weight: 700; }
.rail-footer { display: grid; gap: 8px; margin-top: auto; }
.rail-footer a { padding: 8px 13px; color: var(--muted); font-size: .82rem; }
.rail-footer button { font-size: .82rem; }

.workspace { min-width: 0; padding: 42px clamp(28px, 5vw, 72px) 80px; }
.workspace-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.workspace-header p, .editor-panel header p { margin: 0 0 5px; color: var(--muted); font-size: .78rem; }
.workspace-header h1 { margin: 0; font-size: clamp(2.1rem, 4vw, 3.3rem); letter-spacing: -.035em; }
.page-status { margin-bottom: 12px; }
.view { display: none; }
.view.active { display: block; }

.library-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 20px 0; border-top: 1px solid var(--line); }
.search-field { width: min(100%, 360px); }
.library-toolbar p { margin: 0; color: var(--muted); font-size: .8rem; }

.movie-list { border-top: 1px solid var(--line); }
.movie-row {
  width: 100%;
  display: grid;
  grid-template-columns: 96px minmax(180px, 1.4fr) minmax(120px, .8fr) 110px 90px;
  gap: 18px;
  align-items: center;
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: right;
  cursor: pointer;
}
.movie-row:hover { background: #0b0e14; }
.movie-row img { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface); }
.movie-title strong { display: block; }
.movie-title span, .movie-cell { color: var(--muted); font-size: .8rem; }
.state { justify-self: start; color: var(--muted); font-size: .75rem; }
.state.published { color: #8fc7a1; }
.source { direction: ltr; text-align: right; color: var(--muted); font-size: .74rem; text-transform: uppercase; }

.section-copy { margin: 16px 0 34px; }
.section-copy h2 { margin: 0 0 7px; font-size: 2rem; }
.section-copy p { margin: 0; color: var(--muted); }
.inline-form { grid-template-columns: minmax(220px, 1fr) 130px auto; align-items: end; padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.category-list, .release-list { margin-top: 18px; }
.category-row, .release-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; border-bottom: 1px solid var(--line); }
.category-row span, .release-row span { color: var(--muted); font-size: .8rem; }
.text-button { border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.release-form { max-width: 760px; padding: 28px; border-radius: 14px; background: var(--surface); }
.release-row.current strong::after { content: "الحالي"; margin-inline-start: 9px; color: var(--focus-bright); font-size: .7rem; }
.form-grid { display: grid; gap: 16px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.file-field input { padding: 8px; }

.editor-panel {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: min(520px, calc(100vw - 220px));
  overflow-y: auto;
  padding: 30px;
  background: #0c0f15;
  box-shadow: 20px 0 70px rgba(0, 0, 0, .55);
}
.editor-panel[hidden] { display: none; }
.editor-panel header { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.editor-panel h2 { margin: 0; font-size: 1.7rem; }
.close-editor { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.switch-row { display: flex; flex-wrap: wrap; gap: 18px; padding: 14px 0; border-block: 1px solid var(--line); }
.switch-row label { display: flex; align-items: center; gap: 8px; color: var(--text); }
.switch-row input { width: 18px; min-height: 18px; accent-color: var(--focus); }
.editor-actions { display: flex; gap: 10px; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 330px; }
  .login-intro h1 { margin-top: 38px; }
  .back-link { margin-top: 24px; }
  .admin-shell { grid-template-columns: 1fr; padding-bottom: 72px; }
  .admin-rail {
    position: fixed;
    z-index: 25;
    inset: auto 0 0;
    width: 100%;
    height: 68px;
    display: block;
    padding: 8px 12px;
    border: 0;
    border-top: 1px solid var(--line);
  }
  .admin-rail > .admin-brand, .rail-footer { display: none; }
  .admin-rail nav { grid-template-columns: repeat(4, 1fr); margin: 0; }
  .rail-item { text-align: center; min-height: 50px; padding: 7px; font-size: .76rem; }
  .workspace { padding: 26px 18px 60px; }
  .editor-panel { width: 100%; }
  .movie-row { grid-template-columns: 86px minmax(0, 1fr) 80px; }
  .movie-cell.category, .source { display: none; }
}

@media (max-width: 560px) {
  .login-body { padding: 0; }
  .login-shell { min-height: 100svh; border-radius: 0; }
  .login-intro, .login-panel { padding: 34px 24px; }
  .workspace-header { align-items: stretch; flex-direction: column; }
  .library-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .movie-row { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
  .movie-row img { width: 72px; }
  .movie-cell.state { display: none; }
  .inline-form, .two-columns { grid-template-columns: 1fr; }
  .release-form { padding: 20px; }
  .editor-panel { padding: 24px 18px 80px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
