/* ============================================================
   التخطيط: شاشة الدخول، الهيكل، الشريط الجانبي، منطقة المحتوى.
   ============================================================ */

/* ==================== شاشة الدخول ==================== */
.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: var(--sp-4);
  position: relative; overflow: hidden;
}

/* توهّج خفيف يعطي عمقًا بلا صور. */
.auth::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(900px circle at 15% 0%, var(--accent-soft), transparent 55%),
    radial-gradient(700px circle at 85% 100%, var(--info-soft), transparent 55%);
  opacity: .8; pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%; max-width: 396px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
  animation: fade-up var(--t-slow) both;
}

.auth-logo {
  width: 46px; height: 46px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--gold-strong), var(--gold));
  display: grid; place-items: center; color: #fff;
  margin-bottom: var(--sp-4); box-shadow: var(--shadow-md);
}

.auth-title { font-size: var(--fs-xl); font-weight: 680; letter-spacing: -.015em; }
.auth-sub { color: var(--text-2); font-size: var(--fs-md); margin-top: 2px; }
.auth-form { margin-top: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-foot {
  margin-top: var(--sp-5); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--text-3); line-height: 1.7;
}
.auth-tools { position: absolute; inset-block-start: var(--sp-4); inset-inline-end: var(--sp-4); z-index: 1; }

/* ==================== الهيكل ==================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ==================== الشريط الجانبي ==================== */
.side {
  background: var(--sidebar);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: var(--sp-4) var(--sp-3);
  position: sticky; top: 0; height: 100vh;
}

.side-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-5);
}
.side-brand .mark {
  width: 34px; height: 34px; border-radius: var(--r-md); flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold-strong), var(--gold));
  display: grid; place-items: center; color: #1a1206;
  box-shadow: var(--shadow-xs);
}
.side-brand .name { font-weight: 680; font-size: var(--fs-lg); line-height: 1.2; letter-spacing: -.01em; color: var(--sidebar-text-strong); }
.side-brand .sub { font-size: var(--fs-xs); color: var(--sidebar-text); }

.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: 9px var(--sp-3);
  border: 0; border-radius: var(--r-md);
  background: none; color: var(--sidebar-text);
  font: inherit; font-size: var(--fs-md); font-weight: 550;
  cursor: pointer; text-align: start;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--gold-strong); font-weight: 620; }
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 17px; border-radius: var(--r-full); background: var(--gold-strong);
}
.nav-item svg { flex-shrink: 0; opacity: .85; }
.nav-item.active svg { opacity: 1; }

.side-foot { padding-top: var(--sp-3); border-top: 1px solid rgba(255, 255, 255, .09); margin-top: var(--sp-3); }

.user-chip {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  background: var(--sidebar-hover); margin-bottom: var(--sp-2);
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold-strong), var(--gold)); color: #1a1206;
  display: grid; place-items: center;
  font-weight: 650; font-size: var(--fs-sm);
}
.user-chip .who { min-width: 0; }
.user-chip .who .n { font-weight: 600; font-size: var(--fs-sm); color: var(--sidebar-text-strong); }
.user-chip .who .r { font-size: var(--fs-xs); color: var(--sidebar-text); }

/* الأزرار الشبحية داخل الشريط الكحلي تحتاج نصًّا فاتحًا. */
.side .btn-ghost { color: var(--sidebar-text); }
.side .btn-ghost:hover:not(:disabled) { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }

