/**
 * SVG Amelia - AJAX Loading States
 *
 * Provides visual feedback for all async operations
 *
 * @package SVG_Amelia
 * @since 8.3.0
 */

/* ========================================
   Spinner Animations
   ======================================== */

@keyframes svg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes svg-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ========================================
   Loading Spinner
   ======================================== */

.svg-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: svg-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

.svg-spinner-small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.svg-spinner-large {
    width: 32px;
    height: 32px;
    border-width: 4px;
}

/* ========================================
   Loading Button States
   ======================================== */

.button.svg-loading,
button.svg-loading,
input[type="submit"].svg-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    opacity: 0.6;
}

.button.svg-loading::after,
button.svg-loading::after,
input[type="submit"].svg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: svg-spin 0.6s linear infinite;
}

/* ========================================
   Loading Overlay
   ======================================== */

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

.svg-loading-overlay-dark {
    background: rgba(0, 0, 0, 0.7);
}

.svg-loading-overlay .svg-spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ========================================
   Loading Text with Dots
   ======================================== */

.svg-loading-text::after {
    content: '...';
    animation: svg-dots 1.5s steps(1) infinite;
}

/* ========================================
   Skeleton Screens
   ======================================== */

.svg-skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: svg-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

.svg-skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 100%;
}

.svg-skeleton-text-short {
    width: 60%;
}

.svg-skeleton-heading {
    height: 24px;
    width: 40%;
    margin-bottom: 16px;
}

.svg-skeleton-box {
    height: 200px;
    width: 100%;
    margin-bottom: 16px;
}

/* ========================================
   Progress Bars
   ======================================== */

.svg-progress-bar {
    width: 100%;
    height: 4px;
    background: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
    margin: 16px 0;
}

.svg-progress-bar-fill {
    height: 100%;
    background: #2271b1;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.svg-progress-bar-animated .svg-progress-bar-fill {
    animation: svg-progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes svg-progress-indeterminate {
    0% {
        width: 30%;
        margin-left: -30%;
    }
    50% {
        width: 30%;
        margin-left: 50%;
    }
    100% {
        width: 30%;
        margin-left: 100%;
    }
}

/* ========================================
   Bulk Operation Progress
   ======================================== */

.svg-bulk-progress {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 16px;
    margin: 16px 0;
}

.svg-bulk-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.svg-bulk-progress-title {
    font-weight: 600;
    font-size: 14px;
}

.svg-bulk-progress-count {
    color: #646970;
    font-size: 13px;
}

.svg-bulk-progress-bar {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.svg-bulk-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #2271b1 0%, #72aee6 100%);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.svg-bulk-progress-status {
    font-size: 12px;
    color: #646970;
}

/* ========================================
   Table Loading States
   ======================================== */

.svg-table-loading {
    position: relative;
    pointer-events: none;
}

.svg-table-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.svg-table-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: svg-spin 0.8s linear infinite;
    z-index: 11;
}

/* ========================================
   Disabled States
   ======================================== */

.svg-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* ========================================
   Cache Refresh Button
   ======================================== */

.svg-cache-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
    color: #2c3338;
    cursor: pointer;
    transition: all 0.2s;
}

.svg-cache-refresh-btn:hover {
    background: #fff;
    border-color: #2271b1;
    color: #2271b1;
}

.svg-cache-refresh-btn.svg-loading {
    opacity: 0.6;
    pointer-events: none;
}

.svg-cache-refresh-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.svg-cache-refresh-btn.svg-loading .dashicons {
    animation: svg-spin 1s linear infinite;
}

/* ========================================
   Success/Error States
   ======================================== */

.svg-success-flash {
    animation: svg-success-pulse 0.6s ease;
}

@keyframes svg-success-pulse {
    0%, 100% { background-color: transparent; }
    50% { background-color: #d7f7d7; }
}

.svg-error-flash {
    animation: svg-error-pulse 0.6s ease;
}

@keyframes svg-error-pulse {
    0%, 100% { background-color: transparent; }
    50% { background-color: #ffd7d7; }
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media screen and (max-width: 782px) {
    .svg-spinner {
        width: 16px;
        height: 16px;
        border-width: 2px;
    }

    .svg-cache-refresh-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}
