/* =====================================================================
   نظام الموارد البشرية — مدارس البيارق الأهلية
   theme-bayariq.css — رموز التصميم والأساس
   مشتق من دليل الهوية البصرية 1442/1443هـ
   يُحمَّل بعد bootstrap.rtl.min.css
   ===================================================================== */

:root {
  /* ---- ألوان الهوية الرسمية (من دليل الهوية — لا تُعدَّل) ---- */
  --bq-green:        #005952;
  --bq-gold:         #C49945;

  /* ---- مشتقات الأخضر ---- */
  --bq-green-950:    #002E2A;   /* خلفية القائمة الجانبية */
  --bq-green-900:    #00403B;
  --bq-green-700:    #005952;   /* الأساسي */
  --bq-green-500:    #1A7A72;   /* تمرير الفأرة على الأزرار */
  --bq-green-200:    #9EC6C1;
  --bq-green-50:     #E6EFEE;   /* خلفيات مميزة، صف الجدول عند المرور */

  /* ---- مشتقات الذهبي ---- */
  --bq-gold-700:     #9E7A34;
  --bq-gold-500:     #C49945;   /* الأساسي */
  --bq-gold-200:     #E8D3A8;
  --bq-gold-50:      #F7EFDF;

  /* ---- محايدة ---- */
  --bq-ink:          #12211F;   /* النص الأساسي */
  --bq-ink-2:        #3D4E4B;   /* نص ثانوي */
  --bq-muted:        #5B6B69;   /* تسميات وتلميحات */
  --bq-line:         #DCE4E2;   /* الحدود والفواصل */
  --bq-line-soft:    #EDF1F0;
  --bq-surface:      #F4F7F6;   /* خلفية الصفحة */
  --bq-card:         #FFFFFF;

  /* ---- ألوان الحالة — منفصلة عن الهوية عمداً ----
     الذهبي لون هوية لا لون تحذير. لا تستخدمه لأي حالة. */
  --bq-success:      #17795E;  --bq-success-bg: #E4F2ED;
  --bq-warning:      #B4762A;  --bq-warning-bg: #FBF0E1;
  --bq-danger:       #A32B2B;  --bq-danger-bg:  #F8E6E6;
  --bq-info:         #1B5E8A;  --bq-info-bg:    #E4EFF6;

  /* ---- الخطوط ----
     واجهة النظام: IBM Plex Sans Arabic (مفتوح، أرقام جدولية، وضوح عالٍ)
     الشعار والخطابات المطبوعة: Al Qabas حسب دليل الهوية
     إن توفّرت رخصة ويب لـ GE SS Two، أضفه أول القائمة */
  --bq-font: "IBM Plex Sans Arabic", "GE SS Two", "Segoe UI", Tahoma, sans-serif;

  /* ---- سلّم الحجم ---- */
  --bq-fs-xs:   0.75rem;    /* 12 — شارات وتلميحات */
  --bq-fs-sm:   0.8125rem;  /* 13 — الجداول الكثيفة */
  --bq-fs-base: 0.875rem;   /* 14 — أساس الواجهة الإدارية */
  --bq-fs-md:   1rem;       /* 16 */
  --bq-fs-lg:   1.25rem;    /* 20 — عناوين الأقسام */
  --bq-fs-xl:   1.75rem;    /* 28 — أرقام البطاقات */
  --bq-fs-2xl:  2.25rem;    /* 36 — الرقم البطل */

  /* ---- المسافات ---- */
  --bq-sp-1: 0.25rem;  --bq-sp-2: 0.5rem;   --bq-sp-3: 0.75rem;
  --bq-sp-4: 1rem;     --bq-sp-5: 1.5rem;   --bq-sp-6: 2rem;

  /* ---- الحواف ---- */
  --bq-radius:    6px;   /* البطاقات والحقول */
  --bq-radius-sm: 4px;   /* الشارات والأزرار الصغيرة */

  /* ---- الظلال — بحساب، والاعتماد الأساسي على الحدود ---- */
  --bq-shadow-sm: 0 1px 2px rgba(0, 64, 59, 0.06);
  --bq-shadow-md: 0 4px 14px rgba(0, 64, 59, 0.10);

  /* ---- القياسات ---- */
  --bq-sidebar-w:  248px;
  --bq-header-h:   60px;
}

/* =====================================================================
   الأساس
   ===================================================================== */

html { font-size: 16px; }

