/* ============================================================================
   LOADING SKELETONS - Show immediately while data loads
   ============================================================================ */

/* Skeleton animation */
@keyframes skeleton-loading {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton-pulse {
  background: linear-gradient(
    90deg,
    var(--card-bg) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    var(--card-bg) 100%
  );
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* Product skeleton */
.product-skeleton {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.skeleton-image {
  width: 100%;
  height: 200px;
  border-radius: 8px;
  margin-bottom: 1rem;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-content {
  padding: 0.5rem;
}

.skeleton-title {
  height: 24px;
  width: 80%;
  border-radius: 4px;
  margin-bottom: 1rem;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 16px;
  width: 100%;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.skeleton-button {
  flex: 1;
  height: 40px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(0, 198, 255, 0.1) 0%,
    rgba(0, 198, 255, 0.2) 50%,
    rgba(0, 198, 255, 0.1) 100%
  );
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* Lazy loading image states */
.lazy-image {
  opacity: 0;
  transition: opacity 0.3s ease;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.lazy-image.loaded {
  opacity: 1;
  animation: none;
  background: none;
}

/* Loading indicator overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(0, 198, 255, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Inline loading (for buttons, etc) */
.btn-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Fade in animation for loaded content */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Grid layout for skeletons */
.products-grid .product-skeleton {
  min-height: 400px;
}

/* List layout for skeletons */
.products-list .product-skeleton {
  display: flex;
  gap: 1rem;
  min-height: 150px;
}

.products-list .skeleton-image {
  width: 200px;
  height: 150px;
  flex-shrink: 0;
}

.products-list .skeleton-content {
  flex: 1;
}

/* Loading badge */
.loading-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: rgba(0, 198, 255, 0.1);
  border: 1px solid rgba(0, 198, 255, 0.3);
  border-radius: 20px;
  color: var(--primary-color);
  font-size: 0.85rem;
  font-weight: 500;
}

.loading-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* Stale data indicator */
.stale-data-banner {
  background: linear-gradient(90deg, rgba(255, 193, 7, 0.1), rgba(255, 193, 7, 0.05));
  border-left: 4px solid #ffc107;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.stale-data-banner i {
  color: #ffc107;
}

/* Success update banner */
.update-success-banner {
  background: linear-gradient(90deg, rgba(76, 175, 80, 0.1), rgba(76, 175, 80, 0.05));
  border-left: 4px solid #4caf50;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.update-success-banner i {
  color: #4caf50;
}

/* Responsive */
@media (max-width: 768px) {
  .skeleton-image {
    height: 150px;
  }
  
  .products-list .skeleton-image {
    width: 120px;
    height: 100px;
  }
  
  .loading-spinner {
    width: 40px;
    height: 40px;
  }
}
