/**
 * AGS Skeleton Loading System
 * Provides skeleton placeholders during page load
 * Integrates with AGS theme and brand color system
 */

/* ===== SKELETON VARIABLES ===== */
:root {
  /* Subtle skeleton with low opacity */
  --ags-skeleton-bg: rgba(0, 0, 0, 0.06);
  --ags-skeleton-shimmer: rgba(255, 255, 255, 0.15);
  
  /* Progress bar uses brand accent color */
  --ags-progress-color: var(--ags-accent);
  --ags-progress-bg: var(--ags-border-subtle);
  --ags-progress-height: 3px;
  
  /* Animation timing */
  --ags-skeleton-duration: 2s;
}

/* Dark mode skeleton colors */
html[data-theme="dark"] {
  --ags-skeleton-bg: rgba(255, 255, 255, 0.08);
  --ags-skeleton-shimmer: rgba(255, 255, 255, 0.1);
  --ags-progress-bg: var(--ags-border);
}

/* ===== SKELETON BASE STYLES ===== */
.ags-skeleton {
  background: var(--ags-skeleton-bg);
  border-radius: var(--ags-radius);
  position: relative;
  overflow: hidden;
  display: inline-block;
}

/* Shimmer animation */
.ags-skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  right: -100%;
  bottom: 0;
  left: -100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--ags-skeleton-shimmer) 50%,
    transparent 100%
  );
  animation: ags-skeleton-shimmer var(--ags-skeleton-duration) infinite;
}

@keyframes ags-skeleton-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ===== SKELETON TYPES ===== */

/* Text skeleton - for headers, labels, paragraphs */
.ags-skeleton--text {
  width: 200px;
  height: 1.5rem;
  min-height: 1.5rem;
}

.ags-skeleton--text-sm {
  width: 100px;
  height: 1rem;
}

.ags-skeleton--text-lg {
  width: 300px;
  height: 2rem;
}

/* Button skeleton */
.ags-skeleton--button {
  width: 85px;
  height: 32px;
  border-radius: var(--ags-radius);
}

.ags-skeleton--button-lg {
  width: 120px;
  height: 40px;
}

/* Select/dropdown skeleton */
.ags-skeleton--select {
  width: 90px;
  height: 36px;
  border-radius: var(--ags-radius);
  position: relative;
}

/* Dropdown arrow indicator */
.ags-skeleton--select::before {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--ags-skeleton-shimmer);
  opacity: 0.5;
}

/* Icon button skeleton */
.ags-skeleton--icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

/* Theme toggle skeleton - matches the actual theme toggle size */
.ags-skeleton--theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--ags-radius);
}

/* Input field skeleton */
.ags-skeleton--input {
  width: 100%;
  height: 44px;
  border-radius: var(--ags-radius);
}

/* Card skeleton */
.ags-skeleton--card {
  width: 100%;
  height: 200px;
  border-radius: var(--ags-radius-lg);
}

/* Avatar skeleton */
.ags-skeleton--avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.ags-skeleton--avatar-sm {
  width: 32px;
  height: 32px;
}

.ags-skeleton--avatar-lg {
  width: 64px;
  height: 64px;
}

/* ===== LOADING PROGRESS BAR ===== */
.ags-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ags-progress-height);
  opacity: 0;
  transition: opacity var(--ags-transition);
}

.ags-progress--active {
  opacity: 1;
}

.ags-progress__bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    transparent 20%,
    var(--ags-accent) 50%,
    transparent 80%,
    transparent 100%
  );
  background-size: 50% 100%;
  animation: ags-progress-gradient 1.5s linear infinite;
}

/* Determinate mode - shows actual progress */
.ags-progress:not(.ags-progress--indeterminate) .ags-progress__bar {
  animation: none;
  background: var(--ags-progress-color);
  width: 0;
  transition: width var(--ags-transition-slow);
}

@keyframes ags-progress-gradient {
  0% {
    background-position: -100% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ===== SKELETON CONTAINERS ===== */

/* Skeleton layout helpers */
.ags-skeleton-group {
  display: flex;
  gap: var(--ags-space-sm);
  align-items: center;
}

.ags-skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: var(--ags-space-xs);
}

/* Hide real content while loading */
[data-skeleton-hide] {
  position: absolute !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ===== PLACEHOLDER STATES ===== */

/* Main content placeholder */
.ags-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ags-space-2xl);
  min-height: 200px;
}

/* Loading icon styling */
.ags-placeholder__icon {
  color: var(--ags-accent);
  opacity: 0.3;
}

/* ===== UTILITY CLASSES ===== */

/* Width variations */
.ags-skeleton--w-full { width: 100%; }
/*.ags-skeleton--w-3/4 { width: 75%; }*/
/*.ags-skeleton--w-1/2 { width: 50%; }*/
/*.ags-skeleton--w-1/3 { width: 33.333%; }*/
/*.ags-skeleton--w-1/4 { width: 25%; }*/

/* Animation control */
.ags-skeleton--no-animation::after {
  animation: none;
}

.ags-skeleton--pulse {
  animation: ags-skeleton-pulse 2s ease-in-out infinite;
}

@keyframes ags-skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .ags-skeleton--text {
    width: 150px;
  }
  
  .ags-skeleton--text-lg {
    width: 200px;
  }
  
  .ags-skeleton--select {
    width: 80px;
  }
}