:root {
  --brand: #20559a;
  --brand-deep: #123c73;
  --brand-soft: #e9f1fb;
  --accent: #e52262;
  --ink: #14233a;
  --muted: #64748b;
  --line: #dce5f0;
  --surface: #ffffff;
  --page: #f4f7fb;
  --success: #147a4c;
  --danger: #b4233a;
  --shadow: 0 18px 50px rgba(20, 35, 58, 0.12);
  font-family: Tahoma, Arial, "Noto Sans Arabic", sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  min-width: 320px;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.pdf-stage:focus-visible {
  outline: 3px solid rgba(229, 34, 98, 0.5);
  outline-offset: 3px;
}

.hero {
  position: relative;
  overflow: hidden;
  color: white;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.14), transparent 30%),
    linear-gradient(135deg, var(--brand-deep), var(--brand));
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -8% -180px auto;
  width: 420px;
  height: 420px;
  border: 70px solid rgba(255, 255, 255, 0.05);
  transform: rotate(25deg);
  border-radius: 30%;
}

.hero-pattern {
  height: 18px;
  background: white url("/assets/pattern.jpg") center / auto 84px repeat-x;
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 40px));
  min-height: 250px;
  margin: 0 auto;
  padding: 34px 0;
  display: grid;
  grid-template-columns: 236px 1fr;
  align-items: center;
  gap: 36px;
}

.hero-logo {
  display: block;
  width: 236px;
  height: 160px;
  object-fit: cover;
  border-radius: 24px;
  box-shadow: 0 18px 40px rgba(5, 25, 54, 0.22);
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.82;
}

.hero-copy p {
  margin: 0;
  max-width: 580px;
  font-size: 1.06rem;
  color: rgba(255, 255, 255, 0.84);
}

.button {
  display: inline-flex;
  min-height: 46px;
  padding: 11px 20px;
  border: 0;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.button-primary {
  color: white;
  background: var(--brand);
  box-shadow: 0 10px 24px rgba(32, 85, 154, 0.22);
}

.button-accent {
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(229, 34, 98, 0.22);
}

.button-ghost {
  color: var(--brand);
  background: var(--brand-soft);
}

.button-quiet {
  color: var(--muted);
  background: #eef2f7;
}

.button-wide {
  width: 100%;
}

.menu-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 64px;
}

.category-section {
  margin-bottom: 28px;
}

.category-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.category-heading h2 {
  margin: 0;
  font-size: 1.6rem;
}

.category-scroller {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 3px 2px 12px;
  scrollbar-color: rgba(32, 85, 154, 0.28) transparent;
  scroll-snap-type: x proximity;
}

.category-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 54px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(20, 35, 58, 0.04);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.category-chip span {
  font-weight: 800;
  white-space: nowrap;
}

.category-chip small {
  min-width: 28px;
  color: var(--muted);
  font-weight: 800;
  direction: ltr;
}

.category-chip:hover {
  border-color: rgba(32, 85, 154, 0.45);
}

.category-chip.is-active {
  color: white;
  border-color: var(--brand);
  background: var(--brand);
}

.category-chip.is-active small {
  color: rgba(255, 255, 255, 0.7);
}

.viewer-card {
  border: 1px solid rgba(220, 229, 240, 0.9);
  border-radius: 26px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 18px;
}

