/* EWER 2.0 CMS — Government-ready global loading experience.
   Scoped to #loadingOverlay to avoid changing existing page layouts. */

#loadingOverlay.ewer-loading-overlay,
#loadingOverlay.loading-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 24px !important;
    margin: 0 !important;
    overflow: hidden !important;
    background:
        radial-gradient(circle at 18% 18%, rgba(59, 130, 246, 0.20), transparent 36%),
        radial-gradient(circle at 82% 78%, rgba(124, 58, 237, 0.18), transparent 38%),
        rgba(15, 23, 42, 0.56) !important;
    -webkit-backdrop-filter: blur(14px) saturate(1.18) !important;
    backdrop-filter: blur(14px) saturate(1.18) !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, visibility 180ms ease;
}

#loadingOverlay.ewer-loading-overlay.hidden,
#loadingOverlay.loading-overlay.hidden {
    display: flex !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

#loadingOverlay.ewer-loading-overlay.is-visible,
#loadingOverlay.loading-overlay.is-visible {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
}

body.ewer-loading-active {
    overflow: hidden !important;
}

.ewer-loader-ambient {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.ewer-loader-ambient::before,
.ewer-loader-ambient::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    opacity: 0.7;
    animation: ewerLoaderFloat 6s ease-in-out infinite;
}

.ewer-loader-ambient::before {
    width: 240px;
    height: 240px;
    left: max(-80px, 7vw);
    top: 14%;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.34), transparent 68%);
}

.ewer-loader-ambient::after {
    width: 300px;
    height: 300px;
    right: max(-120px, 4vw);
    bottom: 6%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.30), transparent 68%);
    animation-delay: -3s;
}

.ewer-loader-shell {
    position: relative;
    width: min(440px, calc(100vw - 38px));
    padding: 30px 28px 26px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow:
        0 30px 90px rgba(15, 23, 42, 0.32),
        0 8px 30px rgba(37, 99, 235, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
    backdrop-filter: blur(22px) saturate(1.35);
    text-align: center;
    transform: translateY(8px) scale(0.985);
    transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
}

#loadingOverlay.is-visible .ewer-loader-shell {
    transform: translateY(0) scale(1);
}

.ewer-loader-visual {
    position: relative;
    display: grid;
    place-items: center;
    width: 126px;
    height: 126px;
    margin: 0 auto 20px;
}

.ewer-loader-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-radius: 50%;
}

.ewer-loader-ring--outer {
    border-top-color: #2563eb;
    border-right-color: rgba(37, 99, 235, 0.23);
    border-bottom-color: #7c3aed;
    animation: ewerSpin 1.65s linear infinite;
}

.ewer-loader-ring--middle {
    inset: 12px;
    border-left-color: #0ea5e9;
    border-bottom-color: rgba(14, 165, 233, 0.24);
    border-top-color: #8b5cf6;
    animation: ewerSpinReverse 1.15s linear infinite;
}

.ewer-loader-ring--inner {
    inset: 23px;
    border-width: 2px;
    border-top-color: #f59e0b;
    border-right-color: rgba(245, 158, 11, 0.22);
    animation: ewerSpin 2.15s linear infinite;
}

.ewer-loader-logo-wrap {
    position: relative;
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    overflow: hidden;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 19px;
    background: linear-gradient(145deg, #ffffff, #eff6ff);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
    animation: ewerLoaderPulse 1.8s ease-in-out infinite;
}

.ewer-loader-logo {
    display: block;
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 12px;
}

.ewer-loader-orbit-dot {
    position: absolute;
    top: 4px;
    left: 50%;
    width: 9px;
    height: 9px;
    margin-left: -4.5px;
    border-radius: 50%;
    background: #2563eb;
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.12), 0 0 18px rgba(37, 99, 235, 0.55);
    transform-origin: 4.5px 59px;
    animation: ewerOrbit 1.65s linear infinite;
}

.ewer-loader-kicker {
    margin: 0 0 5px;
    color: #2563eb;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.ewer-loader-title {
    margin: 0;
    color: #172033;
    font-size: clamp(1.1rem, 4vw, 1.35rem);
    font-weight: 800;
    line-height: 1.35;
}

.ewer-loader-message {
    min-height: 22px;
    margin: 7px 0 18px;
    color: #64748b;
    font-size: 0.91rem;
    line-height: 1.5;
    transition: opacity 130ms ease, transform 130ms ease;
}

.ewer-loader-message.is-changing {
    opacity: 0;
    transform: translateY(4px);
}

.ewer-loader-progress {
    position: relative;
    width: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.ewer-loader-progress-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 42%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #0ea5e9, #7c3aed);
    box-shadow: 0 0 14px rgba(37, 99, 235, 0.34);
    animation: ewerProgress 1.35s cubic-bezier(.45, 0, .55, 1) infinite;
}

.ewer-loader-security {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 14px;
    color: #64748b;
    font-size: 0.75rem;
    line-height: 1.4;
}

.ewer-loader-security-mark {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
    animation: ewerSecurityPulse 1.7s ease-in-out infinite;
}

html.dark .ewer-loader-shell,
body.dark-mode .ewer-loader-shell {
    border-color: rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.52), 0 8px 28px rgba(59, 130, 246, 0.16);
}

html.dark .ewer-loader-title,
body.dark-mode .ewer-loader-title {
    color: #f8fafc;
}

html.dark .ewer-loader-message,
html.dark .ewer-loader-security,
body.dark-mode .ewer-loader-message,
body.dark-mode .ewer-loader-security {
    color: #aebbd0;
}

html.dark .ewer-loader-logo-wrap,
body.dark-mode .ewer-loader-logo-wrap {
    border-color: rgba(96, 165, 250, 0.24);
    background: linear-gradient(145deg, #1e293b, #111827);
}

html.dark .ewer-loader-progress,
body.dark-mode .ewer-loader-progress {
    background: #334155;
}

@keyframes ewerSpin { to { transform: rotate(360deg); } }
@keyframes ewerSpinReverse { to { transform: rotate(-360deg); } }
@keyframes ewerOrbit { to { transform: rotate(360deg); } }
@keyframes ewerProgress {
    0% { width: 34%; transform: translateX(-115%); }
    50% { width: 54%; }
    100% { width: 34%; transform: translateX(300%); }
}
@keyframes ewerLoaderPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.045); }
}
@keyframes ewerLoaderFloat {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(18px, -14px, 0) scale(1.06); }
}
@keyframes ewerSecurityPulse {
    0%, 100% { opacity: 0.7; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.12); }
}

@media (max-width: 520px) {
    #loadingOverlay.ewer-loading-overlay,
    #loadingOverlay.loading-overlay {
        padding: 16px !important;
    }

    .ewer-loader-shell {
        padding: 26px 20px 22px;
        border-radius: 20px;
    }

    .ewer-loader-visual {
        width: 112px;
        height: 112px;
    }

    .ewer-loader-orbit-dot {
        transform-origin: 4.5px 52px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ewer-loader-ring,
    .ewer-loader-orbit-dot,
    .ewer-loader-logo-wrap,
    .ewer-loader-progress-bar,
    .ewer-loader-ambient::before,
    .ewer-loader-ambient::after,
    .ewer-loader-security-mark {
        animation: none !important;
    }

    .ewer-loader-ring--outer {
        border-color: rgba(37, 99, 235, 0.22);
        border-top-color: #2563eb;
    }

    .ewer-loader-progress-bar {
        width: 65%;
    }

    #loadingOverlay.ewer-loading-overlay,
    #loadingOverlay.loading-overlay,
    .ewer-loader-shell,
    .ewer-loader-message {
        transition: none !important;
    }
}
