/* =========================================
   8. Loading States & Error Handling
   ========================================= */

/* Loading Spinner */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner-inline {
    display: inline-block;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-spinner-medium {
    width: 24px;
    height: 24px;
}

.loading-spinner-large {
    width: 48px;
    height: 48px;
    border-width: 5px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s;
}

.loading-overlay.show {
    opacity: 1;
}

.loading-spinner-container {
    text-align: center;
}

.loading-message {
    margin-top: 1rem;
    color: var(--text-sub);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
}

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

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: calc(80px + var(--sab) + 1rem);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    max-width: 90%;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-success {
    background: #10b981;
}

.toast-error {
    background: #ef4444;
}

.toast-warning {
    background: #f59e0b;
}

.toast-info {
    background: #3b82f6;
}

/* Skeleton Loaders */
@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }

    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.skeleton-image {
    width: 100%;
    height: 150px;
    background: linear-gradient(90deg, #f0f0f0 0px, #f8f8f8 40px, #f0f0f0 80px);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 0px, #f8f8f8 40px, #f0f0f0 80px);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-sub);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.empty-state-message {
    font-size: 0.9rem;
    line-height: 1.5;
}