/* Advanced Inventory Loading Overlay */

/* Ensure parent container supports absolute positioning */
#mainInventoryContent {
    position: relative;
    background-color: #f9f9f9;
}

.inventory-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: radial-gradient(circle at 30% 20%, rgba(33, 150, 243, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(33, 150, 243, 0.1) 0%, transparent 50%),
                linear-gradient(135deg, #f9f9f9 0%, #f8f9fa 50%, #f9f9f9 100%);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Animated Background Elements */
.loading-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: floatOrb 8s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(33, 150, 243, 0.3) 0%, transparent 70%);
    top: -150px;
    left: -150px;
    animation-delay: 0s;
}

.orb-2 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(25, 118, 210, 0.2) 0%, transparent 70%);
    top: 60%;
    right: -100px;
    animation-delay: -4s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(21, 101, 192, 0.15) 0%, transparent 70%);
    bottom: -125px;
    left: 40%;
    animation-delay: -2s;
}

/* Wave Animation */
.wave-animation {
    position: absolute;
    bottom: -50px;
    left: 0;
    width: 100%;
    height: 200px;
}

.wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 100px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    border-radius: 50% 50% 0 0;
    animation: waveMove 6s ease-in-out infinite;
}

.wave-1 {
    animation-delay: 0s;
    opacity: 0.4;
}

.wave-2 {
    animation-delay: -2s;
    opacity: 0.3;
    height: 80px;
}

.wave-3 {
    animation-delay: -4s;
    opacity: 0.2;
    height: 60px;
}

/* Main Loading Container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    max-width: 500px;
    padding: 40px;
    text-align: center;
    position: relative;
    z-index: 1060;
    animation: containerEntrance 0.8s ease-out;
}

/* Clean Loading Animation */
.loading-animation {
    position: relative;
    width: 240px;
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 35px;
    animation: animationEntrance 1s ease-out 0.3s both;
}

/* Morphing Loader */
.morph-loader {
    display: flex;
    gap: 8px;
    height: 40px;
    align-items: center;
}

.morph-shape {
    width: 12px;
    height: 12px;
    background: linear-gradient(45deg, #2196f3, #1976d2);
    border-radius: 50%;
    animation: morphAnimation 1.5s ease-in-out infinite;
}

.morph-shape:nth-child(1) {
    animation-delay: 0s;
}

.morph-shape:nth-child(2) {
    animation-delay: 0.2s;
}

.morph-shape:nth-child(3) {
    animation-delay: 0.4s;
}

/* Progress Bar */
.progress-container {
    width: 180px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(10px);
}

.progress-bar {
    width: 100%;
    height: 100%;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2196f3, #1976d2, #2196f3);
    background-size: 200% 100%;
    border-radius: 2px;
    animation: progressFill 2s ease-in-out infinite;
}

.progress-glow {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, transparent, rgba(33, 150, 243, 0.5), transparent);
    border-radius: 4px;
    animation: progressGlow 2s ease-in-out infinite;
}

.progress-text {
    margin-top: 12px;
    font-size: 13px;
    color: #666;
    font-weight: 500;
    letter-spacing: 0.5px;
    animation: textFadeIn 1s ease-out 1s both;
}

/* Floating Particles */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: linear-gradient(45deg, #2196f3, #1976d2);
    border-radius: 50%;
    animation: particleFloat 4s linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 3s; }
.particle:nth-child(2) { left: 20%; animation-delay: -0.5s; animation-duration: 4s; }
.particle:nth-child(3) { left: 35%; animation-delay: -1s; animation-duration: 3.5s; }
.particle:nth-child(4) { left: 50%; animation-delay: -1.5s; animation-duration: 4.5s; }
.particle:nth-child(5) { left: 65%; animation-delay: -2s; animation-duration: 3s; }
.particle:nth-child(6) { left: 80%; animation-delay: -2.5s; animation-duration: 4s; }
.particle:nth-child(7) { left: 90%; animation-delay: -3s; animation-duration: 3.5s; }
.particle:nth-child(8) { left: 25%; animation-delay: -3.5s; animation-duration: 4.5s; }

/* Enhanced Text */
.loading-text {
    animation: textEntrance 1s ease-out 0.5s both;
}

.loading-title {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 12px 0;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleShimmer 3s ease-in-out infinite;
}

.loading-subtitle {
    font-size: 16px;
    color: #666;
    margin: 0 0 20px 0;
    opacity: 0.9;
    animation: subtitleFade 2s ease-in-out infinite;
}

