/* base.css — التصفير + التايبوغرافي + القطع المشتركة بين صفحة الدخول والتطبيق.
   أي حاجة بتظهر في المكانين بتتكتب هنا مرة واحدة. */

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol, fieldset, legend { margin: 0; }
ul, ol, fieldset, legend { padding: 0; }
ul[class], ol[class] { list-style: none; }
fieldset { border: 0; min-inline-size: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; }
img, svg, canvas { display: block; max-inline-size: 100%; }
[hidden] { display: none !important; }

html {
  /* الموقع عربي بالكامل — الـdir متحطوط على <html> في الـHTML نفسه، مش هنا */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.75;          /* العربي محتاج سطور أوسع من اللاتيني عشان النقط والتشكيل */
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;          /* أي عنصر بيطلّع سكرول أفقي = غلط، بس ما نكسرش الصفحة بسببه */
}

h1, h2, h3, h4, .u-head {
  font-family: var(--font-head);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0;           /* ممنوع letter-spacing على العربي — بيفك ربط الحروف */
}

a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: .25em; }
a:hover { text-decoration-color: currentColor; }

/* ===== الفوكس =====
   الكيبورد لازم يبان. بنستعمل :focus-visible بس عشان الماوس ما يرسمش إطار على كل ضغطة،
   ومعاه ظل تاني بلون الأرضية عشان الإطار يفضل باين حتى فوق خلفية نعناعي. */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--accent-soft); color: var(--ink); }

/* شريط التمرير — بيبان بلون البراند بدل الرمادي الافتراضي */
* { scrollbar-color: var(--line-2) transparent; scrollbar-width: thin; }

/* ===== أدوات ===== */
.wrap { inline-size: min(100% - (var(--gutter) * 2), var(--maxw)); margin-inline: auto; }
.u-sr {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.u-sr:focus { position: static; inline-size: auto; block-size: auto; clip-path: none; }
.u-num {
  /* الأرقام في الواجهة بتتكتب هندي (٠١٢٣) في النص وعربي في الحقول —
     tabular-nums عشان الأرصدة ما ترقصش وهي بتتحدّث */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
/* وحدة ما تتقسمش: رقم مع عملته أو مع وحدته («٩٠٠٠٫٠٠ ج»، «٢٠ رصيد»).
   من غيرها اللفّ بيسيب العملة لوحدها في سطر تحت الرقم. */
.u-atom { white-space: nowrap; }
.u-muted { color: var(--ink-2); }
.u-dim   { color: var(--ink-3); font-size: var(--fs-sm); }
.u-center { text-align: center; }

/* رابط «تخطّي للمحتوى» — أول حاجة يوصلها التاب */
.skip {
  position: absolute; inset-block-start: -100%; inset-inline-start: var(--s4);
  z-index: 200; background: var(--ink); color: var(--ground);
  padding: var(--s2) var(--s4); border-radius: 0 0 var(--r) var(--r);
}
.skip:focus { inset-block-start: 0; }

/* ===== عنوان قسم =====
   نفس لغة المستند اللي بنطلّعه: عنوان + خط تحته. بنستعمل ترقيم عربي (أولًا/ثانيًا)
   بدل الإيموجي كعلامة قسم — ده نفس اللي بيطبعه المحرك في المذكرة. */
.sec-mark {
  font-family: var(--font-head); font-weight: 700; font-size: var(--fs-sm);
  color: var(--gold); display: block; margin-block-end: var(--s2);
}
.sec-title {
  font-size: var(--fs-xl); margin-block-end: var(--s3);
  padding-block-end: var(--s3);
  border-block-end: 2px solid var(--accent);
}

/* ===== الورقة ===== */
.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.sheet--ruled { border-block-start: 3px solid var(--gold); border-start-start-radius: var(--r-lg); }

/* ===== الأزرار =====
   تلات مستويات بس: أساسي (نعناعي)، ثانوي (محدّد)، هادي (نص).
   المستوى بيتقال بالشكل مش بالحجم — عشان ما يحصلش اللي حصل في «Word مقابل PDF». */
.btn {
  --btn-bg: transparent; --btn-fg: var(--ink); --btn-line: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-block-size: var(--tap); padding-inline: var(--s5); padding-block: var(--s2);
  font-family: var(--font-head); font-weight: 700; font-size: var(--fs-sm);
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1.5px solid var(--btn-line); border-radius: var(--r);
  transition: transform .14s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease);
  text-decoration: none; text-align: center;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--on-brand); --btn-line: var(--accent); }
