/* 
YITP Optimized Preloader CSS
=============================
High-performance preloader with YITP branding
- CSS-only animations (no JavaScript dependencies)
- Lightweight and fast
- Auto-timeout mechanism
- Mobile-optimized
- YITP brand colors: #ff5d15 (orange), #1a2e53 (dark blue)
*/

/* Preloader Container */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a2e53 0%, #ff5d15 100%);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* Hide preloader when loaded */
#loading.loaded {
    opacity: 0;
    visibility: hidden;
}

/* Auto-hide after 3 seconds maximum */
#loading.timeout {
    animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* Preloader Content Container */
.loading-content {
    text-align: center;
    color: white;
    max-width: 300px;
    padding: 20px;
}

/* YITP Logo */
.loading-logo {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
    filter: brightness(0) invert(1); /* Make logo white */
    animation: logoFloat 2s ease-in-out infinite;
}

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

/* Loading Text */
.loading-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: 1px;
    animation: textPulse 1.5s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Modern Spinner */
.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto;
    position: relative;
}

.spinner-ring {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffffff 0%, #ff5d15 100%);
    border-radius: 2px;
    animation: progressFill 2.5s ease-out forwards;
}

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

/* Loading Dots */
.loading-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
}

.dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    margin: 0 3px;
    animation: dotBounce 1.4s ease-in-out infinite both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
.dot:nth-child(3) { animation-delay: 0s; }

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .loading-content {
        max-width: 250px;
        padding: 15px;
    }
    
    .loading-logo {
        width: 100px;
        margin-bottom: 15px;
    }
    
    .loading-text {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .loading-progress {
        width: 150px;
    }
}

@media (max-width: 480px) {
    .loading-content {
        max-width: 200px;
        padding: 10px;
    }
    
    .loading-logo {
        width: 80px;
        margin-bottom: 10px;
    }
    
    .loading-text {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .loading-progress {
        width: 120px;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
    
    .spinner-ring {
        width: 40px;
        height: 40px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    #loading,
    .loading-logo,
    .loading-text,
    .spinner-ring,
    .progress-fill,
    .dot {
        animation: none;
    }
    
    .loading-progress {
        display: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    #loading {
        background: #000000;
    }
    
    .loading-text,
    .spinner-ring,
    .dot {
        color: #ffffff;
        border-color: #ffffff;
        background: #ffffff;
    }
}

/* Print styles */
@media print {
    #loading {
        display: none !important;
    }
}

/* Legacy browser fallback */
.no-css-animations #loading {
    background: #1a2e53;
}

.no-css-animations .loading-logo,
.no-css-animations .loading-text,
.no-css-animations .spinner-ring,
.no-css-animations .progress-fill,
.no-css-animations .dot {
    animation: none;
}

/* Performance optimizations */
#loading * {
    will-change: auto;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* GPU acceleration for smooth animations */
.loading-logo,
.spinner-ring,
.progress-fill {
    transform: translateZ(0);
}

/* YITP Navbar Fixes */
/* Ensure sidebar is properly hidden by default */
.sidebar__area {
    right: -340px !important;
    transition: right 0.3s ease !important;
}

.sidebar__area.sidebar-opened {
    right: 0px !important;
}

/* Ensure proper responsive behavior for auth sections */
@media (min-width: 576px) {
    .mobile__auth {
        display: none !important;
    }
}

/* Ensure desktop auth is hidden on mobile */
@media (max-width: 575px) {
    .header__auth.d-none.d-sm-block {
        display: none !important;
    }
}

/* Bootstrap Dropdown Fixes */
.dropdown-menu.user__dropdown {
    position: absolute !important;
    top: 100% !important;
    left: auto !important;
    right: 0 !important;
    z-index: 1000 !important;
    min-width: 250px !important;
    margin-top: 0.5rem !important;
}

/* Prevent dropdown duplication */
.dropdown-menu.user__dropdown.show {
    display: block !important;
}

.dropdown-menu.user__dropdown:not(.show) {
    display: none !important;
}

/* Ensure proper dropdown positioning */
.user__info.dropdown {
    position: relative !important;
}

/* Mobile Navigation Toggle Enhancements */
.sidebar-toggle-btn {
    cursor: pointer !important;
    padding: 8px !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 93, 21, 0.1) !important;
}

.sidebar-toggle-btn .line {
    display: block !important;
    width: 20px !important;
    height: 2px !important;
    background: #1a2e53 !important;
    margin: 4px 0 !important;
    transition: all 0.3s ease !important;
}

/* Ensure sidebar animation works smoothly */
.sidebar__area {
    transition: right 0.3s cubic-bezier(0.785, 0.135, 0.15, 0.86) !important;
}

.body-overlay {
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
}

.body-overlay.opened {
    opacity: 1 !important;
    visibility: visible !important;
}
