/* "Please wait" - the application's single busy indicator.
   Driven by pleaseWait in Scripts/App/helpers.js; markup in Views/shared/please_wait_modal.cshtml.

   Deliberately NOT a Bootstrap modal. A Bootstrap modal takes over focus, adds .modal-open to the
   body and compensates for the scrollbar with a padding-right, which shifts the whole page sideways
   each time it opens and closes - very visible when it opens for a third of a second. It also
   refuses to hide if it was shown by anything other than its own API. This is a plain fixed
   element toggled by a class instead.

   z-index: AdminLTE's navbar sits at about 1030 and Bootstrap modals at 1050, so 2000 is above
   everything the application itself puts on screen.

   The veil is hidden AND invisible for the first 150 ms (the animation's "both" fill keeps the
   from-state), so a fast request shows nothing at all, and - importantly - it cannot swallow a
   click while it is still invisible. */

.pw-veil {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: pw-fade-in .2s ease-out .15s both;
}
.pw-veil.pw-on { display: flex; }

.pw-card {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 220px;
    padding: 18px 26px 21px 22px;
    overflow: hidden;
    border-radius: 14px;
    background: #fff;
    font-size: 15px;
    font-weight: 500;
    color: var(--brand-text, #1f2937);
    font-family: var(--brand-font, inherit);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .16);
}
.pw-card > * + * { margin-left: 14px; }

.pw-spinner {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid rgba(0, 0, 0, .08);
    border-top-color: var(--brand-primary-bg, #2A5A63);
    animation: pw-spin .8s linear infinite;
}
.pw-dots::after {
    content: "";
    display: inline-block;
    width: 1.2em;
    text-align: left;
    animation: pw-dots 1.2s steps(4, end) infinite;
}
.pw-bar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    margin-left: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, .05);
}
.pw-bar::before {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    width: 40%;
    border-radius: 3px;
    background: var(--brand-primary-bg, #2A5A63);
    animation: pw-slide 1.3s ease-in-out infinite;
}

/* Non-blocking indicator: used once the page is up or the user has acted, so a load never
   steals a click. The table being reloaded is dimmed instead.

   Its colour is NOT the brand/primary colour. The bar is 3px at the very top of the viewport,
   which is exactly where the header sits - painted in the primary colour it is the header's own
   colour on top of the header, i.e. invisible. It has to read against both the dark header and
   the light page behind it when scrolled, so it uses the accent instead. */
.pw-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    overflow: hidden;
    z-index: 2001;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease-out;
}
.pw-topbar.active { opacity: 1; transition-delay: .15s; }
.pw-topbar::before {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    width: 40%;
    border-radius: 3px;
    background: var(--brand-accent, #f39c12);
    animation: pw-slide 1.3s ease-in-out infinite;
}
.pw-loading {
    opacity: .55;
    pointer-events: none;
    transition: opacity .2s ease-out .15s;
}

@keyframes pw-fade-in { from { opacity: 0; visibility: hidden; } to { opacity: 1; visibility: visible; } }
@keyframes pw-spin { to { transform: rotate(360deg); } }
@keyframes pw-slide { from { left: -40%; } to { left: 100%; } }
@keyframes pw-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }

@media (prefers-reduced-motion: reduce) {
    .pw-spinner { animation-duration: 2.4s; }
    .pw-bar::before, .pw-dots::after, .pw-topbar::before { animation: none; }
}