.loading-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.dot {
    width: 8px;
    height: 8px;
    background: linear-gradient(45deg, #2196f3, #1976d2);
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

/* Advanced Animation Keyframes */

/* Background Animations */
@keyframes floatOrb {
    0%, 100% {
        transform: translateY(0px) translateX(0px) scale(1);
        opacity: 0.6;
    }
    33% {
        transform: translateY(-30px) translateX(20px) scale(1.1);
        opacity: 0.8;
    }
    66% {
        transform: translateY(20px) translateX(-15px) scale(0.9);
        opacity: 0.4;
    }
}

@keyframes waveMove {
    0% {
        transform: translateX(-50%) rotate(0deg);
        opacity: 0.3;
    }
    50% {
        transform: translateX(-60%) rotate(180deg);
        opacity: 0.6;
    }
    100% {
        transform: translateX(-50%) rotate(360deg);
        opacity: 0.3;
    }
}

/* Container and Element Entrance Animations */
@keyframes containerEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes textFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Morphing Loader Animations */
@keyframes morphAnimation {
    0%, 100% {
        transform: scale(1) translateY(0px);
        border-radius: 50%;
        background: linear-gradient(45deg, #2196f3, #1976d2);
    }
    25% {
        transform: scale(1.2) translateY(-10px);
        border-radius: 20%;
        background: linear-gradient(45deg, #1976d2, #1565c0);
    }
    50% {
        transform: scale(0.8) translateY(-20px);
        border-radius: 10%;
        background: linear-gradient(45deg, #1565c0, #0d47a1);
    }
    75% {
        transform: scale(1.1) translateY(-10px);
        border-radius: 30%;
        background: linear-gradient(45deg, #0d47a1, #2196f3);
    }
}

/* Progress Bar Animations */
@keyframes progressFill {
    0% {
        width: 0%;
        background-position: 0% 50%;
    }
    50% {
        width: 70%;
        background-position: 100% 50%;
    }
    100% {
        width: 100%;
        background-position: 200% 50%;
    }
}

@keyframes progressGlow {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(-100px);
    }
    50% {
        opacity: 1;
        transform: translateX(100px);
    }
}

/* Particle Animations */
@keyframes particleFloat {
    0% {
        bottom: -10px;
        opacity: 0;
        transform: translateX(0px) rotate(0deg);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        bottom: 100%;
        opacity: 0;
        transform: translateX(20px) rotate(360deg);
    }
}

/* Text Animations */
@keyframes textEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0px);
    }
}

@keyframes titleShimmer {
    0%, 100% {
        background-position: -200% center;
    }
    50% {
        background-position: 200% center;
    }
}

@keyframes subtitleFade {
    0%, 100% {
        opacity: 0.9;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.8) translateY(0px);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2) translateY(-15px);
        opacity: 1;
    }
}

/* Fade Out Transition */
.inventory-loading-overlay.fade-out {
    animation: advancedFadeOut 0.6s ease-out forwards;
}

@keyframes advancedFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px);
    }
    60% {
        opacity: 0.3;
        transform: scale(1.01);
        filter: blur(1px);
    }
    100% {
        opacity: 0;
        transform: scale(1.02);
        filter: blur(2px);
    }
}

/* Fade in animation for main content */
.inventory-content-fade-in {
    animation: contentFadeIn 0.8s ease-out forwards;
}

@keyframes contentFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.99);
        filter: blur(1px);
    }
    30% {
        opacity: 0.3;
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0px);
    }
}

/* Smooth vehicle loading - prevent flash */
#carInventory {
    min-height: 200px;
    background-color: #f9f9f9;
    transition: opacity 0.2s ease;
    position: relative;
}

/* Mobile Vehicle Loading Animation */
.mobile-vehicle-loading {
    position: fixed;
    top: calc(60px + 132px); /* Mobile header + filter bar */
    left: 0;
    right: 0;
    bottom: 0;
    min-height: calc(100vh - 192px);
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.mobile-loading-content {
    text-align: center;
    padding: 40px 20px;
}

/* Mobile Spinner Animation */
.mobile-loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
}

