/* ================================================================
   UTILITY STYLES - CONSOLIDATED
   Sophia College STARS - Reengagement Room System
   Loading states, skeletons, validation, accessibility
   ================================================================ */

/* ================== LOADING STATES ================== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  text-align: center;
}

.loading-message {
  margin-top: var(--spacing-md);
  color: var(--text-light);
  font-weight: 500;
}

.loading-progress {
  width: 200px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin-top: var(--spacing-md);
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

/* ================== SKELETON SCREENS ================== */
.skeleton {
  animation: skeleton-loading 1.5s ease-in-out infinite;
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #e0e0e0 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-table-row {
  display: grid;
  grid-template-columns: 1fr 2fr 2fr 1fr 1fr;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}

.skeleton-cell {
  height: 20px;
}

.skeleton-cell.large {
  height: 40px;
}

.dark-mode .skeleton {
  background: linear-gradient(
    90deg,
    #2a2a2a 0%,
    #3a3a3a 20%,
    #2a2a2a 40%,
    #2a2a2a 100%
  );
  background-size: 200% 100%;
}

/* ================== FADE IN ANIMATION ================== */
.fade-in {
  animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================== DATA LOADING OVERLAY ================== */
.data-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.data-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dark-mode .data-loading::after {
  background: rgba(0, 0, 0, 0.6);
}

/* ================== FORM VALIDATION STATES ================== */
.field-valid {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15) !important;
  background: rgba(5, 150, 105, 0.02);
  transition: all 0.3s ease;
}

.field-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15) !important;
  background: rgba(220, 38, 38, 0.02);
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.field-error {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: var(--spacing-xs);
  font-weight: 500;
}

/* ================== ACCESSIBILITY ================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to content link - appears on keyboard focus */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
  font-weight: 600;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Remove focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}
