/* Smooth Page Transitions CSS */

/* Base transition styles */
body {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* Page loading state */
body.page-loading {
    opacity: 0;
    pointer-events: none;
}

/* Fade in animation on page load */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Apply fade in to main content */
.page-enter {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Navigation stays persistent visually */
#react-public-header {
    position: relative;
    z-index: 1000;
    background: white;
    transition: none !important;
}

/* Content wrapper for smooth transitions */
.transition-wrapper {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease-in-out;
}

.transition-wrapper.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

.transition-wrapper.fade-in {
    opacity: 0;
    transform: translateY(10px);
}

/* Page transition overlay */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.page-transition-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Loading spinner for transitions */
.transition-loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.transition-loader.active {
    opacity: 1;
}

.transition-loader .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #FF4438;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Preload links hover effect */
a[data-preload] {
    position: relative;
}

a[data-preload]::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #FF4438;
    transition: width 0.3s ease;
}

a[data-preload]:hover::after {
    width: 100%;
}

/* Hero and main content transitions */
.hero,
.page-header,
.main-content,
.login-page-wrapper,
.centered-container,
.section {
    opacity: 0;
    animation: contentFadeIn 0.6s ease-out 0.2s forwards;
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animations for list items */
.features-item,
.pricing-card,
.service-box {
    opacity: 0;
    animation: itemFadeIn 0.5s ease-out forwards;
}

.features-item:nth-child(1) { animation-delay: 0.1s; }
.features-item:nth-child(2) { animation-delay: 0.2s; }
.features-item:nth-child(3) { animation-delay: 0.3s; }

.pricing-card:nth-child(1) { animation-delay: 0.1s; }
.pricing-card:nth-child(2) { animation-delay: 0.2s; }
.pricing-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes itemFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth transition for images */
img {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

img.lazy-loading {
    opacity: 0;
}

img.lazy-loaded {
    animation: imageFadeIn 0.4s ease-out forwards;
}

@keyframes imageFadeIn {
    from {
        opacity: 0;
        filter: blur(5px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    /* Reduce motion for mobile */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
    
    /* Faster transitions on mobile */
    .transition-wrapper,
    .page-transition-overlay {
        transition-duration: 0.2s;
    }
}

/* Progress bar for page loads */
.page-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 68, 56, 0.1);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-progress.active {
    opacity: 1;
}

.page-progress-bar {
    height: 100%;
    background: #FF4438;
    width: 0;
    transition: width 0.3s ease;
}