/* Loading, Error, and Empty State Components */

/* =============================================================================
   Loading State
   ============================================================================= */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.loading-spinner.sm {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

.loading-spinner.lg {
    width: 56px;
    height: 56px;
    border-width: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-message {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.loading-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Inline Loading (for buttons, small areas) */
.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.loading-inline .loading-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    margin-bottom: 0;
}

/* =============================================================================
   Error State
   ============================================================================= */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.error-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.error-icon svg {
    width: 32px;
    height: 32px;
    color: var(--danger);
}

.error-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.error-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    max-width: 400px;
    line-height: 1.5;
}

.error-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.error-actions .btn {
    min-width: 100px;
}

/* Error Details (collapsible) */
.error-details {
    margin-top: 16px;
    text-align: left;
    width: 100%;
    max-width: 500px;
}

.error-details-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 auto;
    padding: 4px 8px;
}

.error-details-toggle:hover {
    color: var(--text-secondary);
}

.error-details-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s;
}

.error-details-toggle.expanded svg {
    transform: rotate(180deg);
}

.error-details-content {
    display: none;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

.error-details-content.show {
    display: block;
}

/* =============================================================================
   Empty State
   ============================================================================= */

.empty-state-component {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    font-size: 2rem;
}

.empty-icon svg {
    width: 40px;
    height: 40px;
    color: var(--text-muted);
}

.empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    max-width: 400px;
    line-height: 1.5;
}

.empty-action {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* =============================================================================
   Skeleton Loading
   ============================================================================= */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 25%,
        var(--border-color) 50%,
        var(--bg-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

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

.skeleton-text.md {
    width: 80%;
}

.skeleton-text.lg {
    width: 100%;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.skeleton-table-row {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-table-row .skeleton {
    flex: 1;
    height: 20px;
}

/* =============================================================================
   State Variants
   ============================================================================= */

/* Compact version */
.loading-state.compact,
.error-state.compact,
.empty-state-component.compact {
    padding: 24px 16px;
}

.compact .loading-spinner {
    width: 32px;
    height: 32px;
}

.compact .error-icon,
.compact .empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.compact .error-icon svg,
.compact .empty-icon svg {
    width: 24px;
    height: 24px;
}

.compact .error-title,
.compact .empty-title {
    font-size: 0.9rem;
}

.compact .error-message,
.compact .empty-message {
    font-size: 0.8rem;
    margin-bottom: 16px;
}

/* Card variant (with background) */
.loading-state.card,
.error-state.card,
.empty-state-component.card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* Full height variant */
.loading-state.full,
.error-state.full,
.empty-state-component.full {
    min-height: 300px;
}
