/* =====================================================================
   القصاص للعطور — نظام التصميم
   ---------------------------------------------------------------------
   Tailwind عبر CDN يتولّى التخطيط (المسافات، الشبكة، المحاذاة).
   هذا الملف يبني طبقة الدلالات: الألوان، الظلال، الحواف، المكوّنات.

   المبدأ: أبسط ما يمكن.
   • ثلاث فئات أبعاد فقط  (بطاقة / حقل / زر)
   • لون واحد للهوية (ذهبي) + لون حبر دافئ واحد للنصوص
   • ظلال خفيفة جداً — الحدّ الفاتح يقوم مقام الظل
   ===================================================================== */

:root {
  /* ---------- هوية العطور: ذهبي دافئ على ورق عاجي ---------- */
  --brand:        #b5842c;
  --brand-strong: #8f6518;
  --brand-soft:   #f6ecd8;
  --brand-ring:   rgba(181,132,44,.22);

  /* ---------- الحبر ---------- */
  --ink:          #1c1917;
  --ink-2:        #44403c;
  --ink-3:        #6b6560;
  --ink-4:        #9a938c;

  /* ---------- الأسطح ---------- */
  --canvas:       #f5f2ee;
  --surface:      #ffffff;
  --surface-2:    #faf8f5;
  --surface-3:    #f0ece7;

  /* ---------- الحدود ---------- */
  --line:         #e8e2da;
  --line-2:       #d8d0c5;

  /* ---------- دلالات الحالة ---------- */
  --ok:      #0f8a5f;
  --ok-bg:   #e6f6ef;
  --warn:    #b4700a;
  --warn-bg: #fdf3e2;
  --risk:    #c0364c;
  --risk-bg: #fdecee;
  --info:    #1f6fa8;
  --info-bg: #e8f2fa;

  /* ---------- الظلال (خفيفة جداً) ---------- */
  --sh-1: 0 1px 2px rgba(28,25,23,.05);
  --sh-2: 0 2px 8px -2px rgba(28,25,23,.10), 0 1px 2px rgba(28,25,23,.05);
  --sh-3: 0 16px 40px -12px rgba(28,25,23,.22);

  /* ---------- الأنصاف ---------- */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* ---------- إيقاع ---------- */
  --gut: 1.25rem;

  --font: 'Tajawal', 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--ink-2);
}

/* --------------------------- الأرقام ------------------------------- */
.tabular-nums, .tnum, .num, .figure, .data-table td {
  font-variant-numeric: tabular-nums;
}

.mono { font-family: Consolas, 'Courier New', ui-monospace, monospace; }

/* الرقم الكبير في بطاقات المؤشرات */
.figure {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.12;
  letter-spacing: -.02em;
}

/* ------------------------- شريط التمرير ---------------------------- */
::-webkit-scrollbar        { width: 9px; height: 9px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--line-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ================================================================== */
/* 1) عناصر الإدخال — شكل واحد لكل الحقول                             */
/* ================================================================== */
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: .3rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: .5rem .7rem;
  font-family: inherit;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  outline: none;
  transition: border-color .12s, box-shadow .12s, background-color .12s;
}
.form-input::placeholder { color: var(--ink-4); }

.form-input:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.form-input:disabled,
.form-select:disabled { background: var(--surface-3); color: var(--ink-4); cursor: not-allowed; }

.form-input.is-error,
.form-select.is-error { border-color: var(--risk); }
.form-input.is-error:focus,
.form-select.is-error:focus { box-shadow: 0 0 0 3px rgba(192,54,76,.15); }

.form-hint { font-size: .7rem; color: var(--ink-4); margin-top: .25rem; }

/* سهم القائمة المنسدلة على اليسار (RTL) */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b6560'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left .6rem center;
  background-size: 1em;
  padding-left: 2rem;
  padding-right: .7rem;
}

.form-check {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  accent-color: var(--brand);
  cursor: pointer;
  flex: none;
}

