/* ───────────────────────────────────────────────────────────────
   Itqan ERP · إتقان — motion UI: splash + loaders
   Every shape and every slant here comes from the logo's 30° qalam cut.
   Colours follow the page theme; override any --itqan-m-* variable.
   ─────────────────────────────────────────────────────────────── */
:root {
  --itqan-m-ink:        var(--itqan-navy-900, #0B1F3A);
  --itqan-m-accent:     var(--itqan-gold-500, #C9A24D);
  --itqan-m-rule:       var(--itqan-gold-500, #C9A24D);
  --itqan-m-track:      #E3E8EF;
  --itqan-m-skel:       #EEF1F5;
  --itqan-m-skel-hl:    #F9FAFC;
  --itqan-m-splash-bg:  var(--itqan-navy-900, #0B1F3A);
  --itqan-m-ease:       cubic-bezier(.32,.08,.24,1);
}
[data-theme="dark"], [data-bs-theme="dark"], .itqan-on-dark {
  --itqan-m-ink: #F5F1EA; --itqan-m-accent: #DAB060; --itqan-m-rule: #DAB060;
  --itqan-m-track: #23405F; --itqan-m-skel: #16304F; --itqan-m-skel-hl: #21426A;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --itqan-m-ink: #F5F1EA; --itqan-m-accent: #DAB060; --itqan-m-rule: #DAB060;
    --itqan-m-track: #23405F; --itqan-m-skel: #16304F; --itqan-m-skel-hl: #21426A;
  }
}
.itqan-on-light {
  --itqan-m-ink: #0B1F3A; --itqan-m-accent: #C9A24D; --itqan-m-rule: #C9A24D;
  --itqan-m-track: #E3E8EF; --itqan-m-skel: #EEF1F5; --itqan-m-skel-hl: #F9FAFC;
}

/* ═══ shared loader box ═══ */
.itqan-loader { display: inline-grid; place-items: center; gap: .6em; color: var(--itqan-m-ink);
  font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; line-height: 1.4; }
.itqan-loader .im-svg { width: var(--im-size, 64px); height: auto; display: block; overflow: visible; }
.itqan-loader__label { font-size: 13px; color: inherit; opacity: .72; }
.itqan-loader--page { position: fixed; inset: 0; display: grid; place-content: center; z-index: 50;
  background: var(--itqan-m-page-bg, transparent); }

/* ═══ 1 · orbit — seven blades circle the whole letter, counter-clockwise ═══ */
.itqan-loader--orbit { --im-period: 1.6s; }
.im-ob     { transform-origin: 100px 89px; animation: im-orbit var(--im-period) linear infinite;
             animation-delay: calc(var(--i) * var(--im-period) / -7); }
.im-ob-in  { transform-origin: 174px 89px; animation: im-orbit-depth var(--im-period) linear infinite;
             animation-delay: calc(var(--i) * var(--im-period) / -7); }
@keyframes im-orbit { to { transform: rotate(-360deg); } }
@keyframes im-orbit-depth {
  0%   { transform: rotate(0deg)   scale(1.12); opacity: 1;   }
  25%  { transform: rotate(90deg)  scale(1);    opacity: .8;  }
  50%  { transform: rotate(180deg) scale(.86);  opacity: .5;  }
  75%  { transform: rotate(270deg) scale(1);    opacity: .8;  }
  100% { transform: rotate(360deg) scale(1.12); opacity: 1;   }
}

/* ═══ 2 · blades — the seven blades light right → left; doubles as a 7-step progress ═══ */
.im-bb { opacity: .2; transform-box: fill-box; transform-origin: 50% 100%;
         animation: im-seq 1.8s var(--itqan-m-ease) infinite both; animation-delay: calc(var(--j) * .11s); }
@keyframes im-seq {
  0%   { opacity: .2; transform: none; }
  9%   { opacity: 1;  transform: translateY(-4px); }
  17%  { opacity: 1;  transform: none; }
  60%  { opacity: 1; }
  80%, 100% { opacity: .2; }
}
.itqan-loader.is-determinate .im-bb { animation: none; opacity: .2; transition: opacity .24s var(--itqan-m-ease); }
.itqan-loader.is-determinate .im-bb.is-on { opacity: 1; }

/* ═══ 3 · spinner — seven blades set radially, compact (buttons, cells) ═══ */
.itqan-loader--spinner { --im-size: 20px; }
.im-sp { opacity: .16; animation: im-sp-fade .91s linear infinite; animation-delay: calc(var(--k) * -.13s); }
@keyframes im-sp-fade { 0% { opacity: 1; } 100% { opacity: .16; } }

/* ═══ 4 · qalam — the mark writes itself, holds, and lifts ═══ */
.im-qa { transform-box: fill-box; transform-origin: 50% 0; animation: im-qa 2.4s var(--itqan-m-ease) infinite; }
.im-qh { transform-box: fill-box; transform-origin: 50% 100%; animation: im-qh 2.4s var(--itqan-m-ease) infinite; }
.im-qb { animation: im-qb 2.4s var(--itqan-m-ease) infinite both; animation-delay: calc(var(--j) * .06s); }
@keyframes im-qa { 0% { transform: scaleY(0); opacity: 1; } 24% { transform: scaleY(1); }
                   78% { transform: scaleY(1); opacity: 1; } 92%, 100% { transform: scaleY(1); opacity: 0; } }
@keyframes im-qh { 0%, 18% { opacity: 0; transform: translateY(6px) scale(.7); } 32% { opacity: 1; transform: none; }
                   78% { opacity: 1; } 92%, 100% { opacity: 0; } }
@keyframes im-qb { 0%, 30% { opacity: 0; transform: translateY(-10px); } 40% { opacity: 1; transform: none; }
                   78% { opacity: 1; } 92%, 100% { opacity: 0; } }

/* ═══ 5 · top bar — route changes; segment travels right → left with 30° cut ends ═══ */
.itqan-topbar { position: relative; height: var(--im-bar-h, 3px); background: var(--itqan-m-track);
  overflow: hidden; width: 100%; }
.itqan-topbar--fixed { position: fixed; inset: 0 0 auto 0; z-index: 60; background: transparent; }
.itqan-topbar__seg { position: absolute; top: 0; bottom: 0; left: 0; width: 38%;
  background: var(--itqan-m-accent);
  clip-path: polygon(calc(var(--im-bar-h, 3px) * .577) 0, 100% 0, calc(100% - var(--im-bar-h, 3px) * .577) 100%, 0 100%);
  animation: im-bar 1.5s cubic-bezier(.65,.05,.36,1) infinite; }
.itqan-topbar__seg + .itqan-topbar__seg { width: 18%; animation-delay: .62s; }
@keyframes im-bar { from { transform: translateX(270%); } to { transform: translateX(-110%); } }
.itqan-topbar__fill { position: absolute; top: 0; bottom: 0; right: 0; width: calc(var(--p, 0) * 100%);
  background: var(--itqan-m-accent); transition: width .3s var(--itqan-m-ease);
  clip-path: polygon(calc(var(--im-bar-h, 3px) * .577) 0, 100% 0, 100% 100%, 0 100%); }

/* ═══ 6 · skeleton — placeholders; the sheen leans at the qalam angle and sweeps right → left ═══ */
.itqan-skeleton { position: relative; overflow: hidden; background: var(--itqan-m-skel);
  border-radius: 6px; min-height: .9em; }
.itqan-skeleton::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, var(--itqan-m-skel-hl) 50%, transparent 70%);
  transform: translateX(100%); animation: im-sheen 1.5s var(--itqan-m-ease) infinite; }
@keyframes im-sheen { to { transform: translateX(-100%); } }
.itqan-skeleton--line   { height: .8em; border-radius: 4px; }
.itqan-skeleton--title  { height: 1.3em; width: 45%; border-radius: 5px; }
.itqan-skeleton--avatar { width: 40px; height: 40px; border-radius: 9999px; }
.itqan-skeleton--block  { height: 120px; border-radius: 14px; }
.itqan-skeleton-stack   { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); width: 100%; }

