/* Animations / reusable UI bits */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

/* ================================================================
   SKELETON LOADING SYSTEM
   ================================================================ */

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

@keyframes skeletonFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.skel-bone {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 0%,
    var(--bg-hover) 40%,
    var(--bg-tertiary) 80%
  );
  background-size: 800px 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="dark"] .skel-bone {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.08) 40%,
    rgba(255, 255, 255, 0.04) 80%
  );
  background-size: 800px 100%;
}

.skel-card {
  animation: skeletonFadeIn 0.35s ease both;
}

/* Skeleton table layout */
.skel-table {
  width: 100%;
}

.skel-table-head {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  background: var(--table-head-bg);
  border-bottom: 1px solid var(--border-subtle);
}

.skel-table-th {
  flex: 1;
}

.skel-table-row {
  display: flex;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  animation: skeletonFadeIn 0.3s ease both;
}

.skel-table-td {
  flex: 1;
}

/* Loading screen (auth check, full-page) */
.app-loading-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  animation: fadeUp 0.3s ease both;
}

.app-loading-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Branded loading spinner */
.app-loading-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  font-weight: 800;
  font-family: var(--font-display);
  animation: logoPulse 2s ease-in-out infinite;
  box-shadow: 0 8px 32px rgba(15, 118, 110, 0.25);
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 32px rgba(15, 118, 110, 0.25); }
  50%      { transform: scale(1.05); box-shadow: 0 12px 40px rgba(15, 118, 110, 0.35); }
}

/* Progress bar */
.app-loading-progress {
  width: 200px;
  height: 3px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.app-loading-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  animation: progressSlide 1.5s ease-in-out infinite;
}

@keyframes progressSlide {
  0%   { width: 0%; margin-left: 0; }
  50%  { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

.app-loading-text {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.03em;
}

/* Page-level loading (shown inside the layout, not full-screen) */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  animation: fadeUp 0.3s ease both;
}

.page-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.page-loading-text {
  color: var(--text-muted);
  font-size: 13px;
}

.main-body {
  animation: fadeUp 0.45s ease both;
}

.stats-grid > *,
.dashboard-grid-auto > * {
  animation: fadeUp 0.5s ease both;
}

.stats-grid > *:nth-child(1),
.dashboard-grid-auto > *:nth-child(1) { animation-delay: 0.03s; }
.stats-grid > *:nth-child(2),
.dashboard-grid-auto > *:nth-child(2) { animation-delay: 0.07s; }
.stats-grid > *:nth-child(3),
.dashboard-grid-auto > *:nth-child(3) { animation-delay: 0.11s; }
.stats-grid > *:nth-child(4),
.dashboard-grid-auto > *:nth-child(4) { animation-delay: 0.15s; }
