/* =========================================================================
   Enhanced Preloader CSS - CyberFox Pro Theme
   Улучшенный прелоадер с защитой от блокировщиков
   ========================================================================= */

/* Основной контейнер прелоадера */
.cyberfox-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
    will-change: opacity, visibility;
}

/* Анимация исчезновения */
.cyberfox-preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Логотип прелоадера */
.preloader-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    position: relative;
    will-change: transform;
}

.preloader-logo svg {
    width: 100%;
    height: 100%;
}

/* Анимация логотипа - оптимизирована */
.preloader-logo path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawLogo 2s ease-in-out infinite;
    will-change: stroke-dashoffset;
}

@keyframes drawLogo {
    0% { stroke-dashoffset: 200; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -200; }
}

/* Текст загрузки */
.preloader-text {
    color: #0EF6CC;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(14, 246, 204, 0.5);
    will-change: opacity;
}

/* Прогресс-бар */
.preloader-progress {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    will-change: transform;
}

.preloader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0EF6CC, #6C63FF);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    will-change: width;
}

.preloader-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
    will-change: transform;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Процент загрузки */
.preloader-percentage {
    color: #ffffff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    margin-top: 15px;
    text-align: center;
    will-change: opacity;
}

/* Анимация точек - оптимизирована */
.preloader-dots {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.preloader-dot {
    width: 8px;
    height: 8px;
    background: #0EF6CC;
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite both;
    will-change: transform, opacity;
}

.preloader-dot:nth-child(1) { animation-delay: -0.32s; }
.preloader-dot:nth-child(2) { animation-delay: -0.16s; }
.preloader-dot:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Сканирующая линия - оптимизирована */
.preloader-scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #0EF6CC, transparent);
    animation: scanLine 2s linear infinite;
    will-change: transform;
}

@keyframes scanLine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .preloader-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 20px;
    }
    
    .preloader-text {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .preloader-progress {
        width: 250px;
    }
    
    .preloader-percentage {
        font-size: 12px;
    }
}

/* Анимация появления - оптимизирована */
.cyberfox-preloader {
    animation: preloaderFadeIn 0.5s ease-out;
    will-change: opacity, transform;
}

@keyframes preloaderFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Состояние готовности */
.cyberfox-preloader.ready {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
}

.preloader-logo.ready path {
    animation: logoReady 0.8s ease-out forwards;
}

@keyframes logoReady {
    0% { stroke-dashoffset: 200; }
    100% { stroke-dashoffset: 0; }
}

/* Скрытие прелоадера */
.cyberfox-preloader.hidden {
    display: none;
}

/* Защита от блокировщиков - альтернативные стили */
@media (prefers-reduced-motion: reduce) {
    .cyberfox-preloader * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Поддержка для старых браузеров */
@supports not (backdrop-filter: blur(10px)) {
    .cyberfox-preloader {
        background: #0a0a0a;
    }
}

/* Оптимизация производительности */
.cyberfox-preloader {
    contain: layout style paint;
}

/* Fallback для медленных устройств */
@media (max-width: 480px) {
    .preloader-logo {
        width: 60px;
        height: 60px;
    }
    
    .preloader-text {
        font-size: 14px;
    }
    
    .preloader-progress {
        width: 200px;
    }
    
    .preloader-dots {
        gap: 6px;
    }
    
    .preloader-dot {
        width: 6px;
        height: 6px;
    }
}

/* Предотвращение зависания */
.cyberfox-preloader.loading-slow {
    animation: none;
}

.cyberfox-preloader.loading-slow * {
    animation: none !important;
    transition: none !important;
}

/* Состояние ошибки */
.cyberfox-preloader.error {
    background: linear-gradient(135deg, #1a0a0a 0%, #2e1a1a 50%, #3e1616 100%);
}

.preloader-text.error {
    color: #FF6B35;
    animation: errorPulse 2s ease-in-out infinite;
}

@keyframes errorPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