.btn--gold    { --btn-bg: var(--brand-gold); --btn-fg: #2a1d02; --btn-line: var(--brand-gold); }
.btn--ghost   { --btn-line: transparent; --btn-fg: var(--ink-2); }
.btn--ghost:hover:not(:disabled) { --btn-fg: var(--ink); box-shadow: none; background: var(--sheet-2); }
.btn--danger  { --btn-fg: var(--danger); --btn-line: var(--danger); }
.btn--lg { min-block-size: 54px; font-size: var(--fs-md); padding-inline: var(--s6); }
.btn--block { inline-size: 100%; }
.btn svg { inline-size: 1.15em; block-size: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===== الحقول ===== */
.field { display: block; margin-block-end: var(--s4); }
.field > .label {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  color: var(--ink-2); margin-block-end: var(--s1);
}
.field > .hint { display: block; font-size: var(--fs-xs); color: var(--ink-3); margin-block-start: var(--s1); }
.field > .err  { display: block; font-size: var(--fs-xs); color: var(--danger); margin-block-start: var(--s1); font-weight: 600; }
.input, .select, textarea.input {
  inline-size: 100%; min-block-size: var(--tap);
  padding: var(--s2) var(--s3);
  font-size: var(--fs-input); font-family: var(--font-ui);
  color: var(--ink); background: var(--sheet);
  border: 1.5px solid var(--line-2); border-radius: var(--r);
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.input::placeholder { color: var(--ink-3); }
.input:hover, .select:hover { border-color: var(--ink-3); }
.input:focus-visible, .select:focus-visible { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.select {
  appearance: none;
  /* سهم مرسوم بالـCSS مش صورة — ملف أقل يتحمّل، وبيتلوّن مع الثيم لوحده */
  /* نصفين بيكوّنوا سهم لتحت: المربع الشمال نصه الأعلى-يمين ملوّن، واليمين نصه الأعلى-شمال.
     لو الترتيب اتعكس بيطلعوا بقعتين مفصولتين بدل سهم — وده اللي كان حاصل. */
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: left var(--s4) center, left calc(var(--s4) + 5px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-inline-start: var(--s3); padding-inline-end: var(--s6);
}
textarea.input { min-block-size: 7rem; resize: vertical; line-height: 1.8; }

/* ===== الرقائق (chips) ===== */
.chip {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: 2px var(--s2); border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 700;
  background: var(--sheet-2); color: var(--ink-2); border: 1px solid var(--line);
}
.chip--ok   { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip--warn { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.chip--bad  { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ===== سطر تنبيه =====
   «الملحوظة الأمينة» — الحتة اللي بنقول فيها اللي المنتج ما بيعملوش. مش بنخبّيها. */
.note {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-radius: var(--r);
  border-inline-start: 3px solid var(--gold);
  background: var(--gold-soft);
  font-size: var(--fs-sm); line-height: 1.7;
}
/* أيقونة التنبيه — مشتركة بين صفحة الدخول والتطبيق، فمكانها هنا مش في ملف واحد منهم */
.note__i { inline-size: 22px; block-size: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-block-start: 2px; }
.note--plain { background: var(--sheet-2); border-inline-start-color: var(--line-2); color: var(--ink-2); }
.note--bad   { background: var(--danger-soft); border-inline-start-color: var(--danger); }
.note b { font-weight: 700; }

/* ===== جدول ===== */
.table { inline-size: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--s3); text-align: start; border-block-end: 1px solid var(--line); }
.table thead th {
  background: var(--brand-green); color: #f3fbf6;
  font-family: var(--font-head); font-weight: 700; font-size: var(--fs-xs);
  border-block-end: 0; white-space: nowrap;
}
.table thead th:first-child { border-start-start-radius: var(--r); }
.table thead th:last-child  { border-start-end-radius: var(--r); }
.table tbody tr:hover { background: var(--sheet-2); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== إشعارات ===== */
.toasts {
  position: fixed; inset-block-end: calc(var(--s4) + env(safe-area-inset-bottom));
  inset-inline: var(--s4); z-index: 300;
  display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none;
}
.toast {
  pointer-events: auto; max-inline-size: 30rem; inline-size: 100%;
  padding: var(--s3) var(--s4); border-radius: var(--r);
  background: var(--ink); color: var(--ground);
  font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--shadow-lift);
  animation: toast-in .25s var(--ease);
}
.toast--bad { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ===== لودر ===== */
.spin {
  inline-size: 1.1em; block-size: 1.1em; border-radius: 50%;
  border: 2px solid var(--line-2); border-block-start-color: var(--accent);
  animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* الهيكل العظمي وقت التحميل — أحسن من كلمة «بنحمّل» لإنه بيوري شكل اللي جاي */
.skel {
  background: linear-gradient(90deg, var(--sheet-2) 25%, var(--line) 50%, var(--sheet-2) 75%);
  background-size: 400% 100%; animation: skel 1.4s ease-in-out infinite;
  border-radius: var(--r-sm); color: transparent;
}
@keyframes skel { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ===== احترام إعداد «قلّل الحركة» =====
   مش بنطفّي الحركة كلها — بنخلّيها فورية. اللودر بيفضل بيلف بس أبطأ عشان يفضل واضح إن فيه شغل. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .spin { animation: spin 1.6s linear infinite !important; animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
