/**
 * Authentication Loading States CSS for Missav Theme
 * 
 * Provides smooth loading transitions and skeleton loaders
 * to prevent flash of incorrect authentication state
 */

/* ===== AUTHENTICATION LOADING STATES ===== */

/* Hide menu items during loading */
.auth-loading .auth-logged-out,
.auth-loading .auth-logged-in {
    display: none !important;
}

/* Show loading indicator during loading */
.auth-loading .auth-loading-indicator {
    display: block;
}

/* Hide loading indicator when loaded */
.auth-loaded .auth-loading-indicator {
    display: none !important;
}

/* ===== SKELETON LOADERS ===== */

/* Base skeleton loader */
.skeleton-loader {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.1) 25%, 
        rgba(255, 255, 255, 0.2) 50%, 
        rgba(255, 255, 255, 0.1) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

/* Skeleton loading animation */
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton loader variants */
.skeleton-loader.rounded-full {
    border-radius: 50%;
}

.skeleton-loader.rounded-sm {
    border-radius: 2px;
}

.skeleton-loader.rounded-md {
    border-radius: 6px;
}

.skeleton-loader.rounded-lg {
    border-radius: 8px;
}

/* ===== RESPONSIVE SKELETON SIZES ===== */

/* Small skeleton (for avatars) */
.skeleton-loader.h-5.w-5 {
    width: 1.25rem;
    height: 1.25rem;
}

/* Medium skeleton (for buttons) */
.skeleton-loader.h-8 {
    height: 2rem;
    width: 4rem;
}

/* Large skeleton (for menu items) */
.skeleton-loader.h-10 {
    height: 2.5rem;
    width: 6rem;
}

/* ===== SMOOTH TRANSITIONS ===== */

/* Fade in animation for menu items */
.auth-logged-in,
.auth-logged-out {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.auth-loaded .auth-logged-in,
.auth-loaded .auth-logged-out {
    opacity: 1;
}

/* Smooth hover transitions */
.auth-logged-in a,
.auth-logged-out a {
    transition: color 0.2s ease-in-out;
}

/* ===== LOADING INDICATOR STYLES ===== */

/* Pulsing effect for loading indicators */
.auth-loading-indicator {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ===== MOBILE SPECIFIC STYLES ===== */

/* Mobile menu loading states */
@media (max-width: 768px) {
    #user-menu-mobile .skeleton-loader {
        background: linear-gradient(90deg, 
            rgba(245, 158, 11, 0.1) 25%, 
            rgba(245, 158, 11, 0.2) 50%, 
            rgba(245, 158, 11, 0.1) 75%
        );
        background-size: 200% 100%;
    }
    
    /* Adjust mobile skeleton sizes */
    #user-menu-mobile .skeleton-loader.h-5.w-5 {
        width: 1.25rem;
        height: 1.25rem;
    }
}

/* ===== DESKTOP SPECIFIC STYLES ===== */

/* Desktop menu loading states */
@media (min-width: 769px) {
    #user-menu .skeleton-loader {
        background: linear-gradient(90deg, 
            rgba(245, 158, 11, 0.1) 25%, 
            rgba(245, 158, 11, 0.2) 50%, 
            rgba(245, 158, 11, 0.1) 75%
        );
        background-size: 200% 100%;
    }
}

/* ===== ERROR STATES ===== */

/* Error state styling */
.auth-error {
    color: #ef4444;
    font-size: 0.875rem;
    opacity: 0.8;
}

.auth-error::before {
    content: "⚠ ";
    margin-right: 0.25rem;
}

/* ===== ACCESSIBILITY ===== */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .skeleton-loader,
    .auth-loading-indicator {
        animation: none;
    }
    
    .auth-logged-in,
    .auth-logged-out {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .skeleton-loader {
        background: linear-gradient(90deg, 
            rgba(255, 255, 255, 0.3) 25%, 
            rgba(255, 255, 255, 0.6) 50%, 
            rgba(255, 255, 255, 0.3) 75%
        );
    }
}

/* ===== DARK MODE SUPPORT ===== */

/* Dark mode skeleton loaders */
@media (prefers-color-scheme: dark) {
    .skeleton-loader {
        background: linear-gradient(90deg, 
            rgba(255, 255, 255, 0.05) 25%, 
            rgba(255, 255, 255, 0.1) 50%, 
            rgba(255, 255, 255, 0.05) 75%
        );
    }
}

/* ===== FOCUS STATES ===== */

/* Focus indicators for accessibility */
.auth-logged-in a:focus,
.auth-logged-out a:focus {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===== LOADING PERFORMANCE OPTIMIZATIONS ===== */

/* GPU acceleration for animations */
.skeleton-loader,
.auth-loading-indicator {
    transform: translateZ(0);
    will-change: background-position, opacity;
}

/* Optimize repaints */
.auth-logged-in,
.auth-logged-out {
    transform: translateZ(0);
    will-change: opacity;
}

/* ===== FALLBACK STYLES ===== */

/* Fallback for browsers without CSS animation support */
.no-cssanimations .skeleton-loader {
    background: rgba(255, 255, 255, 0.1);
}

.no-cssanimations .auth-loading-indicator {
    opacity: 0.5;
}

/* ===== PRINT STYLES ===== */

/* Hide loading states in print */
@media print {
    .auth-loading-indicator,
    .skeleton-loader {
        display: none !important;
    }
    
    .auth-logged-in,
    .auth-logged-out {
        opacity: 1 !important;
        display: block !important;
    }
}
