/* Fursa UI v2 — loading spinners (v2/loading.js). A veil with a spinner over
   the part of the page that is changing, and a small spinner inside a field
   while typing asks the server. Replaces the old top progress bar. */

html[data-ui="v2"] .fx-busy--rel{position:relative}
html[data-ui="v2"] .fx-busy-veil{
  position:absolute;inset:0;z-index:var(--fx-z-sticky);
  display:flex;justify-content:center;align-items:center;
  border-radius:inherit;
  background:color-mix(in srgb, var(--fx-surface) 55%, transparent);
  cursor:progress;
  animation:fx-busy-in var(--fx-dur-fast, .15s) ease-out both;
}
/* The page card can be taller than the screen: keep the spinner in view. */
html[data-ui="v2"] .fx-busy-veil--page{align-items:flex-start;background:color-mix(in srgb, var(--fx-bg, var(--fx-surface)) 50%, transparent)}
html[data-ui="v2"] .fx-busy-veil--page .fx-busy-veil__spin{position:sticky;inset-block-start:calc(50dvh - 22px);margin-block-start:min(30dvh, 160px)}

html[data-ui="v2"] .fx-busy-veil__spin{
  display:block;inline-size:36px;block-size:36px;border-radius:50%;
  border:3px solid color-mix(in srgb, var(--fx-primary) 18%, transparent);
  border-block-start-color:var(--fx-primary);
  box-shadow:0 0 0 6px color-mix(in srgb, var(--fx-surface) 85%, transparent);
  background:var(--fx-surface);
  animation:fx-spin .8s linear infinite;
}
@keyframes fx-busy-in{from{opacity:0}to{opacity:1}}

/* Typing: spinner at the field's inline end. */
html[data-ui="v2"] .fx-input-busy{
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6' fill='none' stroke='%23224A89' stroke-opacity='.2' stroke-width='2'/%3E%3Cpath d='M8 2a6 6 0 0 1 6 6' fill='none' stroke='%23224A89' stroke-width='2' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 8 8' to='360 8 8' dur='.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E");
  background-repeat:no-repeat;background-size:16px 16px;background-position:right 12px center;
}
html[data-ui="v2"][dir="rtl"] .fx-input-busy{background-position:left 12px center}

/* Uploads keep their progress bar; the «جارٍ الرفع» text gets a spinner too. */
html[data-ui="v2"] form.fx-upload.htmx-request .fx-upload__busy::before{
  content:"";display:inline-block;inline-size:.9em;block-size:.9em;margin-inline-end:.45em;
  vertical-align:-.12em;border-radius:50%;
  border:2px solid color-mix(in srgb, currentColor 25%, transparent);border-block-start-color:currentColor;
  animation:fx-spin .8s linear infinite;
}

@media (prefers-reduced-motion:reduce){
  html[data-ui="v2"] .fx-busy-veil{animation:none}
  html[data-ui="v2"] .fx-busy-veil__spin,
  html[data-ui="v2"] form.fx-upload.htmx-request .fx-upload__busy::before{animation:none}
}

/* -- Pilot (body[data-loading-pilot]): the Fursa wordmark, step messages,
   page outlines, the Excel row-count toast and tips in AI cards. -- */
html[data-ui="v2"] .fx-busy-veil--brand{flex-direction:column;background:color-mix(in srgb, var(--fx-surface) 90%, transparent)}
html[data-ui="v2"] .fx-busy-veil--page.fx-busy-veil--brand{background:color-mix(in srgb, var(--fx-bg) 80%, transparent)}
html[data-ui="v2"] .fx-busy-head{display:flex;flex-direction:column;align-items:center;gap:6px;text-align:center;padding-inline:var(--fx-space-4)}
html[data-ui="v2"] .fx-busy-veil--page.fx-busy-veil--brand .fx-busy-head{position:sticky;inset-block-start:calc(50dvh - 48px);margin-block-start:min(30dvh,160px)}
/* The real FursaTech wordmark (navy on light, white on dark, gold diamond), the same files as the header. */
html[data-ui="v2"] .fx-busy-logo{display:flex;flex-direction:column;align-items:center;gap:8px;animation:fx-logo-pulse 1.8s ease-in-out infinite}
html[data-ui="v2"] .fx-busy-logo img{block-size:48px;inline-size:auto;max-inline-size:100%}
html[data-ui="v2"] .fx-busy-logo__img--navy{display:block}
html[data-ui="v2"] .fx-busy-logo--sm img{block-size:28px}
html[data-ui="v2"] .fx-busy-logo__img--white{display:none}
html[data-ui="v2"].dark .fx-busy-logo__img--navy{display:none}
html[data-ui="v2"].dark .fx-busy-logo__img--white{display:block}
html[data-ui="v2"] .fx-busy-logo::after{
  content:"";inline-size:72%;block-size:2px;border-radius:2px;
  background:linear-gradient(90deg,transparent 0%,var(--fx-accent) 50%,transparent 100%);
  background-size:200% 100%;animation:fx-logo-sweep 1.6s linear infinite;
}
html[data-ui="v2"] .fx-busy-logo--sm::after{block-size:1.5px}
@keyframes fx-logo-pulse{50%{opacity:.72}}
@keyframes fx-logo-sweep{from{background-position:100% 0}to{background-position:-100% 0}}
html[data-ui="v2"] .fx-busy-dots{display:flex;gap:5px}
html[data-ui="v2"] .fx-busy-dots i{inline-size:6px;block-size:6px;border-radius:50%;background:var(--fx-accent);animation:fx-dot 1s ease-in-out infinite}
html[data-ui="v2"] .fx-busy-dots i:nth-child(2){animation-delay:.15s;background:var(--fx-primary)}
html[data-ui="v2"] .fx-busy-dots i:nth-child(3){animation-delay:.3s}
@keyframes fx-dot{50%{transform:translateY(-5px);opacity:.5}}
html[data-ui="v2"] .fx-busy-msg{min-block-size:1.5em;font-size:var(--fx-text-sm);font-weight:var(--fx-weight-semibold);color:var(--fx-text-muted)}
html[data-ui="v2"] .fx-busy-msg:empty{display:none}
html[data-ui="v2"] .fx-busy-msg--in{animation:fx-msg-in .3s ease both}
@keyframes fx-msg-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}