/* ═══ splash ═══ */
.itqan-splash { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center;
  background: var(--itqan-m-splash-bg); transition: opacity .38s var(--itqan-m-ease);
  --itqan-m-ink: #F5F1EA; --itqan-m-accent: #C9A24D; --itqan-m-rule: #C9A24D; }
.itqan-splash.itqan-on-light { --itqan-m-splash-bg: #F5F1EA; --itqan-m-ink: #0B1F3A; }
.itqan-splash--inline { position: relative; inset: auto; width: 100%; height: 100%; }
.itqan-splash .im-splash-art { width: min(58vw, 260px); height: auto; overflow: visible;
  transition: transform .38s var(--itqan-m-ease); }
.itqan-splash--inline .im-splash-art { width: min(64%, 260px); }
.itqan-splash .im-alif { transform-box: fill-box; transform-origin: 50% 0; }
.itqan-splash .im-hz   { transform-box: fill-box; transform-origin: 50% 100%; }
.itqan-splash .im-sb, .itqan-splash .im-wm { transform-box: view-box; transform-origin: 0 0; }
.itqan-splash.is-idle .im-sb > path { animation: im-idle 1.6s var(--itqan-m-ease) infinite;
  animation-delay: calc(var(--j, 0) * .1s); }
@keyframes im-idle { 0%, 100% { opacity: 1; } 35% { opacity: .38; } }
.itqan-splash.is-exit { opacity: 0; pointer-events: none; }
.itqan-splash.is-exit .im-splash-art { transform: scale(1.06); }

/* ═══ reduced motion: hold still, breathe gently ═══ */
@media (prefers-reduced-motion: reduce) {
  .im-ob, .im-ob-in, .im-sp { animation-play-state: paused !important; }
  .im-bb, .im-qa, .im-qh, .im-qb { animation: none !important; opacity: 1; transform: none; }
  .itqan-loader .im-svg { animation: im-breathe 1.8s ease-in-out infinite; }
  .itqan-topbar__seg { animation: none; transform: none; width: 100%; opacity: .6; }
  .itqan-skeleton::after { animation: none; display: none; }
  .itqan-skeleton { animation: im-breathe 1.8s ease-in-out infinite; }
  .itqan-splash.is-idle .im-sb > path { animation: none; }
}
@keyframes im-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
