/* ═══════════════════════════════════════════════════════════
   Global Loading Overlay (AppLoader)
   Beautiful glassmorphism loader with animated ring + operation
   messages that tell the user exactly what's happening.
   ═══════════════════════════════════════════════════════════ */
#appLoaderOverlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 20, 35, .62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    font-family: 'Vazirmatn', system-ui, sans-serif;
    direction: rtl;
}
#appLoaderOverlay.on {
    opacity: 1;
    visibility: visible;
}

.app-loader-card {
    width: min(92vw, 380px);
    background: rgba(255, 255, 255, .96);
    border-radius: 22px;
    padding: 2rem 1.75rem 1.7rem;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .35), 0 2px 10px rgba(0, 0, 0, .12);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transform: translateY(14px) scale(.97);
    transition: transform .28s cubic-bezier(.3, 1.2, .4, 1);
    border: 1px solid rgba(255, 255, 255, .6);
}
#appLoaderOverlay.on .app-loader-card {
    transform: none;
}

/* ── Animated ring ── */
.app-loader-ring {
    position: relative;
    width: 84px;
    height: 84px;
    margin-bottom: 1.15rem;
}
.app-loader-ring .ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 5px solid #e8ecf3;
    border-top-color: #6d28d9;
    animation: appLoaderSpin 1s linear infinite;
}
.app-loader-ring .ring.ring-2 {
    inset: 10px;
    border-width: 4px;
    border-top-color: #f59e0b;
    animation-duration: 1.6s;
    animation-direction: reverse;
}
.app-loader-ring .ring.ring-3 {
    inset: 21px;
    border-width: 3px;
    border-top-color: #10b981;
    animation-duration: 2.2s;
}
.app-loader-ring .icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    color: #6d28d9;
    animation: appLoaderPulse 1.4s ease-in-out infinite;
}
@keyframes appLoaderSpin { to { transform: rotate(360deg); } }
@keyframes appLoaderPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(.82); opacity: .7; }
}

/* ── Messages ── */
.app-loader-title {
    font-size: 1.02rem;
    font-weight: 800;
    color: #1a1d2e;
    margin: 0 0 .3rem;
    line-height: 1.55;
}
.app-loader-detail {
    font-size: .78rem;
    font-weight: 600;
    color: #6b7280;
    line-height: 1.6;
    min-height: 1.4em;
    margin: 0 0 1.1rem;
}
.app-loader-detail .dot {
    animation: appLoaderBlink 1.1s steps(2, start) infinite;
    font-weight: 800;
}
.app-loader-detail .dot:nth-child(2) { animation-delay: .18s; }
.app-loader-detail .dot:nth-child(3) { animation-delay: .36s; }
@keyframes appLoaderBlink { to { visibility: hidden; } }

/* ── Progress bar ── */
.app-loader-progress {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #eef0f5;
    overflow: hidden;
    position: relative;
}
.app-loader-progress .bar {
    height: 100%;
    width: 30%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6d28d9, #a78bfa, #f59e0b);
    background-size: 200% 100%;
    animation: appLoaderSlide 1.5s ease-in-out infinite;
    transition: width .35s ease;
}
@keyframes appLoaderSlide {
    0% { margin-left: -30%; }
    100% { margin-left: 100%; }
}

/* ── Small inline variant (page-local, e.g. tables) ── */
.app-inline-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: 2.2rem 1rem;
    color: #6b7280;
    font-size: .8rem;
    font-weight: 600;
}
.app-inline-loading .spin {
    width: 22px;
    height: 22px;
    border: 3px solid #e8ecf3;
    border-top-color: #6d28d9;
    border-radius: 50%;
    animation: appLoaderSpin .8s linear infinite;
}

/* RTL-safe slide: keep the bar moving visually identical */
@supports (margin-inline-start: initial) {
    .app-loader-progress .bar { margin-left: 0; margin-inline-start: -30%; animation-name: appLoaderSlideRtl; }
    @keyframes appLoaderSlideRtl {
        0% { margin-inline-start: -30%; }
        100% { margin-inline-start: 100%; }
    }
}
