/**
 * Lead ROI Smooth AJAX Loader — Frontend CSS
 * Author: Lead ROI Team
 *
 * Contains:
 *  1. Page transition animations (fade, slide, zoom)
 *  2. Spinner loader
 *  3. Progress bar loader
 *  4. Dots loader
 *
 * All colours use the CSS variable --lrsal-color set inline by JS
 * so the admin colour picker value flows through automatically.
 */

/* ================================================================
   1. PAGE TRANSITION ANIMATIONS
   ================================================================ */

/* OUT: content fades / moves away before new content loads */
.lrsal-anim-out {
    animation: lrsal-out 0.3s ease forwards;
    pointer-events: none;
}

@keyframes lrsal-out {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: translateY(-8px); }
}

/* IN: shared setup — all animation types use this class */
.lrsal-anim-in {
    animation-duration: 0.5s;
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* FADE */
.lrsal-anim-in.lrsal-anim-fade {
    animation-name: lrsal-fade-in;
}
@keyframes lrsal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* SLIDE UP */
.lrsal-anim-in.lrsal-anim-slide {
    animation-name: lrsal-slide-in;
}
@keyframes lrsal-slide-in {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ZOOM IN */
.lrsal-anim-in.lrsal-anim-zoom {
    animation-name: lrsal-zoom-in;
}
@keyframes lrsal-zoom-in {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* ================================================================
   2. LOADER — shared base
   All loaders are position:fixed so they sit on top of everything.
   They are hidden by default and shown via the --visible modifier.
   ================================================================ */
.lrsal-loader {
    position: fixed;
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.lrsal-loader--visible {
    opacity: 1;
}

/* ================================================================
   3. SPINNER
   A circular ring centred in the viewport.
   ================================================================ */
.lrsal-spinner {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
}

.lrsal-spinner-ring {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--lrsal-color, #ffcc00);
    border-radius: 50%;
    animation: lrsal-spin 0.75s linear infinite;
}

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

/* ================================================================
   4. PROGRESS BAR
   A thin bar that slides across the very top of the viewport.
   ================================================================ */
.lrsal-progress {
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
}

.lrsal-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--lrsal-color, #ffcc00);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px var(--lrsal-color, #ffcc00);
    transition: none;
}

/* When visible, animate the bar from 0 to ~85% (the last 15% is
   filled instantly when loading completes in JS) */
.lrsal-loader--visible .lrsal-progress-bar {
    animation: lrsal-progress 1.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes lrsal-progress {
    0%   { width: 0%; }
    40%  { width: 50%; }
    70%  { width: 72%; }
    100% { width: 85%; }
}

/* When loader is hidden (load complete), snap bar to 100% then fade */
.lrsal-progress.lrsal-done .lrsal-progress-bar {
    width: 100%;
    transition: width 0.15s ease;
}

/* ================================================================
   5. BOUNCING DOTS
   Three small dots that bounce in sequence, centred in viewport.
   ================================================================ */
.lrsal-dots {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
    padding: 14px 20px;
    border-radius: 40px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.lrsal-dots span {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--lrsal-color, #ffcc00);
    animation: lrsal-bounce 1.2s ease-in-out infinite;
}

.lrsal-dots span:nth-child(1) { animation-delay: 0s; }
.lrsal-dots span:nth-child(2) { animation-delay: 0.18s; }
.lrsal-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes lrsal-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-10px); }
}
