/* ===== HAD CONSULTANTS LOADER PERFORMANCE FIX ===== */

/* ===== QUICK 1-SECOND LOADER FIX ===== */

/* Option 1: 1-second limited spin (RECOMMENDED) */
.decorative-spinner, 
.hero-spinner,
[class*="spin"],
.loading,
.loading2,
.preloader,
.rotate-loading {
    animation-duration: 1s !important;        /* Fast 1-second rotation */
    animation-iteration-count: 1 !important;  /* Only spin once */
    animation-fill-mode: forwards !important; /* Stop in final position */
    animation-timing-function: ease-out !important; /* Smooth deceleration */
}

/* Fix main loading animations specifically */
.loading-container .loading {
    animation: rotate-loading-fast 1s linear 0s 1 normal !important;
}

.loading.loading2 {
    animation: rotate-loading-fast 1s linear 0s 1 normal !important;
}

/* Create faster keyframe animation */
@keyframes rotate-loading-fast {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Option 2: Even faster 0.5-second spin */
.ultra-fast-spinner {
    animation-duration: 0.5s !important;
    animation-iteration-count: 1 !important;
    animation-fill-mode: forwards !important;
}

/* Option 3: Fade-in instead of spinning (ALTERNATIVE) */
.fade-instead-of-spin {
    animation: fadeInQuick 0.8s ease-in-out forwards !important;
}

@keyframes fadeInQuick {
    from { 
        opacity: 0; 
        transform: scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* Disable all infinite animations */
[style*="animation-iteration-count: infinite"],
.infinite-spin,
[class*="infinite"] {
    animation-iteration-count: 1 !important;
    animation-duration: 1s !important;
}

/* Fix any remaining infinite animations */
*[style*="infinite"] {
    animation-iteration-count: 1 !important;
    animation-duration: 1s !important;
}

/* ===== LOADING COMPLETION INDICATOR ===== */
.loading-complete {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    animation: showCompletion 2s ease-in-out;
    z-index: 9999;
}

@keyframes showCompletion {
    0% { opacity: 0; transform: translateY(-20px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.rotating-element,
.loading,
.loading2,
.preloader {
    will-change: transform; /* Better performance */
    backface-visibility: hidden; /* Reduce repaints */
    transform-origin: center center; /* Optimize rotation point */
}

/* ===== PRELOADER SPECIFIC FIXES ===== */
.preloader {
    transition: opacity 0.3s ease-out !important;
}

/* Auto-hide preloader after 1.5 seconds maximum */
.preloader {
    animation: autoHideLoader 1.5s ease-out forwards !important;
}

@keyframes autoHideLoader {
    0% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* ===== MOBILE OPTIMIZATION ===== */
@media (max-width: 768px) {
    /* Even faster on mobile devices */
    .decorative-spinner,
    .loading,
    .loading2 {
        animation-duration: 0.7s !important;
    }
    
    /* Reduce motion for users who prefer it */
    @media (prefers-reduced-motion: reduce) {
        .decorative-spinner,
        .loading,
        .loading2,
        .preloader {
            animation: none !important;
            opacity: 0 !important;
            visibility: hidden !important;
        }
    }
}

/* ===== BACKUP FALLBACK ===== */
/* If all else fails, hide loaders after 2 seconds */
.loading-container,
.preloader,
.loader {
    max-width: 100%;
    max-height: 100%;
    animation-duration: 1s !important;
    animation-iteration-count: 1 !important;
}

/* Force completion state */
.loading-complete-fallback {
    animation-play-state: paused !important;
    transform: rotate(360deg) !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ===== ADDITIONAL SPINNER TARGETING ===== */
/* Target any remaining problematic spinners */
.fa-spin,
.spinner,
[data-animation*="spin"],
[class*="rotation"],
[class*="spinning"] {
    animation-duration: 1s !important;
    animation-iteration-count: 1 !important;
    animation-fill-mode: forwards !important;
}

/* ===== THEME LOADER SPECIFIC FIX ===== */
.theme-loader,
.vl-preloader,
[id*="preloader"],
[id*="loader"] {
    animation-duration: 1s !important;
    animation-iteration-count: 1 !important;
    transition: all 0.3s ease-out !important;
}