.viewer-toolbar,
.viewer-footer {
  min-height: 78px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.viewer-toolbar {
  position: relative;
  z-index: 3;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.page-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.page-kicker {
  color: var(--muted);
  font-size: 0.76rem;
}

.page-meta strong {
  color: var(--brand-deep);
  font-size: 1.05rem;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--brand);
  background: white;
  font-size: 1.35rem;
  cursor: pointer;
}

.icon-button:disabled {
  color: #9aa9bb;
  cursor: not-allowed;
}

.zoom-value {
  min-width: 58px;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  direction: ltr;
}

.pdf-stage {
  position: relative;
  min-height: 68vh;
  max-height: 78vh;
  padding: 16px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background:
    linear-gradient(45deg, rgba(32, 85, 154, 0.035) 25%, transparent 25%) 0 0 / 26px 26px,
    linear-gradient(-45deg, rgba(32, 85, 154, 0.035) 25%, transparent 25%) 0 0 / 26px 26px,
    #eaf0f6;
  overscroll-behavior: contain;
}

.menu-page-image {
  display: block;
  flex: 0 0 auto;
  height: auto;
  max-width: none;
  border-radius: 4px;
  background: white;
  box-shadow: 0 12px 30px rgba(20, 35, 58, 0.18);
  transition: opacity 120ms ease;
}

.menu-page-image.is-loading {
  opacity: 0.25;
}

.pdf-stage.is-zoomed {
  justify-content: flex-start;
}

.viewer-loading,
.viewer-error {
  position: absolute;
  z-index: 2;
  inset: 0;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.viewer-loading[hidden],
.viewer-error[hidden] {
  display: none;
}

.viewer-loading small,
.viewer-error p {
  margin-top: 7px;
  color: var(--muted);
}

.spinner {
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border: 4px solid rgba(32, 85, 154, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.viewer-footer {
  border-top: 1px solid var(--line);
  background: white;
}

.nav-button {
  min-height: 44px;
  padding: 9px 16px;
  border: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 800;
  cursor: pointer;
}

.nav-button:disabled {
  color: #96a5b5;
  background: #f2f5f8;
  cursor: not-allowed;
}

.page-counter {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  direction: rtl;
}

.page-counter strong {
  color: var(--brand-deep);
  font-size: 1.05rem;
  direction: ltr;
}

.noscript-message {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #f1c8d5;
  border-radius: 16px;
  background: #fff7fa;
}

.site-footer {
  min-height: 120px;
  padding: 26px max(24px, calc((100vw - 1080px) / 2));
  display: flex;
  align-items: center;
  gap: 14px;
  color: white;
  background: var(--brand-deep);
}

.site-footer img {
  border-radius: 12px;
}

.site-footer div {
  display: flex;
  flex-direction: column;
  margin-inline-end: auto;
}

.site-footer span,
.site-footer a {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
}

/* Admin */
.admin-body {
  min-height: 100vh;
  background:
    linear-gradient(rgba(18, 60, 115, 0.88), rgba(18, 60, 115, 0.96)),
    url("/assets/pattern.jpg") center / 560px auto repeat;
}

.admin-layout {
  width: min(720px, calc(100% - 28px));
  margin: 0 auto;
  padding: 46px 0;
}

.admin-card {
  padding: clamp(22px, 5vw, 42px);
  border-radius: 28px;
  background: white;
  box-shadow: 0 28px 80px rgba(4, 20, 42, 0.3);
}

.admin-brand {
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.admin-brand img {
  width: 142px;
  height: 96px;
  object-fit: cover;
  border-radius: 18px;
}

.admin-brand h1 {
  margin: 0;
  color: var(--brand-deep);
  font-size: clamp(1.45rem, 4vw, 2.2rem);
}

.admin-brand .eyebrow {
  color: var(--accent);
}

.alert {
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid;
  border-radius: 14px;
  font-weight: 700;
}

.alert-error {
  color: var(--danger);
  border-color: #f3bbc7;
  background: #fff3f6;
}

.alert-success {
  color: var(--success);
  border-color: #b8e2cd;
  background: #f1fbf6;
}

.login-form,
.upload-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  font-weight: 800;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.password-row input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.admin-actions {
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-actions form {
  margin: 0;
}

.status-grid {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.status-item {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: #f8fafc;
}

.status-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.status-item strong {
  color: var(--brand-deep);
}

.admin-section {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
}

.admin-section p {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

.step-number {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  direction: ltr;
}

.file-limit {
  color: var(--muted);
  font-size: 0.76rem;
  direction: ltr;
}

.file-picker {
  min-height: 104px;
  padding: 18px;
  border: 2px dashed #b9c8d9;
  border-radius: 17px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  background: #f8fafc;
  cursor: pointer;
}

.file-picker:hover {
  border-color: var(--brand);
}

.file-picker span {
  color: var(--muted);
  font-size: 0.82rem;
}

.file-picker span[data-state="success"] {
  color: var(--success);
}

.file-picker span[data-state="error"] {
  color: var(--danger);
}

.file-picker input {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.qr-section {
  background: linear-gradient(135deg, #fff, #fff6f9);
}

@media (max-width: 780px) {
  .hero-inner {
    grid-template-columns: 138px 1fr;
    gap: 20px;
    min-height: 210px;
  }

  .hero-logo {
    width: 138px;
    height: 94px;
    border-radius: 17px;
  }

  .pdf-stage {
    min-height: 64vh;
    max-height: 72vh;
  }
}

@media (max-width: 520px) {
  .hero-pattern {
    height: 12px;
  }

  .hero-inner {
    width: min(100% - 28px, 1120px);
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 18px 0;
    gap: 12px;
    text-align: center;
  }

  .hero-logo {
    width: 170px;
    height: 116px;
    margin: 0 auto;
  }

  .hero-copy p {
    margin-inline: auto;
  }

  .menu-shell {
    width: min(100% - 20px, 1080px);
    padding-top: 22px;
    padding-bottom: 36px;
  }

  .category-section {
    margin-bottom: 16px;
  }

  .category-heading {
    align-items: start;
    margin-bottom: 10px;
  }

  .category-scroller {
    padding-bottom: 6px;
  }

  .viewer-card {
    border-radius: 20px;
  }

  .viewer-toolbar,
  .viewer-footer {
    min-height: 70px;
    padding: 12px;
  }

  .page-meta strong {
    max-width: 165px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pdf-stage {
    padding: 10px;
    min-height: 60vh;
    max-height: 68vh;
  }

  .nav-button {
    padding: 9px 12px;
  }

  .site-footer {
    flex-wrap: wrap;
  }

  .site-footer a {
    width: 100%;
    margin-top: 8px;
  }

  .admin-layout {
    padding: 18px 0;
  }

  .admin-card {
    border-radius: 22px;
  }

  .admin-brand {
    align-items: flex-start;
  }

  .admin-brand img {
    width: 104px;
    height: 71px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .admin-section {
    padding: 18px;
  }

  .section-heading {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
