/* Show preloader by default (before JS loads) */
.preloader {
    opacity: 1;
    visibility: visible;
}
/* Prevent scrolling while preloader is active */
body:has(.preloader:not(.hidden)) {
    overflow: hidden;
    height: 100vh;
}
/* AI-Powered Futuristic Preloader */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #0a0e27;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.8s ease, visibility 0.8s ease;
    overflow: hidden;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
}

.preloader::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 50%, rgba(240, 147, 251, 0.15) 0%, transparent 50%);
    animation: rotate 20s linear infinite;
}

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

.preloader-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

/* AI Brain/Neural Network */
.ai-brain {
    width: 200px;
    height: 200px;
    margin: 0 auto 40px;
    position: relative;
}

/* Central Core */
.brain-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    box-shadow: 0 0 60px rgba(102, 126, 234, 0.8),
                0 0 100px rgba(102, 126, 234, 0.4),
                inset 0 0 20px rgba(255, 255, 255, 0.3);
    animation: pulse-core 2s ease-in-out infinite;
}

@keyframes pulse-core {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 60px rgba(102, 126, 234, 0.8),
                    0 0 100px rgba(102, 126, 234, 0.4),
                    inset 0 0 20px rgba(255, 255, 255, 0.3);
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 80px rgba(102, 126, 234, 1),
                    0 0 120px rgba(102, 126, 234, 0.6),
                    inset 0 0 30px rgba(255, 255, 255, 0.5);
    }
}

/* Orbiting Rings */
.orbit-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    border-right-color: #667eea;
}

.orbit-ring:nth-child(1) {
    width: 100px;
    height: 100px;
    margin: -50px 0 0 -50px;
    animation: orbit 3s linear infinite;
}

.orbit-ring:nth-child(2) {
    width: 140px;
    height: 140px;
    margin: -70px 0 0 -70px;
    border-top-color: #f093fb;
    border-right-color: #f093fb;
    animation: orbit 4s linear infinite reverse;
}

.orbit-ring:nth-child(3) {
    width: 180px;
    height: 180px;
    margin: -90px 0 0 -90px;
    border-top-color: #00d4aa;
    border-right-color: #00d4aa;
    animation: orbit 5s linear infinite;
}

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

/* Data Nodes */
.data-node {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.8);
    animation: node-pulse 2s ease-in-out infinite;
}

.data-node:nth-child(4) {
    top: 10%;
    left: 50%;
    animation-delay: 0s;
}

.data-node:nth-child(5) {
    top: 50%;
    right: 10%;
    background: #f093fb;
    box-shadow: 0 0 10px rgba(240, 147, 251, 0.8);
    animation-delay: 0.5s;
}

.data-node:nth-child(6) {
    bottom: 10%;
    left: 50%;
    background: #00d4aa;
    box-shadow: 0 0 10px rgba(0, 212, 170, 0.8);
    animation-delay: 1s;
}

.data-node:nth-child(7) {
    top: 50%;
    left: 10%;
    background: #f093fb;
    box-shadow: 0 0 10px rgba(240, 147, 251, 0.8);
    animation-delay: 1.5s;
}

@keyframes node-pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(2);
        opacity: 0.3;
    }
}

/* Connection Lines */
.connection-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    transform-origin: left center;
    opacity: 0.4;
    animation: line-pulse 3s ease-in-out infinite;
}

@keyframes line-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

/* Loading Text */
.loader-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #f093fb 50%, #00d4aa 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 4px;
    margin-bottom: 20px;
    animation: gradient-shift 3s ease-in-out infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* AI Status Text */
.ai-status {
    font-family: 'Inter', monospace;
    font-size: 14px;
    color: rgba(102, 126, 234, 0.8);
    letter-spacing: 2px;
    margin-bottom: 30px;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Progress Bar */
.progress-container {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #f093fb, #00d4aa);
    background-size: 200% auto;
    border-radius: 2px;
    animation: progress 2s ease-in-out infinite, gradient-shift 3s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6);
}

@keyframes progress {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* Floating Particles */
.preloader-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(102, 126, 234, 0.6);
    border-radius: 50%;
    animation: particle-float 15s infinite linear;
}

.particle:nth-child(2n) {
    background: rgba(240, 147, 251, 0.6);
    animation-duration: 18s;
}

.particle:nth-child(3n) {
    background: rgba(0, 212, 170, 0.6);
    animation-duration: 20s;
}

@keyframes particle-float {
    0% {
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) translateX(100px) scale(1);
        opacity: 0;
    }
}

/* Loading Stats */
.loading-stats {
    display: flex;
    gap: 30px;
    justify-content: center;
    margin-top: 30px;
    font-family: 'Inter', sans-serif;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
    display: block;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Glitch Effect on Load Complete */
.preloader.hidden .loader-text {
    animation: glitch 0.3s ease-out;
}

@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-5px, 5px); }
    40% { transform: translate(-5px, -5px); }
    60% { transform: translate(5px, 5px); }
    80% { transform: translate(5px, -5px); }
}

/* Responsive */
@media (max-width: 768px) {
    .ai-brain {
        width: 150px;
        height: 150px;
    }
    
    .brain-core {
        width: 40px;
        height: 40px;
    }
    
    .orbit-ring:nth-child(1) {
        width: 70px;
        height: 70px;
        margin: -35px 0 0 -35px;
    }
    
    .orbit-ring:nth-child(2) {
        width: 100px;
        height: 100px;
        margin: -50px 0 0 -50px;
    }
    
    .orbit-ring:nth-child(3) {
        width: 130px;
        height: 130px;
        margin: -65px 0 0 -65px;
    }
    
    .loader-text {
        font-size: 24px;
    }
    
    .progress-container {
        width: 250px;
    }
}