/* Standardized Loading Animations for PosterPro */

/* CSS Variables for Loading Animations */
:root {
    --loading-primary: #187fe8;        /* Primary blue */
    --loading-secondary: #667eea;      /* Purple-blue */
    --loading-light: rgba(24, 127, 232, 0.2);  /* Light blue for spinner background */
    --loading-size-sm: 20px;
    --loading-size-md: 40px;
    --loading-size-lg: 60px;
}

/* Brand gradient for file animation */
:root {
    --file-gradient-start: #187fe8;     /* Primary blue */
    --file-gradient-end: #667eea;       /* Purple-blue */
}

/* ============================================
   FILE/DOCUMENT LOADING ANIMATION (PRIMARY)
   ============================================ */

/* File/document animation - main loading animation for website */
.loader-con {
    position: relative;
    width: 100%;
    height: 100px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-con .pfile {
    position: absolute;
    bottom: 25px;
    width: 40px;
    height: 50px;
    background: linear-gradient(90deg, var(--file-gradient-start), var(--file-gradient-end));
    border-radius: 4px;
    transform-origin: center;
    animation: flyRight 3s ease-in-out infinite;
    opacity: 0;
}

.loader-con .pfile::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 4px;
    background-color: #ffffff;
    border-radius: 2px;
}

.loader-con .pfile::after {
    content: "";
    position: absolute;
    top: 13px;
    left: 6px;
    width: 18px;
    height: 4px;
    background-color: #ffffff;
    border-radius: 2px;
}

@keyframes flyRight {
    0% {
        left: -10%;
        transform: scale(0);
        opacity: 0;
    }
    50% {
        left: 45%;
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        left: 100%;
        transform: scale(0);
        opacity: 0;
    }
}

.loader-con .pfile {
    animation-delay: calc(var(--i) * 0.6s);
}

/* Compact version for smaller spaces */
.loader-con-compact {
    height: 60px;
}

.loader-con-compact .pfile {
    width: 30px;
    height: 38px;
    bottom: 15px;
}

.loader-con-compact .pfile::before {
    top: 5px;
    left: 5px;
    width: 20px;
    height: 3px;
}

.loader-con-compact .pfile::after {
    top: 10px;
    left: 5px;
    width: 14px;
    height: 3px;
}

/* ============================================
   GENERAL WEBSITE LOADING SPINNER (FALLBACK)
   ============================================ */

/* Standard circular spinner for general website use */
.loading-spinner {
    display: inline-block;
    width: var(--loading-size-md);
    height: var(--loading-size-md);
    border: 3px solid var(--loading-light);
    border-top-color: var(--loading-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Small variant */
.loading-spinner-sm {
    width: var(--loading-size-sm);
    height: var(--loading-size-sm);
    border-width: 2px;
}

/* Large variant */
.loading-spinner-lg {
    width: var(--loading-size-lg);
    height: var(--loading-size-lg);
    border-width: 4px;
}

/* Branded spinner with gradient and shadow */
.loading-spinner-branded {
    width: var(--loading-size-lg);
    height: var(--loading-size-lg);
    border: 4px solid var(--loading-light);
    border-top-color: var(--loading-primary);
    border-right-color: var(--loading-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 4px 16px rgba(24, 127, 232, 0.2);
}

/* Spin animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   CHAT TYPING INDICATOR
   ============================================ */

/* Typing dots for chat interfaces */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 8px 12px;
    background: #f2f2f2;
    border-radius: 18px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--loading-primary);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Loading state for buttons (uses Font Awesome spinner) */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* For dark buttons */
.btn-loading.btn-dark::after {
    border-color: rgba(0, 0, 0, 0.2);
    border-top-color: currentColor;
}

/* ============================================
   INLINE LOADING TEXT
   ============================================ */

/* Loading text with spinner */
.loading-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--loading-primary);
    font-size: 14px;
}

.loading-text .loading-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* ============================================
   FULL PAGE LOADER
   ============================================ */

/* Full page loading overlay */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.page-loader .loader-con {
    margin-bottom: 1rem;
}

.page-loader-text {
    color: var(--loading-primary);
    font-size: 16px;
    font-weight: 500;
    margin-top: 1rem;
}

/* ============================================
   SAVING OVERLAY (FULL SCREEN)
   ============================================ */

/* Full-screen saving overlay - matches 5-step progress overlay style */
.saving-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ws-overlay-bg, rgba(255, 255, 255, 0.98));
    backdrop-filter: var(--ws-overlay-blur, blur(8px));
    -webkit-backdrop-filter: var(--ws-overlay-blur, blur(8px));
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999; /* Higher than everything else */
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ws-transition-base, 0.3s ease);
}

/* Dark mode support - uses workspace CSS variables */
.saving-overlay {
    background: var(--ws-overlay-bg, rgba(255, 255, 255, 0.98));
}

.saving-content-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Prevent interactions when saving */
body.saving-in-progress * {
    pointer-events: none !important;
    user-select: none !important;
}

body.saving-in-progress .saving-overlay,
body.saving-in-progress .saving-overlay * {
    pointer-events: auto !important;
}

/* ============================================
   REGENERATE WITH AI – LOADING SPINNER
   ============================================ */

/* When Regenerate with AI is in progress: spin the ↻ icon and disable the control */
.ai-regen-label.ai-regen-loading {
    pointer-events: none;
    opacity: 0.85;
}

.ai-regen-label.ai-regen-loading .ai-regen-icon {
    display: inline-block;
    animation: spin 0.9s linear infinite;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Center spinner */
.loading-center {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 2rem;
}

/* Inline spinner */
.loading-inline {
    display: inline-block;
    vertical-align: middle;
    margin: 0 4px;
}

