/**
 * AUTOCORE360 Admin Panel - Loading
 * Spinners, skeleton loaders
 */

/* ============ LOADING / SPINNER ============ */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    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;
    gap: 1rem;
    z-index: 3000;
    backdrop-filter: blur(4px);
}

[data-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.9);
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ============ SKELETON LOADING ============ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-hover) 25%,
        var(--surface-active) 50%,
        var(--surface-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

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

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

.skeleton-text:last-child {
    width: 60%;
    margin-bottom: 0;
}

.skeleton-title {
    height: 1.5rem;
    width: 40%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-button {
    height: 36px;
    width: 100px;
    border-radius: var(--radius);
}

.skeleton-card {
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
}

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

.skeleton-table-row > * {
    flex: 1;
}

.skeleton-stat {
    height: 2.5rem;
    width: 80px;
}

/* Skeleton sizes */
.skeleton-sm {
    height: 0.75rem;
}

.skeleton-lg {
    height: 1.5rem;
}

.skeleton-xl {
    height: 2rem;
}

/* Skeleton circle (for avatars, icons) */
.skeleton-circle {
    border-radius: 50%;
}

/* Skeleton image placeholder */
.skeleton-image {
    width: 100%;
    height: 120px;
    border-radius: var(--radius);
}

.skeleton-image.square {
    aspect-ratio: 1;
    height: auto;
}

/* Skeleton inline (for inline values) */
.skeleton-inline {
    display: inline-block;
    height: 1em;
    width: 3ch;
    vertical-align: middle;
    background: linear-gradient(
        90deg,
        var(--surface-hover) 25%,
        var(--surface-active) 50%,
        var(--surface-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* Skeleton paragraph (multiple lines) */
.skeleton-paragraph {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.skeleton-paragraph .skeleton-text {
    margin-bottom: 0;
}

.skeleton-paragraph .skeleton-text:nth-child(1) { width: 100%; }
.skeleton-paragraph .skeleton-text:nth-child(2) { width: 95%; }
.skeleton-paragraph .skeleton-text:nth-child(3) { width: 85%; }
.skeleton-paragraph .skeleton-text:nth-child(4) { width: 70%; }

/* Hide skeleton rows when content loads */
.skeleton-row {
    transition: opacity 0.2s ease;
}

table:not(.loading) .skeleton-row:has(~ tr:not(.skeleton-row)) {
    display: none;
}

/* Content loading placeholder */
.content-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 1rem;
}

.content-loading .spinner {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
    color: var(--primary);
}

/* Page skeleton (full page loading state) */
.page-skeleton {
    padding: 1.5rem;
}

.page-skeleton-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.page-skeleton-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-skeleton-stat {
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-skeleton-table {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.page-skeleton-table-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-skeleton-table-body {
    padding: 0;
}
