/* ── Smooth Page Loading ─────────────────────────────────── */
:root {
  --skeleton-base: #e5e7eb;
  --skeleton-shine: #f3f4f6;
  --skeleton-radius: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  body { transition: opacity 0.25s ease-out, background-color 0.3s ease; }
  .page-loading main,
  .page-loading .main-content,
  .page-loading .main,
  .page-loading #content,
  .page-loading .content { opacity: 0; }
}

/* ── Initial page fade-in ────────────────────────────────── */
body.is-loading {
  opacity: 0;
}
body.is-loaded {
  opacity: 1;
  animation: page-fade-in 0.35s ease-out;
}
@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Top progress bar ────────────────────────────────────── */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, #7c3aed, #5b21b6, #7c3aed);
  background-size: 200% 100%;
  z-index: 100000;
  pointer-events: none;
  width: 0%;
  opacity: 0;
  transition: opacity 0.2s, width 0.4s ease;
  animation: progress-shine 1.5s linear infinite;
}
.page-progress.active { opacity: 1; }
.page-progress.done { width: 100% !important; opacity: 0; transition: width 0.2s, opacity 0.3s 0.1s; }
@keyframes progress-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Skeleton loaders ────────────────────────────────────── */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--skeleton-radius);
  display: block;
}
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-line.sm { width: 30%; }
.skeleton-line.md { width: 60%; }
.skeleton-line.lg { width: 90%; }
.skeleton-title { height: 24px; width: 40%; margin-bottom: 16px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-block { height: 80px; margin-bottom: 12px; border-radius: 12px; }
.skeleton-card { height: 120px; margin-bottom: 16px; border-radius: 12px; }
.skeleton-table-row { height: 48px; margin-bottom: 8px; border-radius: 8px; }

/* ── Card list entry animation ───────────────────────────── */
.fade-in-stagger > * {
  opacity: 0;
  animation: card-fade-in 0.4s ease-out forwards;
}
.fade-in-stagger > *:nth-child(1) { animation-delay: 0.02s; }
.fade-in-stagger > *:nth-child(2) { animation-delay: 0.06s; }
.fade-in-stagger > *:nth-child(3) { animation-delay: 0.10s; }
.fade-in-stagger > *:nth-child(4) { animation-delay: 0.14s; }
.fade-in-stagger > *:nth-child(5) { animation-delay: 0.18s; }
.fade-in-stagger > *:nth-child(6) { animation-delay: 0.22s; }
.fade-in-stagger > *:nth-child(7) { animation-delay: 0.26s; }
.fade-in-stagger > *:nth-child(8) { animation-delay: 0.30s; }
.fade-in-stagger > *:nth-child(9) { animation-delay: 0.34s; }
.fade-in-stagger > *:nth-child(10) { animation-delay: 0.38s; }
.fade-in-stagger > *:nth-child(n+11) { animation-delay: 0.42s; }
@keyframes card-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Page transition (SPA-like) ─────────────────────────── */
.page-transition-out {
  animation: page-fade-out 0.18s ease-in forwards;
}
@keyframes page-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ── Skeleton wrapper ───────────────────────────────────── */
.skeleton-wrapper {
  padding: 16px;
}
.skeleton-wrapper .skeleton-card {
  margin-bottom: 12px;
}
.skeleton-wrapper .skeleton-block {
  margin-bottom: 8px;
}

/* ── Shimmer effect for data loading ─────────────────────── */
.data-loading {
  position: relative;
  min-height: 200px;
}
.data-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.04), transparent);
  background-size: 200% 100%;
  animation: shimmer-overlay 1.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 10;
}
@keyframes shimmer-overlay {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
