/*
    The global busy overlay.

    Sits above everything the app can put on screen: the template's own modals are z-index
    1000 and SweetAlert2 is 1060, so this takes a band well clear of both. A loader that
    appears behind the dialog that triggered it is worse than none.
*/

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 20000;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(248, 250, 252, 0.78);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);

    /* Hidden by default and driven by .is-visible, so the markup can render on every page
       without ever flashing on load. visibility carries the transition so the overlay does
       not swallow clicks while it is fading out. */
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
}

.app-loader.is-visible {
    opacity: 1;
    visibility: visible;
}

.app-loader__panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 26px 34px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 18px 44px -20px rgba(15, 23, 42, .45);
    max-width: min(88vw, 320px);
    text-align: center;

    transform: translateY(6px) scale(.98);
    transition: transform .18s ease;
}

.app-loader.is-visible .app-loader__panel {
    transform: translateY(0) scale(1);
}

/* ---------- the mark ---------- */

.app-loader__mark {
    position: relative;
    width: 74px;
    height: 74px;
    display: grid;
    place-items: center;
}

.app-loader__logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 50%;
}

/*
    A conic gradient masked into a ring, so the sweep reads as one continuous arc rather than
    the four-dot look a border-based spinner gives. The mask is what keeps the middle clear
    for the logo.
*/
.app-loader__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(37, 99, 235, 0) 0deg, rgba(37, 99, 235, .15) 140deg, #2563eb 340deg, rgba(37, 99, 235, 0) 360deg);

    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));

    animation: app-loader-spin 1.1s linear infinite;
}

@keyframes app-loader-spin {
    to { transform: rotate(360deg); }
}

/* ---------- words ---------- */

.app-loader__caption {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: .01em;
}

.app-loader__hint {
    margin: 0;
    font-size: .78rem;
    color: #64748b;
    line-height: 1.45;
}

.app-loader__hint[hidden] { display: none; }

.app-loader__hint kbd {
    font-family: inherit;
    font-size: .72rem;
    padding: 1px 5px;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: #f8fafc;
    color: #334155;
}

/* ---------- reduced motion ---------- */

/*
    The sweep is the part that moves; without it the ring still needs to say "working", so it
    breathes instead of spinning. Something must keep changing, or the overlay reads as frozen.
*/
@media (prefers-reduced-motion: reduce) {
    .app-loader,
    .app-loader__panel {
        transition: none;
    }

    .app-loader__ring {
        animation: app-loader-breathe 1.6s ease-in-out infinite;
        background: conic-gradient(from 0deg, #2563eb 0deg, #2563eb 360deg);
    }

    @keyframes app-loader-breathe {
        0%, 100% { opacity: .25; }
        50% { opacity: .9; }
    }
}

@media (max-width: 480px) {
    .app-loader__panel { padding: 22px 26px; }
}
