/* 
 * Consistent Loading Animation System for Framing Templates
 * This file provides standardized loading animations across all framing pages
 */

:root {
    --loader-bg-color: #f8f9fa;
    --loader-spinner-color: #f7a823;
    --loader-text-color: #6c757d;
    --loader-transition-duration: 0.5s;
}

/* Main Page Loader */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--loader-bg-color);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity var(--loader-transition-duration) ease;
}

#page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Main Page Content */
#page-content {
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s, opacity var(--loader-transition-duration) linear;
}

#page-content.visible {
    visibility: visible;
    opacity: 1;
}

/* Standard Spinner */
.spinner, .loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--loader-spinner-color);
    border-radius: 50%;
    animation: spin 1s linear infinite !important;
    display: inline-block;
}

/* Smaller spinner for inline use */
.spinner-sm {
    width: 30px;
    height: 30px;
    border-width: 3px;
}

/* Loading text */
.loader-text {
    margin-top: 1rem;
    color: var(--loader-text-color);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Spin animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Card/Component Loader Overlay */
.card-loader-overlay, .overlay-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
    cursor: wait;
}

.card-loader-overlay.visible, .overlay-loader.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading .btn-text {
    opacity: 0;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Inline Loading Spinner */
.loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--loader-text-color);
    font-size: 0.9rem;
}

.loading-spinner .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

/* Progress Bar Loading */
.progress-loader {
    width: 100%;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-loader-bar {
    height: 100%;
    background-color: var(--loader-spinner-color);
    width: 0%;
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progress-indeterminate 2s infinite linear;
}

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
        width: 100%;
    }
    50% {
        transform: translateX(0%);
        width: 100%;
    }
    100% {
        transform: translateX(100%);
        width: 100%;
    }
}

/* Loading States for Different Components */
.upload-loading {
    position: relative;
}

.upload-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--loader-spinner-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

/* Pulse Loading Animation */
.pulse-loader {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Theme Variations */
.loader-dark {
    --loader-bg-color: #2c2c2c;
    --loader-text-color: #ffffff;
}

.loader-light {
    --loader-bg-color: #ffffff;
    --loader-text-color: #2c2c2c;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .spinner, .loader-spinner {
        width: 40px;
        height: 40px;
        border-width: 4px;
    }
    
    .loader-text {
        font-size: 0.8rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .spinner, .loader-spinner, .btn-loading::after {
        animation: none;
    }
    
    .progress-loader-bar {
        animation: none;
    }
    
    .skeleton {
        animation: none;
        background: #f0f0f0;
    }
}

/* Utility Classes */
.hide-on-load {
    opacity: 0;
    transition: opacity var(--loader-transition-duration) ease;
}

.show-on-load {
    opacity: 1;
}

.no-transition {
    transition: none !important;
}