/* ============================================================
   العمق — طبقة ثلاثية الأبعاد لواجهات البرامج
   مبدأ واحد: ضوء من الأعلى، وكل جسم تفاعلي له سُمك يُضغط.

   الترتيب: حمّل هذا الملف *بعد* tokens.css من مهارة huwiya.
   يأخذ ألوانه من رموز الهوية حين تكون موجودة، وإلا استعمل بدائل.
   ============================================================ */

:root {
  /* مثلّث الحبر لظلال شفافة — غيّره لو كانت هويتك أدفأ */
  --d-ink: 11, 34, 48;

  --d-lift: 4px;                    /* سُمك الجسم الأساسي */
  --d-edge: #b5c3cc;                /* حافة محايدة */
  --d-hi:   #fff;                   /* الضوء العلوي */

  --d-r:   20px;                    /* بطاقة */
  --d-r-s: 13px;                    /* زر وحقل */

  /* الأسطح الطافية — انتشار سالب ليتجمّع الظل تحت الجسم */
  --d-sh-1: 0 1px 0 #fff inset,
            0 2px 4px rgba(var(--d-ink), .05),
            0 10px 22px -12px rgba(var(--d-ink), .22);
  --d-sh-2: 0 1px 0 #fff inset, 0 -1px 0 rgba(var(--d-ink), .04) inset,
            0 2px 4px rgba(var(--d-ink), .05),
            0 14px 26px -14px rgba(var(--d-ink), .22),
            0 36px 54px -36px rgba(var(--d-ink), .30);
  --d-sh-3: 0 2px 0 rgba(255,255,255,.7) inset,
            0 4px 6px rgba(var(--d-ink), .06),
            0 26px 40px -18px rgba(var(--d-ink), .32),
            0 60px 80px -50px rgba(var(--d-ink), .4);

  /* السطح الغائر — كل ما يُملأ لا يُضغط */
  --d-in: inset 0 2px 4px rgba(var(--d-ink), .09), 0 1px 0 #fff;
}

/* ============================================================
   الغرفة — مصدرا ضوء خافتان في زاويتين متقابلتين.
   fixed ضرورية: لو تحرّك الضوء مع التمرير انهار الإيهام.
   ============================================================ */
