#preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-out;
    background-color: var(--preloader-bg, #000000);
}

/* Light/Dark mode handling */
:root {
    --preloader-bg: #ffffff;
    --preloader-accent: #ff1f5a;
    --preloader-secondary: #3a3a3a;
    --preloader-text: #222222;
}

.dark-mode #preloader {
    --preloader-bg: #121212;
    --preloader-accent: #ff1f5a;
    --preloader-secondary: #dddddd;
    --preloader-text: #eeeeee;
}

.loader-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loader {
    width: 120px;
    height: 120px;
    position: relative;
    perspective: 800px;
}

@media (max-width: 768px) {
    .loader {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .loader {
        width: 80px;
        height: 80px;
    }
}

.hexagon-container {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: rotate 6s infinite linear;
}

.logo-hexagon {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.logo-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.logo-inner img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.loading-text {
    margin-top: 20px;
    font-family: 'Arial', sans-serif;
    font-size: 16px;
    color: var(--preloader-text);
    letter-spacing: 2px;
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--preloader-accent);
    animation: typing 3.5s steps(40, end) infinite, blink-caret 0.75s step-end infinite;
}

/* Animation for the hexagon path */
.logo-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: draw 5s ease-in-out forwards infinite alternate;
    animation-play-state: running;
    stroke: var(--preloader-accent);
    fill: transparent;
    stroke-width: 3;
}

.logo-path-secondary {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: draw-secondary 5s ease-in-out forwards infinite alternate;
    animation-play-state: running;
    stroke: var(--preloader-secondary);
    fill: transparent;
    stroke-width: 2;
    opacity: 0.7;
}

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

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--preloader-accent);
    border-radius: 50%;
    animation: particle-float 4s infinite ease-in-out;
}

@keyframes particle-float {
    0%, 100% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    25% {
        opacity: 1;
    }
    50% {
        transform: translateY(-40px) translateX(20px);
        opacity: 0.5;
    }
    75% {
        opacity: 0.2;
    }
}

/* Animations */
@keyframes draw {
    0% {
        stroke-dashoffset: 600;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes draw-secondary {
    0% {
        stroke-dashoffset: 400;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes rotate {
    0% {
        transform: rotateY(0deg) rotateX(0deg);
    }
    25% {
        transform: rotateY(90deg) rotateX(45deg);
    }
    50% {
        transform: rotateY(180deg) rotateX(0deg);
    }
    75% {
        transform: rotateY(270deg) rotateX(-45deg);
    }
    100% {
        transform: rotateY(360deg) rotateX(0deg);
    }
}

@keyframes typing {
    0%, 100% { 
        width: 0 
    }
    50% { 
        width: 100% 
    }
}

@keyframes blink-caret {
    from, to { 
        border-color: transparent 
    }
    50% { 
        border-color: var(--preloader-accent) 
    }
}

.progress-bar {
    width: 150px;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.2);
    margin-top: 15px;
    border-radius: 5px;
    overflow: hidden;
}

.progress {
    width: 0%;
    height: 100%;
    background-color: var(--preloader-accent);
    animation: progress 3s ease-in-out forwards;
}

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

.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
    display: inline-block;
    width: 20px;
    text-align: left;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60% { content: '...'; }
    80%, 100% { content: ''; }
}