/**
 * RADEXEL Design System - Skeleton Loading Component
 *
 * 12 skeleton types for every loading state in the app.
 * Uses a gradient shimmer animation.
 * All skeletons automatically adapt to dark mode via CSS variables.
 */

/* ==========================================================================
   Base Skeleton
   ========================================================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-shine) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 400% 100%;
  animation: skeletonPulse 1.8s var(--ease-default) infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--skeleton-base);
  }
}


/* ==========================================================================
   1. Text Skeleton
   ========================================================================== */

.skeleton-text {
  height: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

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

.skeleton-text--sm {
  height: 10px;
}

.skeleton-text--lg {
  height: 20px;
}

.skeleton-text--title {
  height: 24px;
  width: 50%;
  margin-bottom: var(--space-3);
}


/* ==========================================================================
   2. Avatar Skeleton
   ========================================================================== */

.skeleton-avatar {
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.skeleton-avatar--sm {
  width: 28px;
  height: 28px;
}

.skeleton-avatar--md {
  width: 36px;
  height: 36px;
}

.skeleton-avatar--lg {
  width: 48px;
  height: 48px;
}

.skeleton-avatar--xl {
  width: 64px;
  height: 64px;
}


/* ==========================================================================
   3. Card Skeleton
   ========================================================================== */

.skeleton-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  animation: none; /* Card container itself doesn't shimmer */
}

.skeleton-card .skeleton-text,
.skeleton-card .skeleton-avatar {
  /* Child elements shimmer normally */
}

.skeleton-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.skeleton-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-card__footer {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-light);
}


/* ==========================================================================
   4. Message Skeleton (Chat Bubble)
   ========================================================================== */

.skeleton-message {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
}

.skeleton-message__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.skeleton-message__body {
  flex: 1;
  max-width: 70%;
}

.skeleton-message__line {
  height: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.skeleton-message__line:nth-child(1) {
  width: 80%;
}

.skeleton-message__line:nth-child(2) {
  width: 60%;
}

.skeleton-message__line:nth-child(3) {
  width: 40%;
}

/* User message (right-aligned) */
.skeleton-message--user {
  flex-direction: row-reverse;
}

.skeleton-message--user .skeleton-message__body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}


/* ==========================================================================
   5. Table Row Skeleton
   ========================================================================== */

.skeleton-table-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.skeleton-table-row__cell {
  height: 14px;
  border-radius: var(--radius-sm);
}

.skeleton-table-row__cell:nth-child(1) {
  width: 30%;
}

.skeleton-table-row__cell:nth-child(2) {
  width: 25%;
}

.skeleton-table-row__cell:nth-child(3) {
  width: 20%;
}

.skeleton-table-row__cell:nth-child(4) {
  width: 15%;
}

.skeleton-table-row__cell:nth-child(5) {
  width: 10%;
}


/* ==========================================================================
   6. Dashboard Skeleton (Full Page)
   ========================================================================== */

.skeleton-dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.skeleton-dashboard__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.skeleton-dashboard__stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  animation: none;
}

.skeleton-dashboard__stat-value {
  height: 28px;
  width: 50%;
  margin-bottom: var(--space-2);
}

.skeleton-dashboard__stat-label {
  height: 12px;
  width: 70%;
}

.skeleton-dashboard__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-6);
}


/* ==========================================================================
   7. Sidebar Item Skeleton
   ========================================================================== */

.skeleton-sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
}

.skeleton-sidebar-item__icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.skeleton-sidebar-item__text {
  height: 14px;
  flex: 1;
  border-radius: var(--radius-sm);
}

.skeleton-sidebar-item:nth-child(odd) .skeleton-sidebar-item__text {
  width: 75%;
}

.skeleton-sidebar-item:nth-child(even) .skeleton-sidebar-item__text {
  width: 60%;
}


/* ==========================================================================
   8. Button Skeleton
   ========================================================================== */

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

.skeleton-button--sm {
  height: 28px;
  width: 80px;
  border-radius: var(--radius-sm);
}

.skeleton-button--lg {
  height: 44px;
  width: 140px;
  border-radius: var(--radius-md);
}

.skeleton-button--block {
  width: 100%;
}


/* ==========================================================================
   9. Input Skeleton
   ========================================================================== */

.skeleton-input {
  height: 38px;
  width: 100%;
  border-radius: var(--radius-md);
}

.skeleton-input--label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-input--label::before {
  content: '';
  display: block;
  width: 80px;
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-shine) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 400% 100%;
  animation: skeletonPulse 1.8s var(--ease-default) infinite;
}


/* ==========================================================================
   10. Badge Skeleton
   ========================================================================== */

.skeleton-badge {
  height: 22px;
  width: 64px;
  border-radius: var(--radius-full);
}

.skeleton-badge--sm {
  height: 18px;
  width: 48px;
}


/* ==========================================================================
   11. Stat Card Skeleton
   ========================================================================== */

.skeleton-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  animation: none;
}

.skeleton-stat-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.skeleton-stat-card__value {
  height: 32px;
  width: 60%;
  margin-bottom: var(--space-2);
}

.skeleton-stat-card__label {
  height: 12px;
  width: 80%;
}

.skeleton-stat-card__change {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.skeleton-stat-card__change-value {
  height: 14px;
  width: 40px;
}

.skeleton-stat-card__change-label {
  height: 12px;
  width: 60px;
}


/* ==========================================================================
   12. Image Skeleton
   ========================================================================== */

.skeleton-image {
  border-radius: var(--radius-md);
  aspect-ratio: 16 / 9;
  width: 100%;
}

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

.skeleton-image--portrait {
  aspect-ratio: 3 / 4;
}

.skeleton-image--banner {
  aspect-ratio: 21 / 9;
}


/* ==========================================================================
   Skeleton Group Container
   ========================================================================== */

.skeleton-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Stagger animation delay for visual flow */
.skeleton-group > *:nth-child(1) { animation-delay: 0ms; }
.skeleton-group > *:nth-child(2) { animation-delay: 100ms; }
.skeleton-group > *:nth-child(3) { animation-delay: 200ms; }
.skeleton-group > *:nth-child(4) { animation-delay: 300ms; }
.skeleton-group > *:nth-child(5) { animation-delay: 400ms; }