.mobile-spinner-ring {
    position: absolute;
    border: 4px solid transparent;
    border-top: 4px solid #2196f3;
    border-radius: 50%;
    animation: mobileSpinnerRotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.mobile-spinner-ring:nth-child(1) {
    width: 64px;
    height: 64px;
    top: 8px;
    left: 8px;
    animation-delay: -0.45s;
}

.mobile-spinner-ring:nth-child(2) {
    width: 52px;
    height: 52px;
    top: 14px;
    left: 14px;
    animation-delay: -0.3s;
}

.mobile-spinner-ring:nth-child(3) {
    width: 40px;
    height: 40px;
    top: 20px;
    left: 20px;
    animation-delay: -0.15s;
}

@keyframes mobileSpinnerRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Mobile Loading Text */
.mobile-loading-text h3 {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 10px 0;
    animation: mobileTextPulse 2s ease-in-out infinite;
}

.mobile-loading-text p {
    font-size: 16px;
    color: #666;
    margin: 0 0 25px 0;
    opacity: 0.8;
}

@keyframes mobileTextPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Mobile Loading Dots */
.mobile-loading-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.mobile-dot {
    width: 8px;
    height: 8px;
    background: #2196f3;
    border-radius: 50%;
    animation: mobileDotBounce 1.4s ease-in-out infinite;
}

.mobile-dot:nth-child(1) {
    animation-delay: 0s;
}

.mobile-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.mobile-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes mobileDotBounce {
    0%, 80%, 100% {
        transform: scale(0.8) translateY(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2) translateY(-10px);
        opacity: 1;
    }
}

/* Vehicle card fade-in on mobile */
@media (max-width: 768px) {
    .mobile-vehicle-fade-in {
        opacity: 0;
        animation: mobileVehicleFadeIn 0.5s ease-out forwards;
    }
}

/* Mobile loading styles are now handled via JavaScript */

@keyframes mobileVehicleFadeIn {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive Design - Keep it simple like desktop */
/* Mobile: Completely disable desktop animations */
.mobile-no-animation {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    animation: none !important;
    transition: none !important;
}

.mobile-no-animation * {
    animation: none !important;
    transition: none !important;
    transform: none !important;
}

/* Desktop - hide mobile vehicle loading */
@media (min-width: 769px) {
    .mobile-vehicle-loading {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Mobile: Instant display - no animations at all for main loading */
    .inventory-loading-overlay,
    .inventory-loading-overlay.fade-out {
        display: none !important;
        animation: none !important;
        transition: none !important;
    }
    
    /* Completely disable content fade-in on mobile */
    .inventory-content-fade-in {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }
    
    /* Force no animations on main content except vehicle loading */
    #inventoryMainContent {
        background-color: #f9f9f9 !important;
    }
    
    /* Allow mobile vehicle loading animations */
    .mobile-vehicle-loading,
    .mobile-vehicle-loading * {
        animation: unset !important;
        transition: unset !important;
        transform: unset !important;
        opacity: unset !important;
    }
    
    /* Mobile vehicle loading adjustments */
    .mobile-vehicle-loading {
        top: calc(60px + 132px); /* Account for mobile header + filter bar */
        min-height: calc(100vh - 192px);
        z-index: 1000;
    }
    
    .mobile-loading-spinner {
        width: 60px;
        height: 60px;
        margin: 0 auto 25px;
    }
    
    .mobile-loading-text h3 {
        font-size: 22px;
    }
    
    .mobile-loading-text p {
        font-size: 15px;
    }
    
    /* Ensure smooth vehicle replacement on mobile */
    #carInventory {
        min-height: 150px;
        background-color: #f9f9f9 !important;
    }
    
    .loading-container {
        padding: 30px 20px;
        gap: 30px;
        max-width: 350px;
    }
    
    .loading-animation {
        width: 200px;
        height: 120px;
        gap: 25px;
    }
    
    .morph-loader {
        gap: 6px;
        height: 30px;
    }
    
    .morph-shape {
        width: 10px;
        height: 10px;
    }
    
    .progress-container {
        width: 160px;
    }
    
    .progress-text {
        font-size: 13px;
    }
    
    .loading-title {
        font-size: 24px;
    }
    
    .loading-subtitle {
        font-size: 15px;
    }
    
    .dot {
        width: 6px;
        height: 6px;
    }
    
    .gradient-orb {
        filter: blur(40px);
    }
    
    .orb-1 {
        width: 200px;
        height: 200px;
    }
    
    .orb-2 {
        width: 150px;
        height: 150px;
    }
    
    .orb-3 {
        width: 180px;
        height: 180px;
    }
    
    .particle {
        width: 3px;
        height: 3px;
    }
}

@media (max-width: 480px) {
    /* Even faster loading overlay fade on small screens */
    .inventory-loading-overlay.fade-out {
        animation-duration: 0.1s;
    }
    
    /* Extra strong animation disabling on small mobile */
    .inventory-content-fade-in,
    #inventoryMainContent,
    #inventoryMainContent *,
    .car-card,
    .car-card * {
        animation: none !important;
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
    
    #inventoryMainContent {
        background-color: #f9f9f9 !important;
    }
    
    .loading-container {
        padding: 25px 15px;
        gap: 25px;
        max-width: 300px;
    }
    
    .loading-animation {
        width: 180px;
        height: 110px;
        gap: 20px;
    }
    
    .progress-container {
        width: 140px;
    }
    
    .progress-text {
        font-size: 12px;
    }
    
    .loading-title {
        font-size: 22px;
    }
    
    .loading-subtitle {
        font-size: 14px;
    }
    
    .morph-shape {
        width: 8px;
        height: 8px;
    }
    
    .dot {
        width: 5px;
        height: 5px;
    }
}



/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .inventory-loading-overlay *,
    .inventory-loading-overlay *::before,
    .inventory-loading-overlay *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .gradient-orb,
    .wave,
    .particle,
    .morph-shape {
        opacity: 0.5;
        animation: none;
        transform: none;
    }
    
    .progress-fill {
        animation: none;
        width: 100%;
    }
} 