/**
 * ZMCOR Skeleton Loaders
 * Provides loading state placeholders for better perceived performance
 */

/* Base skeleton animation */
@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Base skeleton element */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-neutral-200, #eaecf0) 25%,
    var(--color-neutral-100, #f2f4f7) 50%,
    var(--color-neutral-200, #eaecf0) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm, 0.375rem);
}

/* Pulse variant */
.skeleton--pulse {
  background: var(--color-neutral-200, #eaecf0);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Text skeleton */
.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text--sm {
  height: 0.875em;
}

.skeleton-text--lg {
  height: 1.25em;
}

.skeleton-text--title {
  height: 2em;
  width: 70%;
}

.skeleton-text--subtitle {
  height: 1.5em;
  width: 50%;
}

/* Avatar skeleton */
.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-avatar--sm {
  width: 32px;
  height: 32px;
}

.skeleton-avatar--lg {
  width: 64px;
  height: 64px;
}

/* Image skeleton */
.skeleton-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg, 0.75rem);
}

.skeleton-image--square {
  aspect-ratio: 1 / 1;
}

.skeleton-image--portrait {
  aspect-ratio: 3 / 4;
}

/* Button skeleton */
.skeleton-button {
  height: 44px;
  width: 120px;
  border-radius: var(--radius-base, 0.5rem);
}

.skeleton-button--lg {
  height: 52px;
  width: 160px;
}

.skeleton-button--full {
  width: 100%;
}

/* Card skeleton */
.skeleton-card {
  background: var(--color-neutral-0, #fff);
  border-radius: var(--radius-xl, 1rem);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.skeleton-card__image {
  width: 100%;
  height: 200px;
  border-radius: var(--radius-lg, 0.75rem);
  margin-bottom: 1rem;
}

.skeleton-card__title {
  height: 1.5em;
  width: 80%;
  margin-bottom: 0.75rem;
}

.skeleton-card__text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-card__text:last-child {
  width: 60%;
}

/* Blog post skeleton */
.skeleton-blog-post {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--color-neutral-0, #fff);
  border-radius: var(--radius-xl, 1rem);
  box-shadow: var(--shadow-sm);
}

.skeleton-blog-post__image {
  flex-shrink: 0;
  width: 200px;
  height: 150px;
  border-radius: var(--radius-lg, 0.75rem);
}

.skeleton-blog-post__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skeleton-blog-post__category {
  height: 1em;
  width: 80px;
  border-radius: var(--radius-full, 9999px);
}

.skeleton-blog-post__title {
  height: 1.5em;
  width: 90%;
}

.skeleton-blog-post__excerpt {
  height: 1em;
  width: 100%;
}

.skeleton-blog-post__meta {
  height: 0.875em;
  width: 150px;
  margin-top: auto;
}

/* Navigation skeleton */
.skeleton-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem 0;
}

.skeleton-nav__logo {
  width: 120px;
  height: 32px;
}

.skeleton-nav__links {
  display: flex;
  gap: 1.5rem;
}

.skeleton-nav__link {
  width: 80px;
  height: 1em;
}

/* Table skeleton */
.skeleton-table {
  width: 100%;
}

.skeleton-table__header {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-neutral-100, #f2f4f7);
  border-radius: var(--radius-lg, 0.75rem) var(--radius-lg, 0.75rem) 0 0;
}

.skeleton-table__header-cell {
  flex: 1;
  height: 1em;
}

.skeleton-table__row {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--color-neutral-200, #eaecf0);
}

.skeleton-table__cell {
  flex: 1;
  height: 1em;
}

/* Form skeleton */
.skeleton-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.skeleton-form__group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skeleton-form__label {
  height: 1em;
  width: 100px;
}

.skeleton-form__input {
  height: 44px;
  width: 100%;
  border-radius: var(--radius-base, 0.5rem);
}

.skeleton-form__textarea {
  height: 120px;
  width: 100%;
  border-radius: var(--radius-base, 0.5rem);
}

/* Stats skeleton */
.skeleton-stats {
  display: flex;
  gap: 2rem;
}

.skeleton-stat {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.skeleton-stat__value {
  height: 2.5em;
  width: 80px;
}

.skeleton-stat__label {
  height: 1em;
  width: 100px;
}

/* Testimonial skeleton */
.skeleton-testimonial {
  padding: 2rem;
  background: var(--color-neutral-0, #fff);
  border-radius: var(--radius-xl, 1rem);
  box-shadow: var(--shadow-sm);
}

.skeleton-testimonial__quote {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-testimonial__author {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .skeleton-blog-post {
    flex-direction: column;
  }

  .skeleton-blog-post__image {
    width: 100%;
    height: 200px;
  }

  .skeleton-stats {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Utility class for hiding content while loading */
.loading-content {
  position: relative;
}

.loading-content[aria-busy="true"] > *:not(.skeleton) {
  visibility: hidden;
}

.loading-content[aria-busy="true"] .skeleton {
  position: absolute;
  inset: 0;
}

/* Fade transition when content loads */
.skeleton-fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    visibility: hidden;
  }
}
