/* ==========================================================================
   App loader: top progress bar + full-screen processing overlay.
   Driven by wwwroot/js/loader.js (window.AppLoader).
   ========================================================================== */

/* ---- Top progress bar (every request / navigation) ---- */
.app-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2001;
    pointer-events: none;
    opacity: 0;
    transition: opacity .35s ease;
}

.app-progress.is-active {
    opacity: 1;
}

.app-progress-bar {
    position: relative;
    height: 100%;
    background: linear-gradient(90deg, var(--app-primary, #2340a8), var(--app-purple, #6d4bd8), var(--app-accent, #16a34a));
    background-size: 200% 100%;
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform .3s ease;
    box-shadow: 0 0 10px rgba(var(--app-primary-rgb, 35, 64, 168), .55);
    animation: app-progress-flow 1.4s linear infinite;
}

.app-progress-bar.no-transition {
    transition: none;
}

/* ---- Full-screen overlay (saves, form posts, slow page loads) ---- */
.app-loader {
    position: fixed;
    inset: 0;
    z-index: 2000; /* above Bootstrap modals (1055), below toastr */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 29, 74, .32);
    -webkit-backdrop-filter: blur(5px) saturate(120%);
    backdrop-filter: blur(5px) saturate(120%);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility 0s linear .22s;
}

.app-loader.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity .22s ease;
}

.app-loader-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .9rem;
    min-width: 230px;
    max-width: min(340px, 100%);
    padding: 1.9rem 2.1rem 1.6rem;
    background: var(--app-surface, #fff);
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 1.1rem;
    box-shadow: 0 24px 60px rgba(15, 29, 74, .28), 0 2px 6px rgba(15, 29, 74, .08);
    transform: translateY(10px) scale(.96);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}

.app-loader.is-visible .app-loader-card {
    transform: none;
}

.app-loader-spinner {
    position: relative;
    width: 78px;
    height: 78px;
}

.app-loader-track,
.app-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.app-loader-track {
    border: 5px solid var(--app-primary-soft, #eaeefb);
}

.app-loader-ring {
    background: conic-gradient(from 0deg,
        rgba(var(--app-primary-rgb, 35, 64, 168), 0) 0deg,
        var(--app-primary, #2340a8) 250deg,
        var(--app-accent, #16a34a) 360deg);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 5px));
    animation: app-loader-spin .9s linear infinite;
}

/* Rounded head at the end of the arc */
.app-loader-ring::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 5px;
    height: 5px;
    margin-left: -2.5px;
    border-radius: 50%;
    background: var(--app-accent, #16a34a);
}

.app-loader-logo {
    position: absolute;
    inset: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 1px var(--app-border, #e4e8f1), 0 4px 10px rgba(15, 29, 74, .08);
    animation: app-loader-pulse 1.8s ease-in-out infinite;
    overflow: hidden;
}

.app-loader-logo img {
    width: 72%;
    height: 72%;
    object-fit: contain;
}

.app-loader-logo i {
    font-size: 1.5rem;
    color: var(--app-primary, #2340a8);
}

.app-loader-text {
    font-family: var(--app-font-heading, var(--app-font, system-ui, sans-serif));
    font-weight: 700;
    font-size: .98rem;
    color: var(--app-text, #1c2434);
    text-align: center;
    line-height: 1.35;
}

.app-loader-sub {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-top: -.45rem;
    font-size: .78rem;
    color: var(--app-muted, #667085);
}

.app-loader-dots {
    display: inline-flex;
    gap: 3px;
}

.app-loader-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--app-primary, #2340a8);
    animation: app-loader-bounce 1.2s ease-in-out infinite;
}

.app-loader-dots span:nth-child(2) { animation-delay: .15s; }
.app-loader-dots span:nth-child(3) { animation-delay: .3s; }

body.app-loading {
    cursor: progress;
}

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

@keyframes app-loader-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(.93); }
}

@keyframes app-loader-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .35; }
    40% { transform: translateY(-4px); opacity: 1; }
}

@keyframes app-progress-flow {
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .app-loader-ring { animation-duration: 2s; }
    .app-loader-logo,
    .app-loader-dots span,
    .app-progress-bar { animation: none; }
}

@media print {
    .app-loader,
    .app-progress { display: none !important; }
}