body {
  font-family: var(--bq-font);
  font-size: var(--bq-fs-base);
  line-height: 1.65;
  color: var(--bq-ink);
  background: var(--bq-surface);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  color: var(--bq-green-900);
  font-weight: 600;
  line-height: 1.35;
}
h1 { font-size: var(--bq-fs-xl); }
h2 { font-size: var(--bq-fs-lg); }
h3 { font-size: var(--bq-fs-md); }

a { color: var(--bq-green-700); text-decoration: none; }
a:hover { color: var(--bq-green-500); text-decoration: underline; }

/* الأرقام: جدولية دائماً — أساسي لمحاذاة أعمدة الرواتب */
.bq-num, td.bq-num, .bq-stat__value, table.bq-table td {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* المبالغ المالية */
.bq-amount { font-weight: 600; white-space: nowrap; }
.bq-amount--negative { color: var(--bq-danger); }
.bq-amount::after { content: " ر.س"; font-size: 0.85em; color: var(--bq-muted); font-weight: 400; }

/* =====================================================================
   التخطيط
   ===================================================================== */

.bq-layout { display: flex; min-height: 100vh; }

.bq-main {
  flex: 1;
  min-width: 0;              /* يمنع تمدد الجداول العريضة للتخطيط */
  display: flex;
  flex-direction: column;
}

.bq-content { padding: var(--bq-sp-5); flex: 1; }

/* ---- القائمة الجانبية ---- */
.bq-sidebar {
  width: var(--bq-sidebar-w);
  flex-shrink: 0;
  background: var(--bq-green-950);
  color: #CFE0DE;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.bq-sidebar__brand {
  height: var(--bq-header-h);
  display: flex;
  align-items: center;
  gap: var(--bq-sp-3);
  padding: 0 var(--bq-sp-4);
  border-bottom: 1px solid rgba(196, 153, 69, 0.28);
}
.bq-sidebar__brand img { height: 34px; }
.bq-sidebar__brand span { color: #fff; font-weight: 600; font-size: var(--bq-fs-sm); }

/* عنوان مجموعة — بلا أحرف كبيرة مفرّقة */
.bq-sidebar__group {
  padding: var(--bq-sp-4) var(--bq-sp-4) var(--bq-sp-1);
  font-size: var(--bq-fs-xs);
  color: var(--bq-green-200);
}

.bq-sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--bq-sp-3);
  padding: var(--bq-sp-2) var(--bq-sp-4);
  color: #CFE0DE;
  font-size: var(--bq-fs-base);
  border-right: 3px solid transparent;   /* RTL: التمييز على اليمين */
  transition: background 0.12s ease;
}
.bq-sidebar__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}
/* العنصر النشط: الذهبي يظهر هنا — نقطة التمييز الوحيدة في الشريط */
.bq-sidebar__link.is-active {
  background: rgba(196, 153, 69, 0.12);
  border-right-color: var(--bq-gold-500);
  color: #fff;
  font-weight: 600;
}
.bq-sidebar__link i { width: 18px; text-align: center; opacity: 0.85; }

.bq-sidebar__badge {
  margin-inline-start: auto;
  background: var(--bq-gold-500);
  color: var(--bq-green-950);
  font-size: var(--bq-fs-xs);
  font-weight: 600;
  border-radius: 10px;
  padding: 0 6px;
  min-width: 20px;
  text-align: center;
}

/* ---- الترويسة ---- */
.bq-header {
  height: var(--bq-header-h);
  background: var(--bq-card);
  border-bottom: 1px solid var(--bq-line);
  display: flex;
  align-items: center;
  gap: var(--bq-sp-4);
  padding: 0 var(--bq-sp-5);
  position: sticky;
  top: 0;
  z-index: 30;
}

.bq-header__search {
  flex: 1;
  max-width: 480px;
  height: 36px;
  border: 1px solid var(--bq-line);
  border-radius: var(--bq-radius);
  padding: 0 var(--bq-sp-3);
  background: var(--bq-surface);
  font-size: var(--bq-fs-base);
}
.bq-header__search:focus {
  outline: none;
  border-color: var(--bq-green-700);
  background: #fff;
}

/* =====================================================================
   البطاقات والإحصائيات
   ===================================================================== */

.bq-card {
  background: var(--bq-card);
  border: 1px solid var(--bq-line);
  border-radius: var(--bq-radius);
  box-shadow: var(--bq-shadow-sm);
}
.bq-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--bq-sp-3) var(--bq-sp-4);
  border-bottom: 1px solid var(--bq-line-soft);
}
.bq-card__title { font-size: var(--bq-fs-md); font-weight: 600; color: var(--bq-green-900); margin: 0; }
.bq-card__body { padding: var(--bq-sp-4); }

