/* Global loading feedback (ui-loading.js): a slim top progress bar for navigations / submits /
   mutating requests, and an in-place spinner on the button that started the action. */

:root {
    --uil-color: #12a37a;
    --uil-glow: rgba(18, 163, 122, .45);
}

#ui-topbar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    z-index: 3000;
    pointer-events: none;
    transform-origin: 0 50%;
    transform: scaleX(0);
    opacity: 0;
    background: linear-gradient(90deg, var(--uil-color), #3ccf9f);
    box-shadow: 0 0 8px var(--uil-glow);
    transition: transform .25s ease, opacity .3s ease;
}
#ui-topbar.on { opacity: 1; }

/* Busy button: keep its size and label, disable it, add a spinner. */
.ui-busy {
    pointer-events: none;
    cursor: progress !important;
    opacity: .82;
}
.ui-spin {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: .45em;
    vertical-align: -.15em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ui-spin .6s linear infinite;
}
/* Icon-only buttons (e.g. round send button): swap the icon for the spinner. */
.ui-busy--icon > :not(.ui-spin) { display: none !important; }
.ui-busy--icon .ui-spin { margin-right: 0; }

html.ui-navigating, html.ui-navigating * { cursor: progress; }

/* Inline section loader for content swapped in by AJAX (opt-in via ui.loading.section). */
.ui-section-loading { position: relative; min-height: 80px; }
.ui-section-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .55);
    backdrop-filter: blur(1px);
    z-index: 5;
}
.ui-section-loading::before {
    content: "";
    position: absolute;
    top: calc(50% - 14px);
    left: calc(50% - 14px);
    width: 28px;
    height: 28px;
    border: 3px solid var(--uil-color);
    border-right-color: transparent;
    border-radius: 50%;
    animation: ui-spin .7s linear infinite;
    z-index: 6;
}

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

@media (prefers-reduced-motion: reduce) {
    #ui-topbar { transition: opacity .2s; }
    .ui-spin, .ui-section-loading::before { animation-duration: 1.6s; }
}