/* ================================================================== */
/* 2) الأزرار                                                          */
/* ================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .9rem;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.3rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s, opacity .12s, transform .06s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(28,25,23,.10);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-2);
  box-shadow: var(--sh-1);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-4); }

/* بديل ناعم — للإجراءات الثانوية داخل الصفوف */
.btn-soft {
  background: var(--brand-soft);
  color: var(--brand-strong);
  border-color: transparent;
}
.btn-soft:hover:not(:disabled) { background: #f0e2c6; }

.btn-ghost { background: transparent; color: var(--ink-3); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }

.btn-danger { background: var(--risk); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a12a3d; }

.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover:not(:disabled) { background: #0b7049; }

.btn-sm  { padding: .3rem .6rem; font-size: .75rem; line-height: 1.1rem; border-radius: var(--r-sm); gap: .3rem; }
.btn-icon { width: 2rem; height: 2rem; padding: 0; border-radius: var(--r-sm); }
.btn-icon.btn-sm { width: 1.9rem; height: 1.9rem; }

/* ================================================================== */
/* 3) البطاقات — الحد الفاتح يقوم مقام الظل                           */
/* ================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-hover { transition: box-shadow .14s, border-color .14s; }
.card-hover:hover { box-shadow: var(--sh-2); border-color: var(--line-2); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .8rem 1.15rem;
  border-bottom: 1px solid var(--line);
  min-height: 3rem;
}
.card-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 700;
  color: var(--ink);
}
.card-sub { font-size: .72rem; color: var(--ink-4); font-weight: 500; }
.card-body { padding: 1.15rem; }
.card-foot {
  padding: .8rem 1.15rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* عنوان قسم في الصفحة (بدل تكرار عناوين ضخمة) */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.01em;
}
.page-sub { font-size: .8rem; color: var(--ink-3); margin-top: .15rem; }

/* ================================================================== */
/* 4) الجداول                                                          */
/* ------------------------------------------------------------------ */
/*  نستخدم :where() عمداً حتىSpecificity = 0، فتتفوّق دائماً على  */
/*  أصناف Tailwind داخل القوالب ولا يتضارب أي تنسيق.                    */
/* ================================================================== */
.table-scroll {
  overflow: auto;
  max-height: var(--table-max, none);
}

/* رأس ثابت أثناء التمرير داخل الجدول الطويل */
:where(.data-table) :where(thead th) {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* تمييز العمود الرقمي والأرقام دائماً بعرض ثابت */
:where(.data-table) :where(td),
:where(.data-table) :where(th) {
  font-variant-numeric: tabular-nums;
}

/* عمود الأزرار لا يتمدّد */
:where(.data-table) :where(.col-actions) { width: 1%; white-space: nowrap; }

/* جدول بسيط بلا أصناف — الشكل الأساسي */
:where(table.data-table-base) {
  width: 100%;
  font-size: .84rem;
  border-collapse: separate;
  border-spacing: 0;
}
:where(table.data-table-base) :where(th) {
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: .7rem;
  font-weight: 700;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
:where(table.data-table-base) :where(td) {
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--surface-3);
  color: var(--ink-2);
  vertical-align: middle;
}
:where(table.data-table-base) :where(tbody tr:hover) { background: var(--surface-2); }
:where(table.data-table-base) :where(tfoot td) {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--ink);
  border-top: 1px solid var(--line-2);
  border-bottom: 0;
}

/* ================================================================== */
/* 5) الشارات والرقائق                                                 */
/* ================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .45rem;
  border-radius: var(--r-sm);
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.45;
  box-shadow: inset 0 0 0 1px currentColor;
  --tw-ring-color: transparent;
}
.badge-lg { font-size: .75rem; padding: .25rem .55rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .5rem;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: .72rem;
  font-weight: 600;
}

/* رابط نصي بسيط */
.link { color: var(--brand-strong); font-weight: 600; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ================================================================== */
/* 6) أشرطة التقدّم                                                    */
/* ================================================================== */
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; transition: width .3s ease; }
.bar-emerald > span { background: var(--ok); }
.bar-amber   > span { background: #d99b12; }
.bar-rose    > span { background: var(--risk); }
.bar-sky     > span { background: var(--info); }
.bar-slate   > span { background: var(--ink-4); }
.bar-brand   > span { background: var(--brand); }

/* ================================================================== */
/* 7) الفلاتر والأشرطة                                                  */
/* ================================================================== */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: .9rem 1rem;
  margin-bottom: 1rem;
}

/* مجموعة أزرار متجاورة (تبويبات مسطّحة) */
.tabs {
  display: flex;
  gap: .15rem;
  padding: .2rem;
  background: var(--surface-3);
  border-radius: var(--r);
  overflow-x: auto;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .7rem;
  border-radius: var(--r-sm);
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.tab:hover { color: var(--ink); }
.tab-on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* ================================================================== */
/* 8) حالة فارغة                                                      */
/* ================================================================== */
.empty-state { padding: 2.75rem 1.25rem; text-align: center; }
.empty-icon {
  width: 3rem; height: 3rem;
  margin: 0 auto .75rem;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--surface-3);
  color: var(--ink-4);
}
.empty-title { font-size: .9rem; font-weight: 700; color: var(--ink); }
.empty-hint  { font-size: .78rem; color: var(--ink-4); margin-top: .2rem; }

/* ================================================================== */
/* 9) لوحة الأوامر (Ctrl+K)                                            */
/* ================================================================== */
.cmdk-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(28,25,23,.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: start center;
  padding-top: 12vh;
}
.cmdk {
  width: min(40rem, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
.cmdk-input {
  width: 100%;
  border: 0;
  outline: none;
  padding: 1rem 1.1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border-bottom: 1px solid var(--line);
}
.cmdk-input::placeholder { color: var(--ink-4); }
.cmdk-list { max-height: 22rem; overflow-y: auto; padding: .35rem; }
.cmdk-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .7rem;
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: .86rem;
  cursor: pointer;
}
.cmdk-item-on { background: var(--brand-soft); color: var(--brand-strong); }
.cmdk-item small { color: var(--ink-4); font-size: .7rem; }
.cmdk-foot {
  display: flex; gap: 1rem; align-items: center;
  padding: .5rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: .7rem;
  color: var(--ink-4);
}
kbd {
  display: inline-block;
  min-width: 1.4rem;
  text-align: center;
  padding: .1rem .3rem;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font-family: inherit;
  font-size: .68rem;
  font-weight: 700;
  color: var(--ink-3);
}

/* ================================================================== */
/* 10) قوائم منسدلة صغيرة (تنبيهات، مستخدم)                           */
/* ================================================================== */
.pop {
  position: absolute;
  z-index: 60;
  min-width: 15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
.pop-head {
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-size: .72rem;
  font-weight: 700;
  color: var(--ink-3);
}
.pop-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .85rem;
  font-size: .8rem;
  color: var(--ink-2);
  transition: background-color .1s;
}
.pop-item:hover { background: var(--surface-2); }
.pop-sep { height: 1px; background: var(--line); }

/* ================================================================== */
/* 11) حالات الألوان الدلالية (بديل عن تكرارات bg-… في كل ملف)      */
/* ================================================================== */
.t-ok   { color: var(--ok); }
.t-warn { color: var(--warn); }
.t-risk { color: var(--risk); }
.t-info { color: var(--info); }
.t-mute { color: var(--ink-4); }

.bg-ok   { background: var(--ok-bg);   color: var(--ok); }
.bg-warn { background: var(--warn-bg); color: var(--warn); }
.bg-risk { background: var(--risk-bg); color: var(--risk); }
.bg-info { background: var(--info-bg); color: var(--info); }

/* سطر تنبيه كامل العرض */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .7rem .9rem;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: .82rem;
  color: var(--ink-2);
  line-height: 1.7;
}
.alert-ok   { background: var(--ok-bg);   border-color: #bfe6d4; color: #0a6144; }
.alert-warn { background: var(--warn-bg); border-color: #f0dcae; color: #8a5608; }
.alert-risk { background: var(--risk-bg); border-color: #f3ccd2; color: #93293b; }
.alert-info { background: var(--info-bg); border-color: #cbe0ef; color: #17587f; }

/* فاصل */
.hr { height: 1px; background: var(--line); border: 0; margin: 1rem 0; }

/* ================================================================== */
/* 12) حركة دقيقة                                                      */
/* ================================================================== */
@keyframes qs-slide-down { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes qs-fade-in    { from { opacity: 0; } to { opacity: 1; } }
@keyframes qs-pop        { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.flash-item { animation: qs-slide-down .2s ease-out; }
.pop        { animation: qs-pop .14s ease-out; }
.cmdk       { animation: qs-pop .16s ease-out; }

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

/* ================================================================== */
/* 13) الطباعة                                                        */
/* ================================================================== */
.print-header { display: none; }

@media print {
  @page { size: A4; margin: 12mm 10mm; }

  body { background: #fff !important; font-size: 10.5px; }

  .print\:hidden, .no-print { display: none !important; }
  .lg\:mr-72, .xl\:mr-72 { margin-right: 0 !important; }
  main { padding: 0 !important; }

  .print-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding-bottom: .5rem;
    margin-bottom: .75rem;
    border-bottom: 1.5px solid var(--ink);
  }

  .card, .table-scroll { box-shadow: none !important; border-color: #c9c2b8 !important; }
  .data-table th { position: static; background: #f3efe9 !important; }
  .data-table td, .data-table th { padding: .3rem .35rem !important; }

  a { text-decoration: none !important; color: inherit !important; }
  table { page-break-inside: auto; }
  tr    { page-break-inside: avoid; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  .avoid-break { page-break-inside: avoid; }
  .page-break { page-break-before: page; }
}

/* ================================================================== */
/* 14) عناصر مخفية ديناميكية                                          */
/* ================================================================== */
[hidden] { display: none !important; }

@media (max-width: 1023px) {
  .card-body { padding: 1rem; }
  .card-head { padding: .7rem 1rem; }
  :root { --gut: 1rem; }
}