/* بطاقة إحصائية */
.bq-stat { display: flex; align-items: center; gap: var(--bq-sp-4); padding: var(--bq-sp-4); }
.bq-stat__icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--bq-radius);
  background: var(--bq-green-50);
  color: var(--bq-green-700);
  font-size: 1.1rem;
}
.bq-stat__label { color: var(--bq-muted); font-size: var(--bq-fs-sm); margin: 0; }
.bq-stat__value { font-size: var(--bq-fs-xl); font-weight: 700; color: var(--bq-ink); line-height: 1.2; }
.bq-stat__delta { font-size: var(--bq-fs-xs); }
.bq-stat__delta--up   { color: var(--bq-success); }
.bq-stat__delta--down { color: var(--bq-danger); }

/* البطاقة التي تحتاج تصرّفاً — تحمل التمييز الذهبي */
.bq-stat--action .bq-stat__icon { background: var(--bq-gold-50); color: var(--bq-gold-700); }

/* =====================================================================
   الجداول — العنصر الأكثر استخداماً في النظام
   ===================================================================== */

.bq-table { width: 100%; font-size: var(--bq-fs-sm); border-collapse: collapse; }

.bq-table thead th {
  background: var(--bq-green-50);
  color: var(--bq-green-900);
  font-weight: 600;
  text-align: right;
  padding: var(--bq-sp-3);
  border-bottom: 2px solid var(--bq-green-200);
  white-space: nowrap;
  position: sticky;
  top: var(--bq-header-h);
  z-index: 10;
}

/* تحت 992px يصبح .table-responsive-lg حاوية تمرير أفقي، فيُحسب top للرأس اللاصق
   من أعلى الحاوية لا الصفحة ويغطي الصف الأول — لا لصق داخل حاوية التمرير */
@media (max-width: 991.98px) {
  .table-responsive-lg .bq-table thead th { position: static; }
}
.table-responsive .bq-table thead th { position: static; }

.bq-table tbody td {
  padding: var(--bq-sp-3);
  border-bottom: 1px solid var(--bq-line-soft);
  vertical-align: middle;
}
.bq-table tbody tr:hover { background: var(--bq-green-50); }

/* صف صافي الراتب في قسيمة الأجر */
.bq-table tr.is-total td {
  background: var(--bq-green-50);
  font-weight: 700;
  border-top: 2px solid var(--bq-green-700);
  border-bottom: none;
}

/* =====================================================================
   الشارات والحالات
   ===================================================================== */

.bq-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--bq-fs-xs);
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  line-height: 1.7;
  white-space: nowrap;
}
.bq-badge--success { background: var(--bq-success-bg); color: var(--bq-success); }
.bq-badge--warning { background: var(--bq-warning-bg); color: var(--bq-warning); }
.bq-badge--danger  { background: var(--bq-danger-bg);  color: var(--bq-danger); }
.bq-badge--info    { background: var(--bq-info-bg);    color: var(--bq-info); }
.bq-badge--neutral { background: var(--bq-line-soft);  color: var(--bq-ink-2); }

/*  خريطة الحالات إلى الألوان — التزم بها في كل الشاشات:
    معتمد / نشط / حاضر / مدفوع      → success
    قيد الانتظار / مسودة / قيد المراجعة → warning
    مرفوض / منتهٍ / غائب / ملغى      → danger
    في إجازة / قيد التنفيذ            → info
    مؤرشف / غير نشط                  → neutral                        */

/* =====================================================================
   الأزرار
   ===================================================================== */

