/* =========================================================
   Global Button / Page Loader
   - Top progress bar shown automatically during any AJAX call
   - Spinner + disabled state on buttons while a form submits
   ========================================================= */

/* ---- Top page-level ajax progress bar ---- */
#global-ajax-loader{
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color, #004aad), #ff8a00);
    z-index: 99999;
    opacity: 0;
    transition: width .25s ease, opacity .2s ease;
    pointer-events: none;
}
#global-ajax-loader.is-active{
    opacity: 1;
    width: 78%;
}
#global-ajax-loader.is-done{
    opacity: 1;
    width: 100%;
    transition: width .2s ease, opacity .35s ease .1s;
}

/* ---- Full page overlay spinner (used for full-page navigations / heavy actions) ---- */
#global-page-overlay{
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.55);
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
}
#global-page-overlay.is-active{
    display: flex;
}
#global-page-overlay .overlay-spinner{
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(0,0,0,0.12);
    border-top-color: var(--primary-color, #004aad);
    animation: btnLoaderRotate .7s linear infinite;
}

/* ---- Button loading state ---- */
.btn-loading,
button.btn-loading,
input.btn-loading{
    cursor: progress !important;
    opacity: .85;
    pointer-events: none;
    position: relative;
}

/* Spinner glyph injected inside <button> elements (buttons can hold child markup) */
.btn-spinner-ic{
    display: inline-block;
    width: 0.95em;
    height: 0.95em;
    margin-right: 7px;
    vertical-align: -0.15em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-top-color: transparent;
    border-radius: 50%;
    opacity: .9;
    animation: btnLoaderRotate .6s linear infinite;
}

/* Fallback spinner for <input type="submit|button"> (can't hold child nodes),
   drawn with ::after instead so the visible value/text stays put */
input.btn-loading{
    color: transparent !important;
    background-image: none;
}
input.btn-loading::after{
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.55);
    border-top-color: #fff;
    animation: btnLoaderRotate .6s linear infinite;
}

@keyframes btnLoaderRotate{
    to{ transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce){
    .btn-spinner-ic,
    input.btn-loading::after,
    #global-page-overlay .overlay-spinner{
        animation-duration: 1.4s;
    }
}
