/* ========================================
   PWA LOADING & SPLASH SCREEN STYLES
   Complete loading system for FoodHub PWA
   ======================================== */

/* ========================================
   1. SPLASH SCREEN (Initial App Load)
   ======================================== */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #E23744 0%, #FC8019 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Logo Container */
.splash-logo {
    width: 180px;
    height: 180px;
    background: white;
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
    animation: splashPulse 2s ease-in-out infinite;
    padding: 20px;
}

.splash-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Ensure proper aspect ratio */
    max-width: 140px;
    max-height: 140px;
}

/* App Name */
.splash-text {
    color: white;
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 20px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

/* Loading Spinner */
.splash-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

/* Tagline */
.splash-tagline {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 500;
    margin-top: 10px;
}

/* Pulse Animation */
@keyframes splashPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    }
}

/* Spin Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .splash-logo {
        width: 140px;
        height: 140px;
        padding: 15px;
    }
    
    .splash-logo img {
        max-width: 110px;
        max-height: 110px;
    }
    
    .splash-text {
        font-size: 28px;
    }
    
    .splash-tagline {
        font-size: 14px;
    }
}

/* ========================================
   2. PAGE PROGRESS BAR (Navigation Loading)
   ======================================== */
#page-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #E23744, #FC8019);
    z-index: 10000;
    transition: width 0.3s ease;
    box-shadow: 0 2px 8px rgba(226, 55, 68, 0.5);
    opacity: 0;
}

#page-progress-bar.active {
    opacity: 1;
}

/* ========================================
   3. PAGE LOADER OVERLAY (Full Page Loading)
   ======================================== */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#page-loader.active {
    display: flex;
    opacity: 1;
}

.page-loader-content {
    text-align: center;
}

/* Loader Spinner */
.page-loader-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #E23744;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.page-loader-text {
    color: #1c1c1c;
    font-size: 18px;
    font-weight: 600;
    margin-top: 15px;
}

/* ========================================
   4. INLINE LOADING STATES (Buttons, Forms)
   ======================================== */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ========================================
   5. SKELETON LOADERS (Content Placeholders)
   ======================================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    height: 300px;
    margin-bottom: 20px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 10px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 15px;
}

/* ========================================
   6. PWA SPLASH SCREEN FIX (iOS & Android)
   ======================================== */

/* iOS Splash Screen Meta Tags (handled in HTML) */
/* These ensure proper logo display on iOS devices */

/* Android Splash Screen (via manifest.json) */
/* Handled through manifest configuration */

/* Fallback for browsers without native splash support */
@media (display-mode: standalone) {
    /* App is running as PWA */
    body {
        /* Prevent flash of unstyled content */
        visibility: visible;
    }
}

/* ========================================
   7. LOADING ANIMATIONS
   ======================================== */

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Slide Up Animation */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.6s ease-out;
}

/* ========================================
   8. PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Prevent layout shift during loading */
.loading-container {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Smooth transitions */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Hardware acceleration */
#splash-screen,
#page-loader,
#page-progress-bar {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ========================================
   9. ACCESSIBILITY
   ======================================== */

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   10. DARK MODE SUPPORT (Optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    #page-loader {
        background: rgba(28, 28, 28, 0.95);
    }
    
    .page-loader-text {
        color: #ffffff;
    }
    
    .page-loader-spinner {
        border-color: #333;
        border-top-color: #E23744;
    }
}
