/* ══════════════════════════════════════════════════════════════
   LOADING INDICATORS — Vital design system §12
   (heartbeat form overlay · page-transition bar · skeleton reveal)

   Tokens come from static/css/tailwind.css (:root / [data-theme="dark"]);
   every var() carries a light-theme fallback for standalone safety.
   Class names and ids are a frozen contract — the page-transition scripts
   in every base template target #ptBar / #ptSkeleton / .active, and 19+
   templates include the .hb-* overlay. Do not rename.
   ══════════════════════════════════════════════════════════════ */

/* ── Heartbeat overlay container (§12 — blocking form submits) ── */
.heartbeat-overlay {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--bg, #F6F8FA) 86%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 50;
    border-radius: inherit;
    animation: hbOverlayFadeIn 0.3s ease forwards;
}

#loginOverlay {
    display: none;
}

@keyframes hbOverlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Heartbeat icon + expanding pulse rings ── */
.hb-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.hb-icon-wrap {
    width: 76px;
    height: 76px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Two staggered rings — 1.8s ease-out, second offset by .9s (§12). */
.hb-pulse-ring {
    position: absolute;
    inset: 14px;
    border: 2px solid var(--color-primary, #0F54E0);
    border-radius: 50%;
    animation: hbRingPulse 1.8s ease-out infinite;
}

.hb-pulse-ring:nth-child(2) {
    animation-delay: 0.9s;
}

.hb-center {
    width: 48px;
    height: 48px;
    background: var(--color-primary-soft, #EAF1FF);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.hb-center i,
.hb-center svg {
    font-size: 20px;
    color: var(--color-primary, #0F54E0);
    animation: hbBeat 1.2s ease-in-out infinite;
}

@keyframes hbRingPulse {
    0%   { transform: scale(0.7); opacity: 0.55; }
    100% { transform: scale(1.9); opacity: 0; }
}

/* Beat curve matches the reference cvbeat (scale 1.18 at 18%). */
@keyframes hbBeat {
    0%, 100% { transform: scale(1); }
    18%      { transform: scale(1.18); }
    36%      { transform: scale(1); }
}

/* ── ECG waveform with traveling pulse (1.6s linear, §12) ── */
.hb-ecg {
    width: 120px;
    height: 30px;
    overflow: hidden;
    position: relative;
}

.hb-ecg svg {
    width: 240px;
    height: 30px;
    animation: hbEcgScroll 1.6s linear infinite;
}

@keyframes hbEcgScroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ── Loading text ("جارٍ الحفظ" + animated dots) ── */
.hb-text {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted, #6B7888);
    letter-spacing: 0.3px;
}

.hb-text::after {
    content: '';
    animation: hbDots 1.5s steps(4, end) infinite;
}

@keyframes hbDots {
    0%  { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}


/* ══════════════════════════════════════════════════════════════
   SKELETON REVEAL — page transitions (§12)
   ══════════════════════════════════════════════════════════════ */

/* ── Top progress bar — 3px, blue→teal, 2s ease (§12) ── */
.page-transition-bar {
    position: fixed;
    top: 0;
    inset-inline: 0;
    height: 3px;
    background: transparent;
    z-index: 9999;
    pointer-events: none;
    display: none;
}

.page-transition-bar.active {
    display: block;
}

.page-transition-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-primary, #0F54E0), var(--color-accent, #0FB5AE));
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 10px color-mix(in srgb, var(--color-primary, #0F54E0) 50%, transparent),
                0 0 20px color-mix(in srgb, var(--color-accent, #0FB5AE) 30%, transparent);
    animation: ptBarProgress 2s ease-in-out forwards;
}

@keyframes ptBarProgress {
    0%   { width: 0%; }
    15%  { width: 25%; }
    40%  { width: 55%; }
    65%  { width: 75%; }
    85%  { width: 90%; }
    100% { width: 95%; }
}

/* ── Skeleton overlay ── */
.page-transition-skeleton {
    position: fixed;
    inset: 0;
    background: var(--bg, #F6F8FA);
    z-index: 9998;
    display: none;
    flex-direction: column;
    padding: 80px 24px 24px;
    gap: 16px;
    animation: skelFadeIn 0.2s ease forwards;
}

.page-transition-skeleton.active {
    display: flex;
}

@keyframes skelFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Skeleton shapes — panel2 → line shimmer, radius 7px (§5, §12) ── */
.skel-shape {
    background: var(--panel2, #F1F4F8);
    border-radius: 7px;
    position: relative;
    overflow: hidden;
}

.skel-shape::after {
    content: '';
    position: absolute;
    top: 0;
    inset-inline-start: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--line, #EDF1F5), transparent);
    animation: skelShimmer 1.25s linear infinite;
}

@keyframes skelShimmer {
    0%   { inset-inline-start: -100%; }
    100% { inset-inline-start: 100%; }
}

.skel-h {
    height: 24px;
    width: 45%;
    max-width: 300px;
    margin: 0 auto 8px;
}

.skel-p1 {
    height: 14px;
    width: 80%;
    max-width: 500px;
    margin: 0 auto;
}

.skel-p2 {
    height: 14px;
    width: 65%;
    max-width: 400px;
    margin: 0 auto;
}

.skel-card-lg {
    height: 120px;
    width: 100%;
    max-width: 600px;
    margin: 12px auto 0;
    border-radius: 14px;
}

.skel-row {
    display: flex;
    gap: 12px;
    max-width: 600px;
    margin: 12px auto 0;
    width: 100%;
}

.skel-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px; /* squircle, matching .v-avatar */
    flex-shrink: 0;
}

.skel-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skel-line-s {
    height: 12px;
    width: 40%;
}

.skel-line-l {
    height: 12px;
    width: 75%;
}

.skel-btn-row {
    display: flex;
    gap: 12px;
    max-width: 600px;
    margin: auto auto 0;
    width: 100%;
}

.skel-btn {
    height: 40px;
    width: 120px;
    border-radius: 9px;
}

/* ── Skeleton layout: auth pages ── */
.skel-layout-auth {
    flex-direction: column;
    align-items: center;
    background-color: var(--bg, #F6F8FA);
}

.skel-layout-auth::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, var(--color-primary-soft, #EAF1FF), transparent),
                radial-gradient(circle at bottom left, var(--color-accent-soft, #D6F5F2), transparent);
    opacity: .55;
    z-index: 0;
}

.skel-auth-card {
    width: 100%;
    max-width: 500px;
    background: var(--panel, #FFFFFF);
    border: 1px solid var(--border, #E1E7EE);
    border-radius: 16px;
    padding: 48px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(16, 24, 40, 0.06));
    position: relative;
    z-index: 10;
    margin: auto; /* Vertically center in remaining space */
}

/* ── Skeleton layout: dashboards ── */
.skel-layout-dashboard {
    padding: 0;
    gap: 0;
    align-items: flex-start;
}

.skel-nav {
    height: 70px;
    width: 100%;
    background: var(--panel, #FFFFFF);
    border-bottom: 1px solid var(--line, #EDF1F5);
    margin-bottom: 32px;
}

.skel-container {
    padding: 0 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

/* ── Component shapes ── */
.skel-icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto;
}

.skel-h-center {
    height: 32px;
    width: 60%;
    margin: 0 auto 8px;
}

.skel-p-center {
    height: 16px;
    width: 80%;
    margin: 0 auto;
}

.skel-input {
    height: 44px;
    width: 100%;
    border-radius: 9px;
}

.skel-btn-block {
    height: 44px;
    width: 100%;
    border-radius: 9px;
    margin-top: 12px;
}

.skel-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    width: 100%;
}

.skel-card {
    height: 140px;
    border-radius: 14px;
    background: var(--panel, #FFFFFF);
    border: 1px solid var(--border, #E1E7EE);
    padding: 24px;
}

.skel-table {
    height: 400px;
    width: 100%;
    border-radius: 14px;
    background: var(--panel, #FFFFFF);
    border: 1px solid var(--border, #E1E7EE);
}

/* ── Skeleton layout: landing page ── */
.skel-layout-landing {
    padding: 0;
    gap: 0;
    align-items: flex-start;
    overflow: hidden;
}

.skel-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 60px 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    gap: 48px;
    min-height: 600px;
}

.skel-hero-text {
    flex: 1;
    max-width: 600px;
}

.skel-hero-img {
    flex: 1;
    height: 400px;
    background: var(--panel2, #F1F4F8);
    border-radius: 14px;
    position: relative;
    overflow: hidden;
}

.skel-hero-title {
    height: 60px;
    width: 80%;
    margin-bottom: 24px;
}

.skel-hero-p {
    height: 20px;
    width: 90%;
    margin-bottom: 12px;
}

.skel-btn-row-hero {
    display: flex;
    gap: 16px;
    margin-top: 32px;
}

.skel-btn-hero {
    height: 48px;
    width: 160px;
    border-radius: 9px;
}

/* Mobile responsiveness for skeleton */
@media (max-width: 768px) {
    .skel-hero {
        flex-direction: column-reverse;
        padding: 32px 1rem;
        text-align: center;
    }

    .skel-hero-text {
        width: 100%;
        align-items: center;
        display: flex;
        flex-direction: column;
    }

    .skel-btn-row-hero {
        justify-content: center;
    }

    .skel-hero-img {
        width: 100%;
        height: 300px;
    }
}
