/* Reusable Loading Spinner Styles */

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

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

/* Inline Spinner (for buttons) */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

.spinner-sm {
    width: 0.875rem;
    height: 0.875rem;
    border-width: 2px;
}

.spinner-lg {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 3px;
}

.spinner-xl {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
}

/* Spinner color variants */
.spinner-primary {
    border-color: hsl(var(--primary) / 0.3);
    border-top-color: hsl(var(--primary));
}

.spinner-white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

.spinner-dark {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: rgba(0, 0, 0, 0.7);
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    cursor: not-allowed;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-loading.btn-outline::after,
.btn-loading.btn-secondary::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: currentColor;
}

/* Overlay Spinner (covers entire area) */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
}

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

.loading-overlay .spinner {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 3px;
    border-color: hsl(var(--primary) / 0.3);
    border-top-color: hsl(var(--primary));
}

.loading-overlay-dark .spinner {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

.loading-overlay-text {
    margin-top: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.loading-overlay-dark .loading-overlay-text {
    color: white;
}

/* Full Page Loading Overlay */
.loading-overlay-fullpage {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay-fullpage .spinner {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
}

/* Modal Loading State */
.modal-loading {
    pointer-events: none;
}

.modal-loading .modal-content {
    position: relative;
}

.modal-loading .modal-body {
    opacity: 0.5;
}

/* Progress Dots */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.loading-dots span {
    width: 0.5rem;
    height: 0.5rem;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Skeleton Loader (for content loading) */
.skeleton {
    background: linear-gradient(
        90deg,
        hsl(var(--muted) / 0.4) 25%,
        hsl(var(--muted) / 0.2) 50%,
        hsl(var(--muted) / 0.4) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

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

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text-sm {
    height: 0.75rem;
}

.skeleton-text-lg {
    height: 1.25rem;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-image {
    width: 100%;
    height: 200px;
}

/* Upload Progress */
.upload-progress {
    margin-top: 1rem;
}

.upload-progress-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: hsl(var(--muted) / 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.upload-progress-item .spinner {
    flex-shrink: 0;
}

.upload-progress-info {
    flex: 1;
    min-width: 0;
}

.upload-progress-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-progress-status {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.25rem;
}

/* Disabled state for loading elements */
[disabled],
.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Helper classes */
.loading-hidden {
    display: none !important;
}

.loading-visible {
    display: flex !important;
}
