/* ======================= LOADING STATES ======================= */

/* Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading Spinner */
.cpt-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #2271b1;
    animation: spin 0.6s linear infinite;
}

.cpt-spinner--large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.cpt-spinner--small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Loading Container */
.cpt-loading {
    position: relative;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpt-loading__spinner {
    text-align: center;
}

.cpt-loading__text {
    margin-top: 12px;
    color: #646970;
    font-size: 14px;
}

/* Skeleton Loader */
@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }
    100% {
        background-position: 468px 0;
    }
}

.cpt-skeleton {
    background: #f6f7f7;
    background-image: linear-gradient(
        to right,
        #f6f7f7 0%,
        #edeef1 20%,
        #f6f7f7 40%,
        #f6f7f7 100%
    );
    background-repeat: no-repeat;
    background-size: 800px 100%;
    animation: shimmer 1.5s linear infinite;
    border-radius: 4px;
}

.cpt-skeleton--text {
    height: 16px;
    margin-bottom: 8px;
}

.cpt-skeleton--heading {
    height: 24px;
    margin-bottom: 12px;
    width: 60%;
}

.cpt-skeleton--card {
    height: 120px;
    margin-bottom: 16px;
}

.cpt-skeleton--table-row {
    height: 48px;
    margin-bottom: 4px;
}

/* Loading Overlay */
.cpt-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: 1000;
    border-radius: 4px;
}

.cpt-overlay--transparent {
    background: rgba(255, 255, 255, 0.7);
}

/* Button Loading State */
.button.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.button.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
}

.button-primary.is-loading::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}

.button-secondary.is-loading::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #2271b1;
}

/* Pulse Animation for Metrics */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.cpt-metric-card.is-loading .cpt-metric-card__value {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Disabled State */
.cpt-disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

/* Mobile Optimizations */
@media (max-width: 782px) {
    .cpt-spinner--large {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
    
    .cpt-loading {
        min-height: 80px;
    }
    
    .cpt-loading__text {
        font-size: 13px;
    }
}