/* ??????????????????????????????????????????????????????????????
   Global site-wide loading indicator
   Consists of:
     • A thin top progress bar (YouTube / GitHub style)
     • A busy state for buttons while a form is submitting
     • A full-page veil for long-running AI / analyze operations
   ?????????????????????????????????????????????????????????????? */

#page-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 10000;
    pointer-events: none;
    background: transparent;
    opacity: 0;
    transition: opacity .25s ease;
}

#page-progress.active { opacity: 1; }

#page-progress .bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2563eb 0%, #60a5fa 50%, #2563eb 100%);
    background-size: 200% 100%;
    box-shadow: 0 0 10px rgba(37, 99, 235, .45);
    transition: width .25s ease;
}

#page-progress.indeterminate .bar {
    width: 100% !important;
    animation: page-progress-shimmer 1.2s linear infinite;
}

@keyframes page-progress-shimmer {
    0%   { background-position:   0% 0; }
    100% { background-position: 200% 0; }
}

/* ?? Busy submit buttons ????????????????????????????????????????? */
button.is-busy,
.k-btn.is-busy {
    position: relative;
    pointer-events: none;
    opacity: .85;
}

button.is-busy > *,
.k-btn.is-busy > * {
    visibility: hidden;
}

button.is-busy::after,
.k-btn.is-busy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: page-spin .7s linear infinite;
    visibility: visible;
}

@keyframes page-spin { to { transform: rotate(360deg); } }

/* ?? Optional full-page veil (opt-in via data-busy-veil) ???????? */
#page-busy-veil {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#page-busy-veil.show { display: flex; }

#page-busy-veil .veil-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.4rem 1.8rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    gap: .9rem;
    font-weight: 600;
    color: #0f172a;
    font-size: .9rem;
}

#page-busy-veil .veil-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: page-spin .7s linear infinite;
}