/* Page outline: an opaque sheet shaped like the page that is opening. */
html[data-ui="v2"] .fx-busy-veil--outline{align-items:stretch;overflow:hidden;background:var(--fx-bg)}
html[data-ui="v2"] .fx-skel{display:grid;gap:12px;inline-size:100%;max-inline-size:var(--fx-skel-max, var(--fx-page-max, 1080px));margin-inline:auto;align-content:start;padding-block:var(--fx-space-4);padding-inline:var(--fx-space-4)}
html[data-ui="v2"] .fx-skel .fx-busy-head{flex-direction:row;justify-content:center;gap:10px;padding-block-end:4px}
html[data-ui="v2"] .fx-skel i{
  display:block;block-size:16px;border-radius:var(--fx-radius-md);
  background:linear-gradient(90deg,var(--fx-surface-sunken) 0%,var(--fx-surface) 50%,var(--fx-surface-sunken) 100%);
  background-size:200% 100%;animation:fx-skel-shimmer 1.3s linear infinite;
}
html[data-ui="v2"][dir="rtl"] .fx-skel i{animation-direction:reverse}
@keyframes fx-skel-shimmer{from{background-position:200% 0}to{background-position:-200% 0}}
html[data-ui="v2"] .fx-skel i.w40{inline-size:40%;block-size:28px}
html[data-ui="v2"] .fx-skel i.w60{inline-size:60%}
html[data-ui="v2"] .fx-skel i.thin{block-size:12px}
html[data-ui="v2"] .fx-skel i.c{justify-self:center}
html[data-ui="v2"] .fx-skel i.chip{inline-size:110px;block-size:30px;border-radius:var(--fx-radius-pill)}
html[data-ui="v2"] .fx-skel i.row{block-size:64px;border:1px solid var(--fx-border)}
html[data-ui="v2"] .fx-skel i.tile{block-size:104px;border:1px solid var(--fx-border)}
html[data-ui="v2"] .fx-skel i.block{block-size:220px;border:1px solid var(--fx-border)}
html[data-ui="v2"] .fx-skel i.bar{inline-size:min(720px,100%);justify-self:center;block-size:52px;border-radius:var(--fx-radius-pill)}
html[data-ui="v2"] .fx-skel i.card{block-size:150px;border:1px solid var(--fx-border)}
html[data-ui="v2"] .fx-skel i.side{block-size:320px;border:1px solid var(--fx-border)}
html[data-ui="v2"] .fx-skel__chips{display:flex;gap:8px;flex-wrap:wrap}
html[data-ui="v2"] .fx-skel__tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
html[data-ui="v2"] .fx-skel__split{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:16px}
html[data-ui="v2"] .fx-skel__split > div{display:grid;gap:12px;align-content:start}
@media (max-width:720px){html[data-ui="v2"] .fx-skel__split{grid-template-columns:minmax(0,1fr)}}

/* Excel: real row count once the file has arrived. */
html[data-ui="v2"] .fx-mini-toast{
  position:fixed;inset-inline:max(16px, env(safe-area-inset-left, 0px));inset-block-end:calc(20px + env(safe-area-inset-bottom, 0px));
  margin-inline:auto;inline-size:max-content;max-inline-size:calc(100% - 32px);z-index:var(--fx-z-toast);
  padding:10px 16px;border-radius:var(--fx-radius-pill);background:var(--fx-text);color:var(--fx-surface);
  font-size:var(--fx-text-sm);font-weight:var(--fx-weight-semibold);box-shadow:var(--fx-shadow-lg);
  animation:fx-msg-in .25s ease both;
}