/* ==================== المحتوى ==================== */
.main { padding: var(--sp-5) var(--sp-6); min-width: 0; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.page-head .t { font-size: var(--fs-xl); font-weight: 680; letter-spacing: -.015em; }
.page-head .s { color: var(--text-2); font-size: var(--fs-md); margin-top: 2px; max-width: 62ch; }

.page { animation: fade-up var(--t-base) both; }

/* ==================== الشريط العلوي (الجوال) ====================
   لا يظهر إلا حين يصير الشريط الجانبي درجًا: يحمل زر فتحه واسم الصفحة
   الحالية، فيعرف المستخدم أين هو وكيف ينتقل.                         */
.topbar {
  display: none;
  position: sticky; inset-block-start: 0; z-index: 90;
  block-size: var(--topbar-h);
  align-items: center; gap: var(--sp-2);
  padding-inline: var(--sp-3);
  background: var(--sidebar);
  border-block-end: 1px solid var(--border);
}
.topbar .title {
  flex: 1; min-width: 0;
  font-weight: 650; font-size: var(--fs-md);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* حجاب خلف الدرج: نقره يُغلق، ووجوده يمنع لمس ما تحته بالخطأ. */
.scrim {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 13, 20, .45);
  animation: fade-in var(--t-fast) both;
}

/* ==================== الطيّ على سطح المكتب ====================
   أيقونات فقط. العنوان (title) يبقى على كل زر فيظهر اسم الصفحة عند
   المرور — الأيقونة وحدها لا تكفي لمن لم يحفظ مواضعها بعد.          */
.shell.rail { grid-template-columns: var(--rail-w) 1fr; }
.shell.rail .side { padding-inline: var(--sp-2); align-items: center; overflow-x: hidden; }
.shell.rail .side-brand {
  padding-inline: 0; padding-block-end: var(--sp-4);
  flex-direction: column; justify-content: center; gap: var(--sp-2);
}
.shell.rail .rail-toggle { margin-inline-start: 0; }
.shell.rail .side-brand .txt,
.shell.rail .user-chip .who,
.shell.rail .nav-item > span,
.shell.rail .side-foot .btn > span { display: none; }
.shell.rail .nav-item { justify-content: center; padding-inline: 0; }
.shell.rail .nav-item.active::before { display: none; }
.shell.rail .user-chip { justify-content: center; padding-inline: var(--sp-2); }
.shell.rail .side-foot .row { flex-wrap: wrap; justify-content: center; }
.shell.rail .side-nav { inline-size: 100%; }

/* ==================== الاستجابة ==================== */
@media (max-width: 900px) {
  /* عمود واحد، والشريط يخرج من التدفّق ليصير درجًا فوق المحتوى. */
  .shell, .shell.rail { grid-template-columns: 1fr; }

  .topbar { display: flex; }

  .side {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    z-index: 110;
    inline-size: min(82vw, 290px);
    height: 100dvh;                 /* dvh لا vh: شريط المتصفح المتحرّك */
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--t-base);
  }
  [dir="rtl"] .side { transform: translateX(100%); }

  .shell.drawer-open .side { transform: none; }
  .shell.drawer-open .scrim { display: block; }

  /* مفتوح أو مغلق، الشريط في الجوال كامل الملامح لا أيقونات مبتورة. */
  .shell.rail .side-brand .txt,
  .shell.rail .user-chip .who,
  .shell.rail .nav-item > span,
  .shell.rail .side-foot .btn > span { display: revert; }
  .shell.rail .nav-item { justify-content: flex-start; padding-inline: var(--sp-3); }
  .shell.rail .side { padding-inline: var(--sp-3); align-items: stretch; }

  .main { padding: var(--sp-4); }
  .page-head .t { font-size: var(--fs-lg); }
}

/* الشاشات الضيّقة جدًا: الدرج يغطي أغلب العرض فيسهل لمس عناصره. */
@media (max-width: 560px) {
  .side { inline-size: min(88vw, 320px); }
  .page-head { gap: var(--sp-3); margin-bottom: var(--sp-4); }
}

/* من يفضّل تقليل الحركة: يظهر الدرج بلا انزلاق. */
@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}

/* ==================== سقف عرض المحتوى ====================
   بلا سقف تفترش الصفحة الشاشة العريضة، فتنفرد الحقول القصيرة على
   ١٥٠٠ بكسل وتصير أسطر النص أطول من أن تُتابَع العين آخرها.

   ١١٨٠ معتدل عمدًا: الجداول العريضة (التسجيل، الكتالوج) ما زالت
   تأخذ مساحتها داخل الحاوية عبر .table-wrap { overflow-x: auto }
   الموجود أصلًا، فلا يضيق عليها السقف.                           */
.main {
  max-width: 1180px;
  margin-inline: auto;
}

/* صفحة التوثيق نصّ متصل يُقرأ لا لوحة تُمسَح بالنظر، فقياسها أضيق.
   الجداول وكتل الشيفرة تبقى بعرض الحاوية — لا تُقرأ سطرًا سطرًا. */
.page[data-page="docs"] {
  max-width: 940px;
}
.page[data-page="docs"] p,
.page[data-page="docs"] .field-hint,
.page[data-page="docs"] li {
  max-width: 74ch;
}

/* زر الطيّ داخل ترويسة الشريط — يختفي حين يصير الشريط درجًا. */
.rail-toggle { margin-inline-start: auto; flex: none; }
@media (max-width: 900px) { .rail-toggle { display: none; } }
