/**
 * Loading States & Spinners - Bricard Services 2025
 *
 * Loading indicators, spinners, skeletons for better UX
 *
 * @package GeneratePress Child
 * @since 1.0.0
 */

/* ============================================
   LOADING SPINNER
   ============================================ */

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-primary-600);
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loading-spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

.loading-spinner-white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

@keyframes spinner-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.loading-overlay-text {
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    color: var(--color-text);
}

/* ============================================
   INLINE LOADING STATE
   ============================================ */

.loading-inline {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    color: var(--color-text-light);
}

.loading-inline .loading-spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

/* ============================================
   BUTTON LOADING STATE
   ============================================ */

.btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
}

.btn.btn-outline.is-loading::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-primary-600);
}

/* ============================================
   SKELETON LOADING (Placeholder)
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: var(--radius-sm);
}

.skeleton-title {
    height: 2em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-paragraph {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-paragraph:last-child {
    width: 80%;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-image {
    width: 100%;
    height: 200px;
}

.skeleton-card {
    padding: var(--space-6);
    background-color: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   LAZY LOADING FADE-IN
   ============================================ */

.lazy-load {
    opacity: 0;
    transition: opacity 0.3s var(--ease-out);
}

.lazy-load.is-loaded {
    opacity: 1;
}

.lazy-load-image {
    background-color: #f5f5f5;
    min-height: 200px;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar {
    width: 100%;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--color-primary-600);
    border-radius: var(--radius-full);
    transition: width 0.3s var(--ease-out);
}

.progress-bar-animated .progress-bar-fill {
    background: linear-gradient(
        90deg,
        var(--color-primary-600) 0%,
        var(--color-primary-500) 50%,
        var(--color-primary-600) 100%
    );
    background-size: 200% 100%;
    animation: progress-shimmer 1.5s ease-in-out infinite;
}

@keyframes progress-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   LOADING DOTS
   ============================================ */

.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-primary-600);
    border-radius: 50%;
    animation: loading-dot-bounce 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* ============================================
   PULSING EFFECT
   ============================================ */

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* ============================================
   CONTENT PLACEHOLDER
   ============================================ */

.content-placeholder {
    padding: var(--space-8);
    text-align: center;
}

.content-placeholder-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    color: var(--color-text-lighter);
}

.content-placeholder-text {
    font-size: var(--fs-base);
    color: var(--color-text-light);
}

/* ============================================
   INFINITE SCROLL LOADING
   ============================================ */

.infinite-scroll-loading {
    padding: var(--space-8);
    display: flex;
    justify-content: center;
    align-items: center;
}

.infinite-scroll-end {
    padding: var(--space-8);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--color-text-light);
}

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

@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .skeleton,
    .loading-dots,
    .pulse,
    .progress-bar-animated .progress-bar-fill {
        animation: none;
    }

    .lazy-load {
        transition: none;
    }
}

/* Hide loading states from screen readers when not active */
.loading-overlay[aria-hidden="true"],
.loading-spinner[aria-hidden="true"] {
    display: none;
}
