/**
 * SKELETON LOADING — Global shimmer skeleton styles
 * Shared across all pages: Estate Manager, User Dashboard, KPI Dashboard,
 * User Calendar, Site Details.
 *
 * No page-scoping — these classes work on any page.
 */

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

@keyframes skeleton-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

@keyframes skeleton-spin {
  to { transform: rotate(360deg); }
}

/* =============================================================================
   BASE ELEMENTS
   ============================================================================= */

.skeleton-line {
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border);
  border-top-color: var(--aim-blue-base, var(--color-primary));
  border-radius: 50%;
  animation: skeleton-spin 1s linear infinite;
}

.skeleton-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-btn-wide {
  width: 48px;
  height: 28px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

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

.skeleton-table {
  width: 100%;
}

.skeleton-header-row {
  display: flex;
  gap: 8px;
  padding: 12px 8px;
  background: var(--surface-overlay);
  border-bottom: 2px solid var(--color-border);
}

.skeleton-header-row .skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, #d4d8dc 25%, var(--color-border) 50%, #d4d8dc 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-row {
  display: flex;
  gap: 8px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--surface-overlay);
  height: 40px;
  align-items: center;
}

.skeleton-cell {
  flex: 1;
}

.skeleton-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex: 0 0 100px;
}

/* =============================================================================
   MAP SKELETON
   ============================================================================= */

.skeleton-map {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  background: var(--surface-base);
  color: var(--color-text-muted);
  font-size: 14px;
  gap: 12px;
}

/* =============================================================================
   PAGINATION SKELETON
   ============================================================================= */

.skeleton-pagination {
  display: flex;
  gap: 8px;
  padding: 8px;
  align-items: center;
}

/* =============================================================================
   TRANSITIONS & OVERLAYS
   ============================================================================= */

.skeleton-fade-out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.skeleton-refresh-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--color-surface, #fff) 70%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.skeleton-refresh-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* =============================================================================
   ACTION BOXES (User Dashboard)
   ============================================================================= */

.skeleton-action-box {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 60px;
}

/* =============================================================================
   GAUGE ROW (KPI Dashboard)
   ============================================================================= */

.skeleton-gauge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 1rem;
}

.skeleton-gauge-card {
  flex: 1;
  min-width: 200px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: var(--surface-raised);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.skeleton-gauge-circle {
  width: 120px;
  height: 60px;
  border-radius: 120px 120px 0 0;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* =============================================================================
   CALENDAR SKELETON (User Calendar)
   ============================================================================= */

.skeleton-calendar {
  width: 100%;
}

.skeleton-cal-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--surface-overlay);
  padding: 8px 0;
}

.skeleton-cal-header {
  display: flex;
  justify-content: center;
  padding: 4px;
}

.skeleton-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
}

.skeleton-cal-cell {
  background: var(--surface-raised);
  padding: 8px;
  min-height: 80px;
}

/* =============================================================================
   CARD GRID SKELETON (Site Details, Photos, Components)
   ============================================================================= */

.skeleton-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
}

.skeleton-card {
  flex: 1;
  min-width: 150px;
  max-width: 280px;
  background: var(--surface-raised);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.skeleton-card-img {
  width: 100%;
  height: 120px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* =============================================================================
   GENERIC SHAPE PRIMITIVES
   ============================================================================= */

/* Full-width block — use for image placeholders, banners, solid fill areas */
.skeleton-block {
  width: 100%;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* Circle — use for avatars, icons, gauge centres. Apply explicit width/height at use-site. */
.skeleton-circle {
  border-radius: 50%;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* Text line — inline text placeholder (height = 1em, bottom margin for stacking) */
.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 3px;
}

.skeleton-text:last-child {
  margin-bottom: 0;
  width: 60%;
}

/* Avatar — circular user/profile picture placeholder */
.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

/* Button — action button placeholder */
.skeleton-button {
  height: 36px;
  width: 100px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--color-border) 25%, var(--surface-base) 50%, var(--color-border) 75%);
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

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

/* Mimics aim-table row structure — use inside aim-table-scroll for realistic skeletons */
.skeleton-table-row {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.skeleton-table-row .skeleton-line {
  flex: 1;
}

/* =============================================================================
   LINE WIDTH UTILITIES
   ============================================================================= */

.skeleton-line-small  { width: 40%; }
.skeleton-line-medium { width: 60%; }
.skeleton-line-full   { width: 100%; }

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

@media (prefers-reduced-motion: reduce) {
  .skeleton-line,
  .skeleton-spinner,
  .skeleton-btn,
  .skeleton-btn-wide,
  .skeleton-gauge-circle,
  .skeleton-card-img,
  .skeleton-block,
  .skeleton-circle,
  .skeleton-text,
  .skeleton-avatar,
  .skeleton-button {
    animation: none;
    background: var(--color-border);
  }
}
