/* ── SwichPay skeleton loading (skeleton-all-20261121) ─────────────────────
   One shimmer pattern for every loading state on the site. Theme-aware:
   light defaults, dark via html[data-theme="dark"] (the merchant/agent
   masters and the public pages both set data-theme before paint; the admin
   has none and gets the light values). Palette is SwichPay navy/blue —
   nothing is forced black-and-white. The shimmer is a transform-based
   sweep (compositor-cheap), 1.9s with a pause — slow + subtle. */

:root {
  --sk-base: #e8ebf1;
  --sk-shine: rgba(255, 255, 255, .75);
  --sk-line: rgba(10, 15, 30, .06);
}
html[data-theme="dark"] {
  --sk-base: rgba(255, 255, 255, .08);
  --sk-shine: rgba(255, 255, 255, .10);
  --sk-line: rgba(255, 255, 255, .07);
}

/* Base shimmer block. Every skeleton shape is a .sk (or built from .sk). */
.sk { position: relative; overflow: hidden; background: var(--sk-base); border-radius: 6px; display: block; flex: none; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(100deg, transparent 20%, var(--sk-shine) 50%, transparent 80%); animation: sk-shimmer 1.9s ease-in-out infinite; }
@keyframes sk-shimmer { 55%, 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .sk::after { animation: none; } }

.sk-line { height: 12px; border-radius: 6px; }
.sk-line-xs { height: 10px; }
.sk-lines .sk { margin-bottom: 10px; }
.sk-lines .sk:last-child { margin-bottom: 0; }

/* ── Amount swap (dashboard Insights) ──────────────────────────────────────
   The skeleton fills the exact box of the value it replaces: the real
   content goes visibility:hidden (so it keeps its layout) and the skeleton
   overlays it — zero layout shift when the new value lands. Shown by JS
   only after a 200ms delay, so fast responses never flash a skeleton. */
.sk-swap { position: relative; }
.sk-swap > .sk { position: absolute; top: 0; left: 0; bottom: 0; width: 72%; display: none; }
.sk-swap.sk-loading > :not(.sk) { visibility: hidden; }
.sk-swap.sk-loading > .sk { display: block; }

/* ── Chart skeleton ────────────────────────────────────────────────────────
   Same height as the chart it replaces (set inline per chart), with faint
   grid lines + a bottom axis so it reads as a chart, not a grey box. */
.sk-chart { width: 100%; border-radius: 8px; }
.sk-chart::before { content: ""; position: absolute; inset: 0; background:
  repeating-linear-gradient(to bottom, transparent 0, transparent 55px, var(--sk-line) 55px, var(--sk-line) 56px),
  linear-gradient(to bottom, transparent calc(100% - 2px), var(--sk-line) calc(100% - 2px)); }

/* Chart overlay (admin report charts): covers the chart area while its data
   is loading — visible on first paint (charts start with empty series) and
   on date-range refetch after a 200ms delay. The wrap needs a min-height
   matching the chart (380px) so the overlay has size before first render. */
.sk-chart-wrap { position: relative; }
.sk-chart-ov { position: absolute; inset: 0; z-index: 2; display: none; }
.sk-chart-wrap.sk-loading .sk-chart-ov { display: block; }

/* ── Table skeleton ────────────────────────────────────────────────────────
   Rows match the real table's row height (rowH param) so the pagination
   below doesn't jump when content lands. */
.sk-table { width: 100%; }
.sk-thead, .sk-trow { display: flex; gap: 16px; align-items: center; }
.sk-thead { padding: 10px 0; border-bottom: 1px solid var(--sk-line); }
.sk-trow { border-bottom: 1px solid var(--sk-line); }
.sk-tcell { flex: 1; display: flex; align-items: center; }
.sk-tcell-r { justify-content: flex-end; }

/* ── Preloader skeleton shell (layouts.frontend pages) ─────────────────────
   Replaces the pulsing blue circle inside the existing .preloader overlay
   (main.css positions it fixed + centered; app.js hides it — both
   untouched). Shaped like the page behind it: nav bar + title + lines. */
.sk-preloader { width: min(720px, 88vw); }
.sk-pre-nav { display: flex; align-items: center; gap: 18px; margin-bottom: 44px; }
.sk-pre-logo { width: 120px; height: 28px; border-radius: 8px; }
.sk-pre-link { width: 64px; height: 12px; border-radius: 6px; }
.sk-pre-title { width: 58%; height: 30px; border-radius: 8px; margin-bottom: 18px; }
.sk-pre-line { width: 100%; height: 14px; margin-bottom: 12px; }
.sk-pre-line.short { width: 64%; }
@media (max-width: 600px) { .sk-pre-link:nth-child(n+3) { display: none; } }

/* ── Nav progress bar ──────────────────────────────────────────────────────
   2px top bar for full-page navigations (this is an MPA — skeletons can't
   know the next page's shape). Brand blue in both themes. Driven by
   zp-skeleton.js. */
#zp-progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--zp-blue, var(--brand, #4f8bff)); z-index: 999999; opacity: 0; transition: width .45s ease, opacity .3s ease; pointer-events: none; }
#zp-progress.on { opacity: 1; }
