/*!
 * Loading States CSS - Health-Prep v2
 * Loading indicators and skeleton screens for healthcare UI
 */

/* ===== LOADING ANIMATIONS ===== */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

@keyframes dots {
  0%, 20% { color: transparent; text-shadow: 0.25em 0 0 transparent, 0.5em 0 0 transparent; }
  40% { color: var(--hp-primary, #0d6efd); text-shadow: 0.25em 0 0 transparent, 0.5em 0 0 transparent; }
  60% { text-shadow: 0.25em 0 0 var(--hp-primary, #0d6efd), 0.5em 0 0 transparent; }
  80%, 100% { text-shadow: 0.25em 0 0 var(--hp-primary, #0d6efd), 0.5em 0 0 var(--hp-primary, #0d6efd); }
}

/* ===== LOADING SPINNERS ===== */
.loading-spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  vertical-align: text-bottom;
  border: 0.25em solid currentcolor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loading-spinner-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.125em;
}

.loading-spinner-lg {
  width: 3rem;
  height: 3rem;
  border-width: 0.375em;
}

/* Medical-themed spinner */
.loading-medical {
  color: var(--hp-primary, #0d6efd);
  position: relative;
}

.loading-medical::after {
  content: "⚕";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75em;
  animation: pulse 1s ease-in-out infinite;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(26, 29, 35, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-overlay-content {
  text-align: center;
  color: var(--hp-text-primary, #ecf0f1);
}

.loading-overlay-spinner {
  margin-bottom: 1rem;
}

.loading-overlay-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.loading-overlay-subtext {
  font-size: 0.9rem;
  color: var(--hp-text-muted, #95a5a6);
}

/* ===== INLINE LOADING STATES ===== */
.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--hp-text-muted, #95a5a6);
  font-size: 0.9rem;
}

.loading-inline-text::after {
  content: "...";
  animation: dots 1.5s steps(5, end) infinite;
}

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg, 
    var(--hp-bg-secondary, #2c3e50) 25%, 
    var(--hp-bg-card, #34495e) 37%, 
    var(--hp-bg-secondary, #2c3e50) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 0.25rem;
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

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

.skeleton-title {
  height: 1.5rem;
  width: 40%;
  margin-bottom: 1rem;
}

.skeleton-paragraph {
  height: 0.875rem;
  margin-bottom: 0.5rem;
}

.skeleton-paragraph:nth-child(odd) {
  width: 90%;
}

.skeleton-paragraph:nth-child(even) {
  width: 75%;
}

.skeleton-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
}

.skeleton-card {
  height: 200px;
  border-radius: 0.5rem;
}

.skeleton-table-row {
  height: 3rem;
  margin-bottom: 0.5rem;
  border-radius: 0.25rem;
}

/* ===== MEDICAL DATA LOADING ===== */
.loading-medical-data {
  padding: 2rem;
  text-align: center;
  background-color: var(--hp-bg-card, #34495e);
  border: 1px solid var(--hp-border-color, #454d55);
  border-radius: 0.5rem;
}

.loading-medical-icon {
  font-size: 3rem;
  color: var(--hp-primary, #0d6efd);
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

.loading-medical-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--hp-text-primary, #ecf0f1);
  margin-bottom: 0.5rem;
}

.loading-medical-subtext {
  color: var(--hp-text-muted, #95a5a6);
  font-size: 0.9rem;
}

/* ===== SCREENING PROGRESS INDICATOR ===== */
.screening-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background-color: var(--hp-bg-card, #34495e);
  border: 1px solid var(--hp-border-color, #454d55);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.screening-progress-spinner {
  flex-shrink: 0;
}

.screening-progress-content {
  flex: 1;
}

.screening-progress-title {
  font-weight: 600;
  color: var(--hp-text-primary, #ecf0f1);
  margin-bottom: 0.25rem;
}

.screening-progress-status {
  color: var(--hp-text-muted, #95a5a6);
  font-size: 0.9rem;
}

/* ===== OCR PROCESSING INDICATOR ===== */
.ocr-processing {
  background-color: rgba(13, 110, 253, 0.1);
  border: 1px solid var(--hp-primary, #0d6efd);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.ocr-processing-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.ocr-processing-icon {
  color: var(--hp-primary, #0d6efd);
  font-size: 1.25rem;
  animation: spin 2s linear infinite;
}

.ocr-processing-title {
  font-weight: 600;
  color: var(--hp-primary, #0d6efd);
}

.ocr-processing-progress {
  background-color: var(--hp-bg-secondary, #2c3e50);
  border-radius: 0.25rem;
  height: 0.5rem;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.ocr-processing-progress-bar {
  background-color: var(--hp-primary, #0d6efd);
  height: 100%;
  transition: width 0.3s ease;
  animation: shimmer 2s ease-in-out infinite;
}

.ocr-processing-status {
  font-size: 0.875rem;
  color: var(--hp-text-muted, #95a5a6);
}

/* ===== BUTTON LOADING STATES ===== */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.65;
}

.btn-loading .btn-text {
  visibility: hidden;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  top: 50%;
  left: 50%;
  margin-left: -0.5rem;
  margin-top: -0.5rem;
  border: 0.125rem solid currentcolor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ===== FORM LOADING STATES ===== */
.form-loading {
  position: relative;
  opacity: 0.7;
  pointer-events: none;
}

.form-loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(26, 29, 35, 0.3);
  z-index: 10;
}

.form-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border: 0.25rem solid var(--hp-primary, #0d6efd);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  z-index: 11;
}

/* ===== TABLE LOADING STATES ===== */
.table-loading {
  position: relative;
  min-height: 200px;
}

.table-loading tbody {
  opacity: 0.3;
}

.table-loading::after {
  content: "Loading data...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--hp-bg-card, #34495e);
  color: var(--hp-text-primary, #ecf0f1);
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  border: 1px solid var(--hp-border-color, #454d55);
  font-weight: 500;
  z-index: 10;
}

/* ===== TOAST LOADING NOTIFICATIONS ===== */
.toast-loading {
  background-color: var(--hp-bg-card, #34495e);
  border: 1px solid var(--hp-border-color, #454d55);
  color: var(--hp-text-primary, #ecf0f1);
}

.toast-loading .toast-header {
  background-color: var(--hp-bg-secondary, #2c3e50);
  border-bottom: 1px solid var(--hp-border-color, #454d55);
}

.toast-loading-icon {
  animation: spin 1s linear infinite;
  color: var(--hp-primary, #0d6efd);
}

/* ===== RESPONSIVE LOADING STATES ===== */
@media (max-width: 768px) {
  .loading-overlay-content {
    padding: 1rem;
  }
  
  .loading-medical-data {
    padding: 1.5rem 1rem;
  }
  
  .loading-medical-icon {
    font-size: 2.5rem;
  }
  
  .screening-progress {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .skeleton-card {
    height: 150px;
  }
}

@media (max-width: 576px) {
  .loading-overlay-text {
    font-size: 1rem;
  }
  
  .loading-medical-text {
    font-size: 1rem;
  }
  
  .ocr-processing {
    padding: 0.75rem;
  }
  
  .screening-progress {
    padding: 0.75rem;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner,
  .loading-medical::after,
  .ocr-processing-icon,
  .btn-loading::after,
  .form-loading::after {
    animation: none;
  }
  
  .skeleton {
    animation: pulse 2s ease-in-out infinite;
  }
  
  .loading-inline-text::after {
    animation: none;
    content: "...";
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .loading-overlay,
  .loading-spinner,
  .skeleton,
  .loading-medical-data,
  .screening-progress,
  .ocr-processing {
    display: none !important;
  }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
  .loading-spinner,
  .loading-medical,
  .ocr-processing-icon {
    border-width: 3px;
  }
  
  .skeleton {
    background: repeating-linear-gradient(
      90deg,
      #000 0px,
      #333 20px,
      #000 40px
    );
  }
}

