/* Loading States CSS - Reusable loading indicators and animations */

/* Global Loader Overlay */
.global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-loader.hidden {
  display: none;
}

.loader-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.loader-content {
  position: relative;
  background: var(--card);
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 200px;
}

/* Spinner Animations */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--line);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.inline-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  margin-right: 8px;
}

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

/* Inline Loaders */
.inline-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--muted, #64748b);
  font-size: 14px;
}

.inline-loader-text {
  margin-left: 8px;
}

/* Loading States for Specific Elements */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--line);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1;
}

/* Button Loading States */
button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  position: relative;
}

button.loading {
  color: transparent;
}

button.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Calendar Loading States */
.calendar-loading {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.calendar-loading .spinner {
  width: 32px;
  height: 32px;
}

/* Form Loading States */
.form-loading {
  position: relative;
}

.form-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 1;
  border-radius: inherit;
}

.form-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid var(--line);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 2;
}

/* Skeleton Loading for Lists */
.skeleton-loader {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 16px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.long { width: 100%; }

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

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

/* Mobile Responsive Loading States */
@media (max-width: 640px) {
  .loader-content {
    padding: 24px;
    margin: 16px;
    min-width: unset;
    width: calc(100% - 32px);
    max-width: 300px;
  }
  
  .spinner {
    width: 32px;
    height: 32px;
  }
  
  .loader-text {
    font-size: 14px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .inline-spinner,
  .loading::after,
  button.loading::after {
    animation: none;
  }
  
  .skeleton-loader {
    animation: none;
    background: #f0f0f0;
  }
}
