/* Modern Loader Design */

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Modern Loader Container */
.modern-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* DNA Helix Loader */
.dna-loader {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 2rem;
}

.dna-strand {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: dnaHelix 2s infinite linear;
}

.dna-strand:nth-child(1) {
    background: #667eea;
    animation-delay: 0s;
    left: 38px;
}

.dna-strand:nth-child(2) {
    background: #764ba2;
    animation-delay: 0.1s;
    left: 38px;
}

.dna-strand:nth-child(3) {
    background: #667eea;
    animation-delay: 0.2s;
    left: 38px;
}

.dna-strand:nth-child(4) {
    background: #764ba2;
    animation-delay: 0.3s;
    left: 38px;
}

.dna-strand:nth-child(5) {
    background: #667eea;
    animation-delay: 0.4s;
    left: 38px;
}

.dna-strand:nth-child(6) {
    background: #764ba2;
    animation-delay: 0.5s;
    left: 38px;
}

.dna-strand:nth-child(7) {
    background: #667eea;
    animation-delay: 0.6s;
    left: 38px;
}

.dna-strand:nth-child(8) {
    background: #764ba2;
    animation-delay: 0.7s;
    left: 38px;
}

@keyframes dnaHelix {
    0% {
        transform: rotateY(0deg) translateX(20px) rotateY(0deg);
        opacity: 1;
    }
    25% {
        transform: rotateY(90deg) translateX(20px) rotateY(-90deg);
        opacity: 0.7;
    }
    50% {
        transform: rotateY(180deg) translateX(20px) rotateY(-180deg);
        opacity: 1;
    }
    75% {
        transform: rotateY(270deg) translateX(20px) rotateY(-270deg);
        opacity: 0.7;
    }
    100% {
        transform: rotateY(360deg) translateX(20px) rotateY(-360deg);
        opacity: 1;
    }
}

/* Alternative: Neural Network Loader */
.neural-loader {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 2rem;
    display: none; /* Hidden by default, can be activated */
}

.neural-node {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #667eea;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

.neural-node:nth-child(1) {
    top: 10px;
    left: 44px;
    animation: neuralPulse 2s infinite ease-in-out;
    animation-delay: 0s;
}

.neural-node:nth-child(2) {
    top: 44px;
    left: 10px;
    animation: neuralPulse 2s infinite ease-in-out;
    animation-delay: 0.3s;
}

.neural-node:nth-child(3) {
    top: 44px;
    right: 10px;
    animation: neuralPulse 2s infinite ease-in-out;
    animation-delay: 0.6s;
}

.neural-node:nth-child(4) {
    bottom: 10px;
    left: 44px;
    animation: neuralPulse 2s infinite ease-in-out;
    animation-delay: 0.9s;
}

.neural-connection {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    opacity: 0;
    animation: neuralConnection 2s infinite ease-in-out;
}

.neural-connection:nth-child(5) {
    top: 22px;
    left: 22px;
    width: 56px;
    transform: rotate(45deg);
    animation-delay: 0.1s;
}

.neural-connection:nth-child(6) {
    top: 22px;
    right: 22px;
    width: 56px;
    transform: rotate(-45deg);
    animation-delay: 0.4s;
}

.neural-connection:nth-child(7) {
    bottom: 22px;
    left: 22px;
    width: 56px;
    transform: rotate(-45deg);
    animation-delay: 0.7s;
}

.neural-connection:nth-child(8) {
    bottom: 22px;
    right: 22px;
    width: 56px;
    transform: rotate(45deg);
    animation-delay: 1s;
}

@keyframes neuralPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    }
    50% {
        transform: scale(1.5);
        box-shadow: 0 0 30px rgba(102, 126, 234, 0.8);
    }
}

@keyframes neuralConnection {
    0%, 100% {
        opacity: 0;
        transform: scaleX(0);
    }
    50% {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* Quantum Particles Loader */
.quantum-loader {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 2rem;
}

.quantum-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.6);
}

.quantum-particle:nth-child(1) {
    top: 50%;
    left: 50%;
    animation: quantumOrbit1 3s infinite linear;
}

.quantum-particle:nth-child(2) {
    top: 50%;
    left: 50%;
    animation: quantumOrbit2 3s infinite linear;
    animation-delay: 1s;
    background: #764ba2;
    box-shadow: 0 0 15px rgba(118, 75, 162, 0.6);
}

.quantum-particle:nth-child(3) {
    top: 50%;
    left: 50%;
    animation: quantumOrbit3 3s infinite linear;
    animation-delay: 2s;
    background: #10b981;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
}

@keyframes quantumOrbit1 {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) translateX(40px) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg) translateX(40px) rotate(-360deg);
    }
}

@keyframes quantumOrbit2 {
    0% {
        transform: translate(-50%, -50%) rotate(120deg) translateX(30px) rotate(-120deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(480deg) translateX(30px) rotate(-480deg);
    }
}

@keyframes quantumOrbit3 {
    0% {
        transform: translate(-50%, -50%) rotate(240deg) translateX(50px) rotate(-240deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(600deg) translateX(50px) rotate(-600deg);
    }
}

/* Loading Text */
.loader-text {
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 1rem;
    letter-spacing: 0.1em;
}

.loader-subtext {
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

/* Progress Bar */
.loader-progress {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 2rem;
    overflow: hidden;
    position: relative;
}

.loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
    background-size: 200% 100%;
    border-radius: 3px;
    animation: progressFlow 2s ease-in-out infinite;
    width: 0%;
    transition: width 0.3s ease;
}

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

/* Typewriter effect for loading text */
.typewriter-loader {
    overflow: hidden;
    border-right: 2px solid #667eea;
    white-space: nowrap;
    animation: typing 2s steps(20, end) infinite, blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: #667eea; }
}

/* Floating Background Elements */
.loader-bg-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.bg-element {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(45deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    animation: floatBackground 6s ease-in-out infinite;
}

.bg-element:nth-child(1) {
    width: 100px;
    height: 100px;
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.bg-element:nth-child(2) {
    width: 150px;
    height: 150px;
    top: 60%;
    right: 15%;
    animation-delay: 2s;
}

.bg-element:nth-child(3) {
    width: 80px;
    height: 80px;
    bottom: 20%;
    left: 20%;
    animation-delay: 4s;
}

@keyframes floatBackground {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.3;
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
        opacity: 0.6;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .dna-loader,
    .neural-loader,
    .quantum-loader {
        transform: scale(0.8);
    }
    
    .loader-text {
        font-size: 1rem;
    }
    
    .loader-subtext {
        font-size: 0.8rem;
    }
    
    .loader-progress {
        width: 150px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .dna-strand,
    .neural-node,
    .neural-connection,
    .quantum-particle,
    .loader-progress-bar,
    .bg-element {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
    
    .typewriter-loader {
        animation: none;
        border-right: none;
        width: auto;
    }
}