/**
 * Loading System CSS
 * 
 * Provides consistent animations and styles for the unified loading system.
 * Includes heartbeat animation, smooth transitions, and responsive design.
 */

/* Heartbeat Animation */
@keyframes heartbeat {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  25% {
    transform: scale(1.2);
    opacity: 0.8;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
  75% {
    transform: scale(1.1);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes heartbeat-ring {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.3;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0.1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

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

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide In Animation */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Loading Container Base Styles */
.loading-container {
  animation: fadeIn 0.3s ease-out;
  background-color: #ffffff !important;
  color: #333333 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 20px !important;
}

/* Heartbeat Container */
.heartbeat-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heartbeat-pulse {
  animation: heartbeat 1.5s ease-in-out infinite;
  border-radius: 50%;
}

/* Brand Logo Styles */
.brand-logo {
  animation: slideIn 0.5s ease-out;
  transition: all 0.3s ease;
  background-color: #007bff !important;
  color: #ffffff !important;
  box-shadow: 0 4px 20px rgba(0, 123, 255, 0.2) !important;
}

.brand-logo:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3) !important;
}

/* Loading Message Styles */
.loading-message {
  animation: fadeIn 0.6s ease-out 0.2s both;
}

/* Progress Bar Animation */
.progress-bar {
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Button Hover Effects */
.loading-button {
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.loading-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.loading-button:hover::before {
  width: 300px;
  height: 300px;
}

/* Error Screen Shake Animation */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-2px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(2px);
  }
}

.error-container {
  animation: shake 0.5s ease-in-out;
}

/* Success Screen Bounce Animation */
@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

.success-container {
  animation: bounce 0.8s ease-in-out;
}

/* Inline Loader Styles */
.inline-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inline-loader .heartbeat-pulse {
  animation-duration: 1s;
}

/* Responsive Design */
@media (max-width: 768px) {
  .loading-container {
    padding: 15px;
  }
  
  .brand-logo {
    font-size: 1.5rem !important;
    padding: 15px 25px !important;
  }
  
  .loading-message {
    font-size: 1rem;
    max-width: 300px;
  }
  
  .loading-button {
    width: 100%;
    margin-bottom: 10px;
  }
}

@media (max-width: 480px) {
  .loading-container {
    padding: 10px;
  }
  
  .brand-logo {
    font-size: 1.25rem !important;
    padding: 12px 20px !important;
  }
  
  .loading-message {
    font-size: 0.9rem;
    max-width: 250px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .heartbeat-pulse {
    border: 2px solid currentColor;
  }
  
  .brand-logo {
    border: 2px solid currentColor;
  }
  
  .loading-button {
    border: 2px solid currentColor;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .heartbeat-pulse,
  .brand-logo,
  .loading-message,
  .loading-container {
    animation: none;
  }
  
  .loading-button {
    transition: none;
  }
  
  .progress-bar::after {
    animation: none;
  }
}

/* Dark Mode Support - DISABLED
 * App currently does not support dark mode to avoid user confusion
 * Dark mode styling has been removed to ensure consistent light theme
 */

/* Loading Overlay for Partial Page Loading */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(249, 250, 251, 0.95);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dark overlay class removed - app uses consistent light theme */

/* Skeleton Loading Animation */
@keyframes skeleton {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: skeleton 1.5s infinite;
}

/* Dark skeleton class removed - app uses consistent light theme */

/* Utility Classes */
.loading-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.loading-slide-in {
  animation: slideIn 0.3s ease-out;
}

.loading-pulse {
  animation: pulse 2s infinite;
}

.loading-heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

/* Focus Management for Accessibility */
.loading-container:focus-within {
  outline: 2px solid #81de76;
  outline-offset: 2px;
}

/* Screen Reader Support */
.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;
}

/* CRITICAL: Ensure white background everywhere */
html, body, #root, .loading-container, #loading-screen {
  background: #ffffff !important;
}

/* Override any potential dark backgrounds */
* {
  background-color: inherit;
}

/* Loading States for Different Components */
.loading-auth {
  background: #ffffff !important;
  color: #333333 !important;
}

.loading-redirect {
  background: #ffffff !important;
  color: #333333 !important;
}

.loading-error {
  background: #ffffff !important;
  color: #333333 !important;
}

.loading-success {
  background: #ffffff !important;
  color: #333333 !important;
}