/* Advanced Loader Styles */
.loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background-color: #030712; /* Dark background */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
    overflow: hidden;
}

.loader-wrapper.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Animated background gradient */
.loader-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(125deg, #030712 0%, #111827 25%, #1e3a8a 50%, #111827 75%, #030712 100%);
    background-size: 400% 400%;
    opacity: 0.3;
    animation: gradient-shift 15s ease infinite;
}

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

/* Background grid */
.loader-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    perspective: 1000px;
    transform-style: preserve-3d;
    animation: grid-animation 20s linear infinite;
}

/* Main loader container */
.loader {
    position: relative;
    width: 200px;
    height: 200px;
    perspective: 800px;
    z-index: 2;
}

/* Rotating cube */
.cube-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    animation: rotate 8s infinite linear;
}

.cube {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.cube-face {
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    backface-visibility: visible;
    transform-style: preserve-3d;
    transition: all 0.3s ease;
}

.cube-face:nth-child(1) { transform: translateZ(50px); background: rgba(59, 130, 246, 0.1); }
.cube-face:nth-child(2) { transform: rotateY(180deg) translateZ(50px); background: rgba(168, 85, 247, 0.1); border-color: rgba(168, 85, 247, 0.5); box-shadow: 0 0 20px rgba(168, 85, 247, 0.5); }
.cube-face:nth-child(3) { transform: rotateY(90deg) translateZ(50px); background: rgba(45, 212, 191, 0.1); border-color: rgba(45, 212, 191, 0.5); box-shadow: 0 0 20px rgba(45, 212, 191, 0.5); }
.cube-face:nth-child(4) { transform: rotateY(-90deg) translateZ(50px); background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.5); box-shadow: 0 0 20px rgba(251, 191, 36, 0.5); }
.cube-face:nth-child(5) { transform: rotateX(90deg) translateZ(50px); background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.5); box-shadow: 0 0 20px rgba(244, 63, 94, 0.5); }
.cube-face:nth-child(6) { transform: rotateX(-90deg) translateZ(50px); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.5); box-shadow: 0 0 20px rgba(16, 185, 129, 0.5); }

/* Pulsating circle */
.pulse-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, #3b82f6, #a855f7, #2dd4bf);
    animation: pulse 2s infinite ease-in-out;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.8);
}

/* Inner pulse circles */
.pulse-circle::before,
.pulse-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 2s infinite ease-out;
}

.pulse-circle::after {
    animation-delay: 0.5s;
}

/* Logo in the center */
.loader-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    z-index: 2;
    letter-spacing: 2px;
    font-family: 'Canopee', sans-serif;
    text-transform: uppercase;
}

/* Loading text */
.loading-text {
    position: absolute;
    bottom: -40px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 16px;
    color: white;
    letter-spacing: 3px;
    font-family: 'Slimmary Light', serif;
}

.loading-text span {
    display: inline-block;
    animation: wave 1.5s infinite ease-in-out;
}

.loading-text span:nth-child(1) { animation-delay: 0.0s; }
.loading-text span:nth-child(2) { animation-delay: 0.1s; }
.loading-text span:nth-child(3) { animation-delay: 0.2s; }
.loading-text span:nth-child(4) { animation-delay: 0.3s; }
.loading-text span:nth-child(5) { animation-delay: 0.4s; }
.loading-text span:nth-child(6) { animation-delay: 0.5s; }
.loading-text span:nth-child(7) { animation-delay: 0.6s; }

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

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
    opacity: 0;
    animation: particle-animation 3s infinite ease-out;
}

/* Progress bar */
.progress-container {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #3b82f6, #a855f7, #2dd4bf);
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
    font-family: 'Gilroy', sans-serif;
}

/* Countdown timer */
.countdown {
    font-size: 32px;
    font-weight: bold;
    color: white;
    margin-top: 10px;
    background: linear-gradient(45deg, #3b82f6, #a855f7, #2dd4bf);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradient 8s ease infinite;
    background-size: 200% 200%;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    transition: transform 0.3s ease, opacity 0.3s ease;
    font-family: 'Gilroy', sans-serif;
}

.countdown.pulse-animation {
    animation: countdown-pulse 0.5s ease-in-out;
}

@keyframes countdown-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); opacity: 0.7; }
    100% { transform: scale(1); }
}

/* Glowing orbs */
.orbs-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.15;
    animation: float-around 15s infinite ease-in-out;
}

.orb:nth-child(1) {
    background: #3b82f6;
    top: 20%;
    left: 20%;
    animation-duration: 20s;
}

.orb:nth-child(2) {
    background: #a855f7;
    top: 60%;
    left: 70%;
    width: 200px;
    height: 200px;
    animation-duration: 25s;
    animation-delay: 2s;
}

.orb:nth-child(3) {
    background: #2dd4bf;
    top: 70%;
    left: 30%;
    width: 180px;
    height: 180px;
    animation-duration: 18s;
    animation-delay: 1s;
}

.orb:nth-child(4) {
    background: #f43f5e;
    top: 30%;
    left: 80%;
    width: 120px;
    height: 120px;
    animation-duration: 22s;
    animation-delay: 3s;
}

/* Animations */
@keyframes rotate {
    0% { transform: rotateX(0) rotateY(0) rotateZ(0); }
    100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.7; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.9; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.7; }
}

@keyframes ripple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

@keyframes wave {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes particle-animation {
    0% { transform: scale(0); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: scale(20); opacity: 0; }
}

@keyframes float-around {
    0% { transform: translate(0, 0); }
    25% { transform: translate(5%, 10%); }
    50% { transform: translate(-5%, 5%); }
    75% { transform: translate(10%, -5%); }
    100% { transform: translate(0, 0); }
}

@keyframes grid-animation {
    0% { transform: perspective(1000px) rotateX(10deg) rotateY(0) translateZ(0); }
    100% { transform: perspective(1000px) rotateX(10deg) rotateY(360deg) translateZ(0); }
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    .loader {
        width: 150px;
        height: 150px;
    }

    .cube-face {
        width: 80px;
        height: 80px;
    }

    .cube-face:nth-child(1) { transform: translateZ(40px); }
    .cube-face:nth-child(2) { transform: rotateY(180deg) translateZ(40px); }
    .cube-face:nth-child(3) { transform: rotateY(90deg) translateZ(40px); }
    .cube-face:nth-child(4) { transform: rotateY(-90deg) translateZ(40px); }
    .cube-face:nth-child(5) { transform: rotateX(90deg) translateZ(40px); }
    .cube-face:nth-child(6) { transform: rotateX(-90deg) translateZ(40px); }

    .pulse-circle {
        width: 40px;
        height: 40px;
    }

    .loader-logo {
        font-size: 18px;
    }

    .progress-container {
        bottom: 30px;
        width: 150px;
    }
}
