/* ============================================================
   skeleton.css — Skeleton loading / shimmer animations
   FinDom Financial Management App
   ============================================================ */

/* ── Keyframes ──────────────────────────────────────────────── */
@keyframes skeleton-loading {
  0% {
    background-position: -400px 0;
  }
  100% {
    background-position: calc(400px + 100%) 0;
  }
}

/* ── Base Skeleton ──────────────────────────────────────────── */
.skeleton {
  display: block;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-2);
  background-image: linear-gradient(
    90deg,
    var(--color-surface-2) 0px,
    var(--color-surface-3) 80px,
    var(--color-surface-2) 160px
  );
  background-size: 400px 100%;
  background-repeat: no-repeat;
  animation: skeleton-loading 1.4s ease-in-out infinite;
  color: transparent;
  user-select: none;
  pointer-events: none;
}

/* Prevent child content from being visible */
.skeleton * {
  visibility: hidden;
}

/* ── Text variants ──────────────────────────────────────────── */
.skeleton-text {
  display: block;
  height: 1em;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-2);
  background-image: linear-gradient(
    90deg,
    var(--color-surface-2) 0px,
    var(--color-surface-3) 80px,
    var(--color-surface-2) 160px
  );
  background-size: 400px 100%;
  background-repeat: no-repeat;
  animation: skeleton-loading 1.4s ease-in-out infinite;
  color: transparent;
  user-select: none;
}

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

.skeleton-text-lg {
  height: 1.5em;
  border-radius: var(--radius-sm);
}

.skeleton-text-xl {
  height: 2em;
  border-radius: var(--radius-md);
}

/* Common widths for text lines */
.skeleton-w-full  { width: 100%; }
.skeleton-w-3\/4  { width: 75%; }
.skeleton-w-1\/2  { width: 50%; }
.skeleton-w-1\/3  { width: 33%; }
.skeleton-w-1\/4  { width: 25%; }

/* Multiple text lines helper */
.skeleton-paragraph {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

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

/* ── Avatar / Circle ────────────────────────────────────────── */
.skeleton-avatar {
  border-radius: var(--radius-full);
  background-color: var(--color-surface-2);
  background-image: linear-gradient(
    90deg,
    var(--color-surface-2) 0px,
    var(--color-surface-3) 80px,
    var(--color-surface-2) 160px
  );
  background-size: 400px 100%;
  background-repeat: no-repeat;
  animation: skeleton-loading 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

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

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

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

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

/* Square/icon variant */
.skeleton-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background-color: var(--color-surface-2);
  background-image: linear-gradient(
    90deg,
    var(--color-surface-2) 0px,
    var(--color-surface-3) 80px,
    var(--color-surface-2) 160px
  );
  background-size: 400px 100%;
  background-repeat: no-repeat;
  animation: skeleton-loading 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

/* ── Card skeleton ──────────────────────────────────────────── */
.skeleton-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow: hidden;
  position: relative;
}

/* Card-level shimmer overlay */
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.03) 50%,
    transparent 100%
  );
  background-size: 400px 100%;
  background-repeat: no-repeat;
  animation: skeleton-loading 1.4s ease-in-out infinite;
}

/* ── List item skeleton ─────────────────────────────────────── */
.skeleton-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.skeleton-list-item:last-child {
  border-bottom: none;
}

.skeleton-list-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-list-item-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ── Stat card skeleton ─────────────────────────────────────── */
.skeleton-stat {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

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

.skeleton-table-row:last-child {
  border-bottom: none;
}

/* ── Button skeleton ────────────────────────────────────────── */
.skeleton-btn {
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--color-surface-2);
  background-image: linear-gradient(
    90deg,
    var(--color-surface-2) 0px,
    var(--color-surface-3) 80px,
    var(--color-surface-2) 160px
  );
  background-size: 400px 100%;
  background-repeat: no-repeat;
  animation: skeleton-loading 1.4s ease-in-out infinite;
}

/* ── Badge skeleton ─────────────────────────────────────────── */
.skeleton-badge {
  height: 22px;
  width: 60px;
  border-radius: var(--radius-full);
  background-color: var(--color-surface-2);
  background-image: linear-gradient(
    90deg,
    var(--color-surface-2) 0px,
    var(--color-surface-3) 80px,
    var(--color-surface-2) 160px
  );
  background-size: 400px 100%;
  background-repeat: no-repeat;
  animation: skeleton-loading 1.4s ease-in-out infinite;
}

/* ── Stagger animation delays ───────────────────────────────── */
.skeleton-delay-1 { animation-delay: 0.1s; }
.skeleton-delay-2 { animation-delay: 0.2s; }
.skeleton-delay-3 { animation-delay: 0.3s; }
.skeleton-delay-4 { animation-delay: 0.4s; }
.skeleton-delay-5 { animation-delay: 0.5s; }

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .skeleton-text,
  .skeleton-text-sm,
  .skeleton-text-lg,
  .skeleton-text-xl,
  .skeleton-avatar,
  .skeleton-icon,
  .skeleton-btn,
  .skeleton-badge,
  .skeleton-card::after {
    animation: none;
    background-image: none;
    background-color: var(--color-surface-2);
  }
}