.room {
  background:
    radial-gradient(1100px 560px at 88% -8%, rgba(62,157,109,.16) 0, transparent 60%),
    radial-gradient(900px 520px at -8% 108%, rgba(184,137,58,.14) 0, transparent 58%),
    var(--bg, #e9eff1);
  background-attachment: fixed;
}

/* ============================================================
   البطاقة — تطفو فوق الغرفة
   ============================================================ */
.card {
  position: relative;
  background: linear-gradient(180deg, #fff 0%, #f8fbfc 100%);
  border: 1px solid rgba(var(--d-ink), .06);
  border-radius: var(--d-r);
  box-shadow: var(--d-sh-2);
  padding: 22px;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
}
.card.flat { box-shadow: var(--d-sh-1); }
.card.pad0 { padding: 0; overflow: hidden; }

/* الإمالة — تحتاج tilt.js لضبط ‎--rx/--ry/--gx/--gy */
.tilt { transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
        will-change: transform; }
.tilt::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(360px circle at var(--gx, 50%) var(--gy, 0%),
              rgba(255,255,255,.65), transparent 55%);
  opacity: 0; transition: opacity .25s; mix-blend-mode: soft-light;
}
.tilt.on { box-shadow: var(--d-sh-3); }
.tilt.on::after { opacity: 1; }

/* ============================================================
   الأزرار — قانون حفظ الارتفاع:
   translateY + الحافة = ثابت، وإلا بدا الزر ينزلق لا يُضغط.
   ============================================================ */
.btn {
  --c1: #ffffff; --c2: #eaf0f3; --c3: var(--d-edge);
  --hi: var(--d-hi);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; user-select: none; white-space: nowrap; text-decoration: none;
  padding: 10px 20px; border-radius: var(--d-r-s); font-weight: 600; font-size: 14.5px;
  color: var(--ink, #0b2230);
  background: linear-gradient(180deg, var(--c1), var(--c2));
  border: 1px solid var(--c3);
  box-shadow: 0 1px 0 var(--hi) inset,
              0 var(--d-lift) 0 var(--c3),
              0 10px 16px -6px rgba(var(--d-ink), .32);
  transform: translateY(0);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 0 var(--hi) inset,
              0 calc(var(--d-lift) + 2px) 0 var(--c3),
              0 16px 20px -8px rgba(var(--d-ink), .34);
}
.btn:active {
  transform: translateY(var(--d-lift));
  box-shadow: 0 1px 0 var(--hi) inset, 0 0 0 var(--c3),
              0 2px 4px rgba(var(--d-ink), .3);
}
.btn:focus-visible { outline: 3px solid rgba(46,127,184,.45); outline-offset: 2px; }
.btn[disabled], .btn.off { opacity: .55; pointer-events: none; filter: grayscale(.4); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* الثلاثيات معايَرة على لوحة الوزارة من huwiya.
   c2 = لونك · c1 أفتح ‎~18% · c3 أغمق ‎~20% ويجب أن يكون أغمق بوضوح. */
.btn.p, .btn.pri { --c1: #4d9ad0; --c2: #2e7fb8; --c3: #1f5c88;
  --hi: rgba(255,255,255,.35); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn.g, .btn.ok  { --c1: #26a877; --c2: #17825c; --c3: #0d5c41;
  --hi: rgba(255,255,255,.3); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn.d, .btn.dan { --c1: #d66565; --c2: #b23b3b; --c3: #832626;
  --hi: rgba(255,255,255,.3); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn.gold        { --c1: #dcae63; --c2: #b8893a; --c3: #85621f;
  --hi: rgba(255,255,255,.5); color: #3a2806; }
.btn.navy, .btn.deep { --c1: #0a6272; --c2: #033b45; --c3: #01232a;
  --hi: rgba(255,255,255,.18); color: #fff; }

.btn.ghost { --c3: transparent; background: none; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: rgba(var(--d-ink), .06); transform: none; box-shadow: none; }
.btn.ghost:active { transform: scale(.97); }

.btn.sm { --d-lift: 3px; padding: 7px 14px; font-size: 13.5px; border-radius: 11px; }
.btn.xs { --d-lift: 2px; padding: 4px 10px; font-size: 12.5px; border-radius: 9px; }
.btn.lg { --d-lift: 5px; padding: 14px 28px; font-size: 16.5px; border-radius: 16px; }
.btn.icon  { padding: 9px; width: 40px; height: 40px; }
.btn.block { width: 100%; }

/* ============================================================
   الحقول — غائرة، لأنها تُملأ ولا تُضغط
   ============================================================ */
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=tel], input[type=search], input[type=email], input:not([type]),
select, textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--d-r-s);
  border: 1px solid var(--line-2, #c9d6dd); outline: none;
  background: linear-gradient(180deg, #f3f7f9, #fff);
  box-shadow: var(--d-in);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.85; }
input:focus, select:focus, textarea:focus {
  border-color: var(--g2, #2e7fb8);
  box-shadow: inset 0 2px 4px rgba(var(--d-ink), .07), 0 0 0 4px rgba(46,127,184,.2);
}
input::placeholder, textarea::placeholder { color: #9bb0bb; }

/* ============================================================
   المسارات الغائرة — التبويبات وأشرطة النسب
   ============================================================ */
.seg { display: inline-flex; padding: 5px; gap: 4px; border-radius: 16px;
       background: #dbe5ea; flex-wrap: wrap;
       box-shadow: inset 0 3px 5px rgba(var(--d-ink), .16), 0 1px 0 #fff; }
.seg button { border: 0; background: none; cursor: pointer; padding: 8px 16px;
  border-radius: 12px; font-weight: 600; font-size: 14px;
  color: var(--ink-2, #33505f); transition: .18s; }
.seg button:hover { color: var(--ink, #0b2230); }
.seg button.on {
  color: var(--ink, #0b2230); transform: translateY(-1px);
  background: linear-gradient(180deg, #fff, #f1f6f8);
  box-shadow: 0 1px 0 #fff inset, 0 3px 0 var(--d-edge),
              0 8px 12px -6px rgba(var(--d-ink), .35);
}

/* شريط نسبة: مسار غائر ووجه مرفوع فوقه */
.b3 { position: relative; display: flex; height: 13px; border-radius: 8px; background: #d9e3e8;
      box-shadow: inset 0 3px 4px rgba(var(--d-ink), .2), 0 1px 0 #fff; margin: 4px 0 8px; }
.b3 > i {
  --c1: #4d9ad0; --c2: #2e7fb8; --c3: #1f5c88;
  display: block; height: 100%; width: var(--w, 0%); border-radius: 8px;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow: 0 4px 0 var(--c3), 0 8px 8px -3px rgba(var(--d-ink), .35),
              inset 0 1px 0 rgba(255,255,255,.55);
  transform: translateY(-2px);
  transition: width .9s cubic-bezier(.2,.9,.2,1);
}
.b3 > i.ok   { --c1: #26a877; --c2: #17825c; --c3: #0d5c41; }
.b3 > i.warn { --c1: #dcae63; --c2: #b8893a; --c3: #85621f; }
.b3 > i.dan  { --c1: #d66565; --c2: #b23b3b; --c3: #832626; }
.b3.thin { height: 9px; }
.b3.tall { height: 18px; border-radius: 10px; }

/* ============================================================
   المفتاح — مسار غائر وقرص مرفوع
   ============================================================ */
.switch { position: relative; display: inline-flex; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 2; margin: 0;
                width: 100%; height: 100%; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: #c4d1d8;
            box-shadow: inset 0 2px 4px rgba(var(--d-ink), .25); transition: .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(180deg, #fff, #e6edf1);
  box-shadow: 0 2px 4px rgba(var(--d-ink), .35); transition: .2s; }
.switch input:checked + i { background: linear-gradient(180deg, #4d9ad0, #2e7fb8); }
.switch input:checked + i::after { right: 23px; }

/* ============================================================
   مكعّب الأرقام — أبرز عنصر في اللوحة
   145deg لا 180deg: إضاءة قطرية تُظهر وجهين لا وجهاً واحداً.
   ============================================================ */
.kpi { display: flex; align-items: center; gap: 16px; }
.kpi .cube {
  --c1: #4d9ad0; --c2: #2e7fb8; --c3: #1f5c88;
  width: 58px; height: 58px; flex: none; display: grid; place-items: center;
  color: #fff; border-radius: 17px;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  box-shadow: inset 0 2px 2px rgba(255,255,255,.55), inset 0 -5px 8px rgba(0,0,0,.2),
              0 8px 0 -1px var(--c3), 0 16px 18px -6px rgba(var(--d-ink), .4);
  transform: translateY(-4px) rotate(-3deg);
  transition: transform .25s;
}
.card:hover .kpi .cube { transform: translateY(-7px) rotate(3deg); }
.kpi .cube svg { width: 27px; height: 27px; filter: drop-shadow(0 2px 1px rgba(0,0,0,.25)); }
.kpi .cube.ok   { --c1: #26a877; --c2: #17825c; --c3: #0d5c41; }
.kpi .cube.gold { --c1: #dcae63; --c2: #b8893a; --c3: #85621f; color: #4a3407; }
.kpi .cube.dan  { --c1: #d66565; --c2: #b23b3b; --c3: #832626; }
.kpi .cube.deep { --c1: #0a6272; --c2: #033b45; --c3: #01232a; }
.kpi .num { font-family: var(--disp, serif); font-size: 36px; font-weight: 700; line-height: 1.05;
            font-variant-numeric: tabular-nums; }
.kpi .lbl { font-size: 13px; color: var(--ink-3, #6a8391); margin-top: 2px; }

/* ============================================================
   الجداول — كل صف بطاقة تطفو
   ============================================================ */
.tw { overflow: auto; border-radius: 16px; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 14px; }
table.t th { position: sticky; top: 0; z-index: 2; text-align: right; background: transparent;
  font-size: 12.5px; font-weight: 700; color: var(--ink-3, #6a8391);
  padding: 4px 14px; white-space: nowrap; }
table.t td { padding: 12px 14px; background: #fff; vertical-align: middle;
  border-top: 1px solid var(--line, #dbe4e9); border-bottom: 1px solid var(--line, #dbe4e9); }
table.t td:first-child { border-right: 1px solid var(--line, #dbe4e9); border-radius: 0 14px 14px 0; }
table.t td:last-child  { border-left:  1px solid var(--line, #dbe4e9); border-radius: 14px 0 0 14px; }
table.t tbody tr { transition: transform .15s, filter .15s;
                   filter: drop-shadow(0 3px 3px rgba(var(--d-ink), .05)); }
table.t tbody tr:hover { transform: translateY(-2px) scale(1.002);
                         filter: drop-shadow(0 10px 8px rgba(var(--d-ink), .12)); }

/* ============================================================
   النوافذ والإشعارات — تدخل بدوران حول المحور الأفقي
   ============================================================ */
.modal-bg { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 18px; overflow-y: auto; perspective: 1400px;
  background: rgba(6,26,37,.55); backdrop-filter: blur(6px); animation: d-fade .2s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 36px);
  display: flex; flex-direction: column; border-radius: 24px;
  background: linear-gradient(180deg, #fff, #f6fafb);
  box-shadow: var(--d-sh-3), 0 0 0 1px rgba(255,255,255,.4) inset;
  animation: d-pop .42s cubic-bezier(.2,1.1,.3,1); transform-origin: 50% 100%; }
@keyframes d-fade { from { opacity: 0; } }
@keyframes d-pop  { from { opacity: 0; transform: rotateX(16deg) translateY(50px) scale(.94); } }

.rise { animation: d-rise .55s cubic-bezier(.2,.9,.2,1) both;
        animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes d-rise { from { opacity: 0; transform: translateY(24px) rotateX(10deg); } }

/* ============================================================
   من لا يريد حركة — احترم إعداده
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .tilt { transform: none !important; }
}

/* ============================================================
   الطباعة — الظلال تخرج بقعاً رمادية على الورق
   ============================================================ */
@media print {
  body, .room { background: #fff !important; }
  .card, .btn, .seg, .modal, .kpi .cube, table.t tbody tr {
    box-shadow: none !important; filter: none !important; transform: none !important;
  }
  .card { border: 1px solid #cbd6df !important; }
}
