/* ============================================
   LOADING STATES - Pethology Platform
   Reusable loading components
   ============================================ */

/* Spinner Animation */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Shimmer Animation for Skeletons */
@keyframes shimmer {
  0% { background-position: -468px 0; }
  100% { background-position: 468px 0; }
}

/* Pulse Animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================
   SPINNER COMPONENTS
   ============================================ */

/* Default Spinner */
.spinner {
  border: 3px solid var(--gray-200, #e5e7eb);
  border-top: 3px solid var(--blue-primary, #2563eb);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

/* Small Spinner */
.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* Large Spinner */
.spinner-lg {
  width: 60px;
  height: 60px;
  border-width: 4px;
}

/* ============================================
   LOADING CONTAINERS
   ============================================ */

/* Centered Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  text-align: center;
}

.loading-state p {
  color: var(--gray-600, #4b5563);
  font-size: 14px;
  margin: 0;
}

/* Inline Loading (for buttons) */
.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Full Page Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay-content {
  text-align: center;
}

/* ============================================
   SKELETON SCREENS
   ============================================ */

/* Base Skeleton */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--gray-100, #f3f4f6) 25%,
    var(--gray-200, #e5e7eb) 50%,
    var(--gray-100, #f3f4f6) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* Skeleton Text Line */
.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-text-sm {
  height: 12px;
}

.skeleton-text-lg {
  height: 20px;
}

/* Skeleton Title */
.skeleton-title {
  height: 32px;
  width: 60%;
  margin-bottom: 16px;
}

/* Skeleton Card */
.skeleton-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.skeleton-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

/* Skeleton Button */
.skeleton-button {
  height: 40px;
  width: 120px;
  border-radius: 8px;
}

/* ============================================
   LOADING STATES - Specific Components
   ============================================ */

/* Dashboard Card Loading */
.skeleton-dashboard-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.skeleton-dashboard-card .skeleton-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Module Grid Loading */
.skeleton-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.skeleton-module-card {
  height: 160px;
  border-radius: 12px;
}

/* Quiz Question Loading */
.skeleton-quiz-question {
  padding: 24px;
}

.skeleton-quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.skeleton-quiz-option {
  height: 48px;
  border-radius: 8px;
}

/* Table Loading */
.skeleton-table-row {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Hide/Show */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

/* Loading Button State */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Pulse Loading (for live updates) */
.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .skeleton-module-grid {
    grid-template-columns: 1fr;
  }

  .loading-state {
    padding: 40px 20px;
  }

  .spinner-lg {
    width: 48px;
    height: 48px;
  }
}