/* Tips inside AI cards while they work. */
html[data-ui="v2"] .fx-wait-tip{display:grid;gap:2px;margin-block-start:var(--fx-space-3);padding:10px 14px;border-radius:var(--fx-radius-md);background:var(--fx-surface-sunken);border:1px solid var(--fx-border)}
html[data-ui="v2"] .fx-wait-tip small{font-size:var(--fx-text-2xs);font-weight:var(--fx-weight-semibold);color:var(--fx-primary)}
html[data-ui="v2"] .fx-wait-tip p{margin:0;font-size:var(--fx-text-sm);color:var(--fx-text)}

@media (prefers-reduced-motion:reduce){
  html[data-ui="v2"] .fx-busy-logo,html[data-ui="v2"] .fx-busy-logo::after,html[data-ui="v2"] .fx-busy-dots i,html[data-ui="v2"] .fx-skel i,
  html[data-ui="v2"] .fx-busy-msg--in,html[data-ui="v2"] .fx-mini-toast{animation:none}
}

/* -- Phase B pilot: a ring that fills over the page's usual answer time, and
   «هل تعلم؟» facts with real numbers (static/v2/loading.js, /loading/hints). -- */
html[data-ui="v2"] .fx-busy-ring{display:block;inline-size:30px;block-size:30px}
html[data-ui="v2"] .fx-busy-ring svg{inline-size:100%;block-size:100%;transform:rotate(-90deg)}
html[data-ui="v2"] .fx-busy-ring circle{fill:none;stroke-width:3.5}
html[data-ui="v2"] .fx-busy-ring .t{stroke:color-mix(in srgb, var(--fx-primary) 18%, transparent)}
html[data-ui="v2"] .fx-busy-ring .b{stroke:var(--fx-accent);stroke-linecap:round;stroke-dasharray:100;stroke-dashoffset:100}
html[dir="rtl"][data-ui="v2"] .fx-busy-ring svg{transform:rotate(-90deg) scaleY(-1)}
html[data-ui="v2"] .fx-busy-usual{font-size:var(--fx-text-xs, 12px);color:var(--fx-text-muted)}

/* -- Phase C pilot: the live steps of an AI job inside its card
   (templates/v2/_job_steps.html, app/job_progress.py). -- */
html[data-ui="v2"] .fx-jobsteps{display:grid;gap:10px;padding:var(--fx-space-3, 12px) 0}
html[data-ui="v2"] .fx-jobsteps__elapsed{margin:0;font-size:var(--fx-text-xs, 12px);color:var(--fx-text-muted)}
html[data-ui="v2"] .fx-jobsteps__list{list-style:none;margin:0;padding:0;display:grid;gap:6px}
html[data-ui="v2"] .fx-jobsteps__item{display:flex;align-items:center;gap:10px;font-size:var(--fx-text-sm);color:var(--fx-text-muted)}
html[data-ui="v2"] .fx-jobsteps__item--now{color:var(--fx-text);font-weight:var(--fx-weight-semibold)}
html[data-ui="v2"] .fx-jobsteps__mark{flex:none;display:grid;place-items:center;inline-size:20px;block-size:20px;border-radius:50%}
html[data-ui="v2"] .fx-jobsteps__item--done .fx-jobsteps__mark{background:var(--fx-success, #2E9E5B)}
html[data-ui="v2"] .fx-jobsteps__item--done .fx-jobsteps__mark::after{content:"";inline-size:9px;block-size:5px;border:2px solid #fff;border-block-start:0;border-inline-end:0;transform:translateY(-1px) rotate(-45deg)}
html[dir="rtl"][data-ui="v2"] .fx-jobsteps__item--done .fx-jobsteps__mark::after{transform:translateY(-1px) rotate(-45deg) scaleX(-1)}
html[data-ui="v2"] .fx-jobsteps__item--now .fx-jobsteps__mark .fx-spinner{margin:0}
html[data-ui="v2"] .fx-jobsteps__label{flex:1 1 auto;min-inline-size:0}
html[data-ui="v2"] .fx-jobsteps__time{flex:none;font-size:var(--fx-text-xs, 12px);color:var(--fx-text-muted);font-weight:normal}
html[data-ui="v2"] .fx-jobsteps__found{padding:10px 12px;border-radius:var(--fx-radius-md);background:var(--fx-surface-sunken, var(--fx-bg));border:1px solid var(--fx-border)}
html[data-ui="v2"] .fx-jobsteps__found p{margin:0 0 6px;font-size:var(--fx-text-xs, 12px);font-weight:var(--fx-weight-semibold);color:var(--fx-text-muted)}
html[data-ui="v2"] .fx-jobsteps__found ul{margin:0;padding-inline-start:18px;display:grid;gap:4px;font-size:var(--fx-text-sm)}
html[data-ui="v2"] .fx-file .fx-jobsteps{grid-column:1 / -1;margin-block-start:var(--fx-space-2, 8px)}
