/* =========================================================
   SKELETON LOADING SCREENS — PERCEIVED SPEED
   ========================================================= */

/* =========================================================
   SKELETON CARD
   ========================================================= */

.skeleton-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    padding: var(--panel-pad);
    animation: shimmer 1.5s infinite;
}

.skeleton-card-header {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(90deg, 
        var(--panel) 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        var(--panel) 100%);
    border-radius: 50%;
    flex-shrink: 0;
    animation: shimmer 1.5s infinite;
}

.skeleton-title {
    flex: 1;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, 
        var(--panel) 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        var(--panel) 100%);
    border-radius: 4px;
    margin-bottom: 8px;
    animation: shimmer 1.5s infinite;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-line-full {
    height: 14px;
    margin-bottom: 12px;
}

.skeleton-line-short {
    height: 12px;
    width: 60%;
    margin-bottom: 8px;
}

.skeleton-line-medium {
    height: 12px;
    width: 80%;
    margin-bottom: 8px;
}

/* =========================================================
   SKELETON VARIANTS
   ========================================================= */

/* Text skeleton (3 lines) */
.skeleton-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-text .skeleton-line {
    height: 14px;
}

.skeleton-text .skeleton-line:last-child {
    width: 70%;
}

/* Image skeleton */
.skeleton-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(90deg, 
        var(--panel) 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        var(--panel) 100%);
    border-radius: var(--radius-sm);
    animation: shimmer 1.5s infinite;
}

/* Button skeleton */
.skeleton-button {
    height: 40px;
    width: 100px;
    background: linear-gradient(90deg, 
        var(--panel) 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        var(--panel) 100%);
    border-radius: var(--radius-xs);
    animation: shimmer 1.5s infinite;
}

/* Input field skeleton */
.skeleton-input {
    height: 40px;
    width: 100%;
    background: linear-gradient(90deg, 
        var(--panel) 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        var(--panel) 100%);
    border-radius: var(--radius-xs);
    animation: shimmer 1.5s infinite;
    margin-bottom: 12px;
}

/* =========================================================
   SKELETON GRID
   ========================================================= */

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--gap);
}

.skeleton-item {
    animation: slideUp 0.3s var(--ease) backwards;
}

.skeleton-item:nth-child(1) {
    animation-delay: 0ms;
}

.skeleton-item:nth-child(2) {
    animation-delay: 50ms;
}

.skeleton-item:nth-child(3) {
    animation-delay: 100ms;
}

.skeleton-item:nth-child(n+4) {
    animation-delay: 150ms;
}

/* =========================================================
   SKELETON LIST
   ========================================================= */

.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-list-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-xs);
    animation: slideUp 0.3s var(--ease) backwards;
}

.skeleton-list-item:nth-child(1) {
    animation-delay: 0ms;
}

.skeleton-list-item:nth-child(2) {
    animation-delay: 50ms;
}

.skeleton-list-item:nth-child(3) {
    animation-delay: 100ms;
}

.skeleton-list-item:nth-child(n+4) {
    animation-delay: 150ms;
}

/* =========================================================
   SKELETON TABLE
   ========================================================= */

.skeleton-table {
    width: 100%;
    border-collapse: collapse;
}

.skeleton-table thead {
    background: var(--primary-soft);
}

.skeleton-table th {
    padding: 12px;
    text-align: left;
}

.skeleton-table td {
    padding: 12px;
    border-bottom: 1px solid var(--panel-border);
}

.skeleton-table-cell {
    height: 16px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        transparent 100%);
    border-radius: 4px;
    animation: shimmer 1.5s infinite;
}

/* =========================================================
   SKELETON TOOLBAR
   ========================================================= */

.skeleton-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.skeleton-search {
    flex: 1;
    height: 40px;
    background: linear-gradient(90deg, 
        var(--panel) 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        var(--panel) 100%);
    border-radius: var(--radius-xs);
    animation: shimmer 1.5s infinite;
}

.skeleton-filter-btn {
    width: 100px;
    height: 40px;
    background: linear-gradient(90deg, 
        var(--panel) 0%, 
        rgba(200, 215, 255, 0.1) 50%, 
        var(--panel) 100%);
    border-radius: var(--radius-xs);
    animation: shimmer 1.5s infinite;
}

/* =========================================================
   SHIMMER ANIMATION
   ========================================================= */

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* =========================================================
   PULSE ANIMATION (Alternative)
   ========================================================= */

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

.skeleton-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* =========================================================
   DARK MODE
   ========================================================= */

[data-theme="dark"] .skeleton-card,
[data-theme="dark"] .skeleton-line,
[data-theme="dark"] .skeleton-image,
[data-theme="dark"] .skeleton-button,
[data-theme="dark"] .skeleton-input {
    background: linear-gradient(90deg, 
        rgba(20, 25, 40, 0.6) 0%, 
        rgba(100, 150, 255, 0.08) 50%, 
        rgba(20, 25, 40, 0.6) 100%);
}

[data-theme="dark"] .skeleton-card {
    background: linear-gradient(90deg, 
        rgba(30, 40, 65, 0.5) 0%, 
        rgba(100, 150, 255, 0.1) 50%, 
        rgba(30, 40, 65, 0.5) 100%);
}

/* =========================================================
   PLACEHOLDER CONTENT
   ========================================================= */

.skeleton-placeholder {
    background: var(--primary-soft);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    color: var(--primary);
    font-size: 14px;
}

.skeleton-placeholder-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

/* =========================================================
   ACCESSIBILITY
   ========================================================= */

.skeleton-card[aria-busy="true"]::after {
    content: " Loading...";
    position: absolute;
    left: -9999px;
    font-size: 0;
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .skeleton-card,
    .skeleton-line,
    .skeleton-image,
    .skeleton-button,
    .skeleton-input,
    .skeleton-item,
    .skeleton-list-item {
        animation: none;
        background: var(--panel);
    }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {
    .skeleton-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .skeleton-toolbar {
        flex-wrap: wrap;
    }
    
    .skeleton-search {
        flex-basis: 100%;
    }
}