.bq-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--bq-sp-2);
  height: 36px;
  padding: 0 var(--bq-sp-4);
  border-radius: var(--bq-radius-sm);
  border: 1px solid transparent;
  font-size: var(--bq-fs-base);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.bq-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.bq-btn--primary { background: var(--bq-green-700); color: #fff; }
.bq-btn--primary:hover { background: var(--bq-green-500); color: #fff; }

.bq-btn--ghost { background: #fff; border-color: var(--bq-line); color: var(--bq-ink-2); }
.bq-btn--ghost:hover { border-color: var(--bq-green-700); color: var(--bq-green-700); }

.bq-btn--danger { background: var(--bq-danger); color: #fff; }

/* الذهبي للإجراءات المميزة فقط — اعتماد نهائي، إصدار مسير.
   لا تستخدمه للحفظ العادي وإلا فقد معناه. */
.bq-btn--accent { background: var(--bq-gold-500); color: var(--bq-green-950); font-weight: 600; }
.bq-btn--accent:hover { background: var(--bq-gold-700); color: #fff; }

/* =====================================================================
   النماذج
   ===================================================================== */

.bq-label {
  display: block;
  font-size: var(--bq-fs-sm);
  color: var(--bq-ink-2);
  margin-bottom: var(--bq-sp-1);
  font-weight: 500;
}
.bq-label--required::after { content: " *"; color: var(--bq-danger); }

.bq-input, .bq-select, .bq-textarea {
  width: 100%;
  min-height: 38px;
  padding: var(--bq-sp-2) var(--bq-sp-3);
  border: 1px solid var(--bq-line);
  border-radius: var(--bq-radius-sm);
  font-family: inherit;
  font-size: var(--bq-fs-base);
  background: #fff;
  color: var(--bq-ink);
}
.bq-input:focus, .bq-select:focus, .bq-textarea:focus {
  outline: none;
  border-color: var(--bq-green-700);
  box-shadow: 0 0 0 3px rgba(0, 89, 82, 0.12);
}
.bq-input.is-invalid { border-color: var(--bq-danger); }

/* رسالة الخطأ تقول ما الخطأ وكيف يُصلَح — لا تعتذر ولا تُبهم */
.bq-error { color: var(--bq-danger); font-size: var(--bq-fs-xs); margin-top: var(--bq-sp-1); }
.bq-hint  { color: var(--bq-muted);  font-size: var(--bq-fs-xs); margin-top: var(--bq-sp-1); }

/* =====================================================================
   سير العمل — شريط تتبع الاعتمادات
   ===================================================================== */

.bq-flow { display: flex; align-items: flex-start; gap: 0; padding: var(--bq-sp-4) 0; }
.bq-flow__step { flex: 1; text-align: center; position: relative; }
.bq-flow__step::before {              /* الخط الواصل — RTL */
  content: "";
  position: absolute;
  top: 15px; right: 50%; left: -50%;
  height: 2px;
  background: var(--bq-line);
}
.bq-flow__step:first-child::before { display: none; }
.bq-flow__dot {
  position: relative;
  width: 32px; height: 32px;
  margin: 0 auto var(--bq-sp-2);
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--bq-line);
  display: grid; place-items: center;
  font-size: var(--bq-fs-xs);
  color: var(--bq-muted);
}
.bq-flow__step.is-done .bq-flow__dot    { background: var(--bq-success); border-color: var(--bq-success); color: #fff; }
.bq-flow__step.is-done::before          { background: var(--bq-success); }
.bq-flow__step.is-current .bq-flow__dot { border-color: var(--bq-gold-500); color: var(--bq-gold-700); box-shadow: 0 0 0 4px var(--bq-gold-50); }
.bq-flow__step.is-rejected .bq-flow__dot{ background: var(--bq-danger); border-color: var(--bq-danger); color: #fff; }
.bq-flow__label { font-size: var(--bq-fs-xs); color: var(--bq-ink-2); }

/* =====================================================================
   الحالة الفارغة — دعوة للتصرّف لا مجرد نص
   ===================================================================== */

.bq-empty { text-align: center; padding: var(--bq-sp-6) var(--bq-sp-4); color: var(--bq-muted); }
.bq-empty i { font-size: 2.5rem; color: var(--bq-green-200); margin-bottom: var(--bq-sp-3); display: block; }
.bq-empty h3 { color: var(--bq-ink-2); font-size: var(--bq-fs-md); margin-bottom: var(--bq-sp-2); }

/* =====================================================================
   الوصولية والتجاوب
   ===================================================================== */

:focus-visible {
  outline: 2px solid var(--bq-gold-500);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media (max-width: 992px) {
  .bq-sidebar {
    position: fixed;
    right: 0;
    transform: translateX(100%);       /* مخفية افتراضياً في RTL */
    transition: transform 0.2s ease;
    z-index: 40;
  }
  .bq-sidebar.is-open { transform: translateX(0); }
  .bq-content { padding: var(--bq-sp-3); }
  .bq-table { font-size: var(--bq-fs-xs); }
}

/* =====================================================================
   الطباعة — قسائم الرواتب والخطابات
   ===================================================================== */

@media print {
  .bq-sidebar, .bq-header, .bq-btn, .bq-no-print { display: none !important; }
  .bq-content { padding: 0; }
  .bq-card { border: none; box-shadow: none; }
  body { background: #fff; font-size: 11pt; }
  .bq-table thead th { position: static; background: #EEE; }
}

/* قائمة الإشعارات المنسدلة في الرأس (details/summary بلا مكتبات) */
.bq-notify > summary::-webkit-details-marker { display: none; }
.bq-notify > summary { cursor: pointer; }
