/* =============================================================================
   IFINSTA UNIFIED LOADER
   =============================================================================
   A full-screen loading overlay that displays while resources are loading.
   Features:
   - Centered logo with subtle pulse animation
   - Smooth fade-out transition when page is ready
   - Theme-aware (works in light/dark mode)
   - Accessible (respects reduced-motion preferences)
   ============================================================================= */

/* Loader Container - Full screen overlay */
.ifinsta-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--ifinsta-z-max, 1000);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--ifinsta-bg-primary, #ffffff);
    transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
}

/* Dark theme support */
[data-theme="dark"] .ifinsta-loader {
    background: var(--ifinsta-bg-primary, #0f172a);
}

/* Logo container */
.ifinsta-loader__logo {
    width: 200px;
    max-width: 60vw;
    height: auto;
    animation: ifinsta-loader-pulse 2s ease-in-out infinite;
}

/* Subtle pulse animation for the logo */
@keyframes ifinsta-loader-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Loading bar underneath the logo */
.ifinsta-loader__bar {
    margin-top: 32px;
    width: 160px;
    max-width: 50vw;
    height: 3px;
    background: var(--ifinsta-border, #e5e7eb);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

[data-theme="dark"] .ifinsta-loader__bar {
    background: var(--ifinsta-border, #334155);
}

/* Animated progress indicator */
.ifinsta-loader__progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30%;
    background: var(--ifinsta-primary, #2563eb);
    border-radius: 3px;
    animation: ifinsta-loader-progress 1.5s ease-in-out infinite;
}

@keyframes ifinsta-loader-progress {
    0% {
        left: -30%;
    }
    100% {
        left: 100%;
    }
}

/* Hidden state - fade out */
.ifinsta-loader--hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .ifinsta-loader__logo {
        animation: none;
    }

    .ifinsta-loader__progress {
        animation: none;
        width: 100%;
        left: 0;
    }

    .ifinsta-loader {
        transition: opacity 0.1s ease-out, visibility 0.1s ease-out;
    }
}

/* Optional: Loading text for accessibility */
.ifinsta-loader__text {
    margin-top: 24px;
    font-size: var(--ifinsta-text-sm);
    font-weight: 500;
    color: var(--ifinsta-txt-secondary, #64748b);
    letter-spacing: 0.5px;
}

[data-theme="dark"] .ifinsta-loader__text {
    color: var(--ifinsta-txt-secondary, #94a3b8);
}

/* Screen reader only class for accessibility */
.ifinsta-loader__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
