/**
 * Loading Skeleton System
 * Modern skeleton loaders for perceived performance improvement
 * Version: 2026.1.7
 */

/* ===== BASE SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.5) 50%, transparent 100%);
  animation: shimmerOverlay 2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes shimmerOverlay {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ===== SKELETON VARIANTS ===== */
.skeleton-text {
  height: 1rem;
  width: 100%;
  margin-bottom: 0.5rem;
}

.skeleton-text-short {
  width: 60%;
}

.skeleton-text-medium {
  width: 80%;
}

.skeleton-heading {
  height: 1.5rem;
  width: 40%;
  margin-bottom: 1rem;
}

.skeleton-value {
  height: 2.5rem;
  width: 60%;
  margin-bottom: 0.5rem;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-avatar-large {
  width: 90px;
  height: 90px;
  border-radius: 50%;
}

.skeleton-button {
  height: 40px;
  width: 120px;
  border-radius: 8px;
}

.skeleton-card {
  height: 200px;
  border-radius: 16px;
}

.skeleton-image {
  height: 180px;
  width: 100%;
  border-radius: 12px;
}

.skeleton-line {
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, transparent 0%, #e2e8f0 50%, transparent 100%);
}

/* ===== SKELETON CONTAINERS ===== */
.skeleton-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.skeleton-list-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.skeleton-list-item-content {
  flex: 1;
}

/* ===== PAGE-SPECIFIC SKELETONS ===== */

/* Dashboard Skeleton */
.skeleton-dashboard-hero {
  height: 180px;
  border-radius: 24px;
  margin-bottom: 2rem;
}

.skeleton-quick-action {
  height: 140px;
  border-radius: 16px;
}

.skeleton-house-card {
  height: 120px;
  border-radius: 16px;
}

.skeleton-activity-item {
  height: 72px;
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

/* Table Skeleton */
.skeleton-table {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
}

.skeleton-table-header {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.04);
}

.skeleton-table-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.skeleton-table-cell {
  height: 1.5rem;
  border-radius: 4px;
}

/* Stats Panel Skeleton */
.skeleton-stat-item {
  height: 100px;
  border-radius: 16px;
  margin-bottom: 1rem;
}

/* Chart Skeleton */
.skeleton-chart {
  height: 180px;
  border-radius: 12px;
  position: relative;
}

.skeleton-chart::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70%;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.05) 50%,
    transparent 100%
  );
  border-radius: 0 0 12px 12px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
}

[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
}

[data-theme="dark"] .skeleton-line {
  background: linear-gradient(90deg, transparent 0%, #334155 50%, transparent 100%);
}

[data-theme="dark"] .skeleton-list-item {
  background: rgba(51, 65, 85, 0.3);
}

[data-theme="dark"] .skeleton-table-header {
  background: rgba(51, 65, 85, 0.5);
}

[data-theme="dark"] .skeleton-table-row {
  border-bottom-color: rgba(100, 116, 139, 0.2);
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .skeleton::after {
    animation: none;
  }
  
  .skeleton {
    background: #e2e8f0;
  }
  
  [data-theme="dark"] .skeleton {
    background: #1e293b;
  }
}

/* ===== LOADING STATE UTILITIES ===== */
.loading-container {
  position: relative;
  min-height: 200px;
}

.loading-container.is-loading {
  pointer-events: none;
  opacity: 0.6;
}

.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  z-index: 10;
  border-radius: inherit;
}

[data-theme="dark"] .loading-spinner-overlay {
  background: rgba(15, 23, 42, 0.9);
}

[data-theme="dark"] .loading-spinner {
  border-color: rgba(255, 255, 255, 0.1);
  border-left-color: #3b82f6;
}

/* ===== PROGRESSIVE LOADING ===== */
.progressive-reveal {
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.progressive-reveal:nth-child(1) { animation-delay: 0.1s; }
.progressive-reveal:nth-child(2) { animation-delay: 0.2s; }
.progressive-reveal:nth-child(3) { animation-delay: 0.3s; }
.progressive-reveal:nth-child(4) { animation-delay: 0.4s; }
.progressive-reveal:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .progressive-reveal {
    animation: none;
    opacity: 1;
  }
}

/* ===== CONTENT PLACEHOLDER PATTERNS ===== */
.content-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

.content-placeholder-icon {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 1rem;
}

.content-placeholder-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.content-placeholder-subtext {
  font-size: 0.875rem;
  color: var(--text-secondary);
  opacity: 0.7;
}
