/* ---------- Reusable branded loading overlay (public/js/ds-loader.js) ----------
   A full-screen "please wait" overlay used anywhere a click/submit kicks off
   a slow navigation or async action (module launcher cards, login submit,
   ...) so it can't be mistaken for a missed click and re-triggered. Loaded
   globally in both layouts/admin.blade.php and layouts/auth.blade.php - one
   implementation shared app-wide instead of each page rolling its own.

   Don't build this markup by hand: call `DSLoader.show('Some text...')` /
   `DSLoader.hide()` (ds-loader.js) and it injects/updates this structure
   itself, toggling the `.open` class:

     <div class="ds-loading-overlay">
       <div class="ds-loading-panel">
         <div class="ds-loading-ring">
           <img class="ds-loading-mark" src="...logo-icon-square.png">
         </div>
         <div class="ds-loading-text">
           <span class="ds-loading-text-label">Opening module</span><span class="ds-loading-dots">...</span>
         </div>
         <div class="ds-loading-bar"><span></span></div>
       </div>
     </div>

   A brand-colored conic ring spins around the BM-Soft mark, the mark itself
   breathes (scale pulse), and an indeterminate bar slides underneath - all
   sized with clamp()/vw so it scales cleanly from phone to desktop with no
   separate breakpoint. Every animation is skipped under
   prefers-reduced-motion (still visible, just static) so this stays
   accessible. */
.ds-loading-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(30, 41, 82, 0.72), rgba(10, 14, 30, 0.82));
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.ds-loading-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.ds-loading-panel {
    background: var(--db-surface, #fff);
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: var(--db-radius-lg, 16px);
    padding: clamp(1.75rem, 6vw, 2.5rem) clamp(1.75rem, 8vw, 3rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    width: min(320px, 86vw);
    box-shadow: 0 20px 48px rgba(16, 24, 40, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
    transform: translateY(8px) scale(0.97);
    transition: transform 0.25s ease;
}

.ds-loading-overlay.open .ds-loading-panel {
    transform: translateY(0) scale(1);
}

.ds-loading-ring {
    position: relative;
    width: clamp(72px, 20vw, 104px);
    height: clamp(72px, 20vw, 104px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ds-loading-ring::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(from 0deg, #4f46e5, #38bdf8, #4f46e5 60%, transparent 85%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: ds-loading-ring-spin 1.1s linear infinite;
}

.ds-loading-ring::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.35), transparent 70%);
    animation: ds-loading-glow-pulse 1.6s ease-in-out infinite;
}

.ds-loading-mark {
    position: relative;
    width: 62%;
    height: 62%;
    object-fit: contain;
    filter: drop-shadow(0 2px 10px rgba(79, 70, 229, 0.35));
    animation: ds-loading-mark-breathe 1.6s ease-in-out infinite;
}

.ds-loading-text {
    color: var(--db-text, #1f2937);
    font-weight: 600;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
}

.ds-loading-dots {
    display: inline-block;
    width: 1.2em;
    text-align: left;
    overflow: hidden;
    vertical-align: bottom;
    animation: ds-loading-dots-cycle 1.2s steps(4, end) infinite;
}

.ds-loading-bar {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: var(--db-border, #e5e7eb);
    overflow: hidden;
}

.ds-loading-bar span {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4f46e5, #38bdf8);
    animation: ds-loading-bar-slide 1.1s ease-in-out infinite;
}

@keyframes ds-loading-ring-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ds-loading-glow-pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(0.92);
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
    }
}

@keyframes ds-loading-mark-breathe {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

@keyframes ds-loading-dots-cycle {
    0% {
        width: 0;
    }
    100% {
        width: 1.2em;
    }
}

@keyframes ds-loading-bar-slide {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(360%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ds-loading-ring::before,
    .ds-loading-ring::after,
    .ds-loading-mark,
    .ds-loading-dots,
    .ds-loading-bar span {
        animation: none;
    }
}

/* Generic "this clickable thing was just clicked, an async action is in
   flight" dimmer - e.g. the module launcher card that opens the POS
   terminal in a new tab, where the page itself doesn't navigate away so the
   full-screen overlay above isn't appropriate. */
.ds-card-loading {
    opacity: 0.6;
    pointer-events: none;
}
