/* Enhanced Loader System - DigiVal Assessment Platform */

/* Base Loader Overlay */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 9999;
  animation: unifiedFadeIn 0.3s ease-out;
}

.loader-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: 400px;
  padding: 1.5rem;
}

/* Default Basic Loader (Spinner) */
.loader {
  position: relative;
  display: inline-block;
  margin: 0 auto 2rem auto;
  width: 60px;
  height: 60px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ============================================ */
/* UNIFIED LOADER - Single Design for All Types */
/* ============================================ */
.unified-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  z-index: 9999;
  animation: unifiedFadeIn 0.4s ease-out;
}

.unified-loader-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: white;
  padding: 2rem 2.5rem 3rem 2.5rem;
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  min-width: 400px;
  max-width: 450px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  position: relative;
}

.unified-loader-spinner {
  position: relative;
  display: inline-block;
  width: 70px;
  height: 70px;
  margin-bottom: 2rem;
  margin-top: 2rem;
}

.unified-loader-spinner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 4px solid #e1e7ff;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.unified-loader-icon {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  animation: unifiedIconFloat 3s ease-in-out infinite;
  z-index: 10;
}

/* Icon colors based on type */
.unified-loader-icon.exam-type {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.unified-loader-icon.report-type {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

.unified-loader-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 1rem;
  animation: fadeInUp 0.6s ease-out;
  letter-spacing: 0.5px;
}

.unified-loader-subtitle {
  font-size: 1rem;
  color: #6b7280;
  margin-bottom: 2rem;
  animation: fadeInUp 0.8s ease-out;
  line-height: 1.5;
}

.unified-loader-progress {
  font-size: 0.9rem;
  color: #1e40af;
  background: #eff6ff;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  font-family: 'SF Mono', Monaco, monospace;
  animation: unifiedProgressPulse 1.5s ease-in-out infinite;
  margin-top: 0.5rem;
}

.unified-loader-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 1.5rem;
}

.unified-loader-dots .loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  animation: loadingDotPulse 1.4s infinite ease-in-out;
}

.unified-loader-dots .loading-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.unified-loader-dots .loading-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.unified-loader-dots .loading-dot:nth-child(3) {
  animation-delay: 0s;
}

/* Enhanced Spinner Variants */
.loader.spinner-gradient {
  background: conic-gradient(from 0deg, #2196f3, #21cbf3, #2196f3);
  border: none;
  border-radius: 50%;
  position: relative;
}

.loader.spinner-gradient::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  background: white;
  border-radius: 50%;
}

/* Pulse Loader */
.loader.pulse {
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.loader.pulse::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border: 2px solid #667eea;
  border-radius: 50%;
  opacity: 0;
  animation: pulseRing 2s ease-in-out infinite;
}

/* Dots Loader */
.loader.dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  height: 80px;
  width: auto;
  border: none;
  background: none;
  animation: none;
}

.loader.dots .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2196f3, #21cbf3);
  animation: dotBounce 1.4s infinite ease-in-out;
}

.loader.dots .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.loader.dots .dot:nth-child(2) {
  animation-delay: -0.16s;
}

.loader.dots .dot:nth-child(3) {
  animation-delay: 0s;
}

/* Ripple Loader */
.loader.ripple {
  border: none;
  background: none;
  animation: none;
}

.loader.ripple .ripple-circle {
  position: absolute;
  border: 4px solid #2196f3;
  border-radius: 50%;
  opacity: 1;
  animation: rippleEffect 1.2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.loader.ripple .ripple-circle:nth-child(2) {
  animation-delay: -0.6s;
}

/* Progress Bar Loader */
.loader.progress-bar {
  width: 240px;
  height: 8px;
  border: none;
  border-radius: 4px;
  background: #e0e0e0;
  overflow: hidden;
  animation: none;
}

.loader.progress-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2196f3, #21cbf3, #2196f3);
  border-radius: 4px;
  animation: progressSlide 2s infinite linear;
}

/* Text Elements */
.loader-text {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.75rem;
  animation: textPulse 2s infinite ease-in-out;
}

.loader-subtext {
  font-size: 1rem;
  color: #666;
  line-height: 1.5;
  margin-bottom: 1rem;
  animation: fadeInUp 0.6s ease-out;
}

.loader-progress-text {
  font-size: 0.85rem;
  color: #888;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  background: #f8f9fa;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-top: 1rem;
  border-left: 3px solid #2196f3;
}

/* Specialized Context Styles */
.loader-container.exam-context {
  border-left: 6px solid #6b7280;
}

.loader-container.report-context {
  border-left: 6px solid #6b7280;
}

.loader-container.ai-context {
  border-left: 6px solid #6b7280;
}

.loader-container.export-context {
  border-left: 6px solid #6b7280;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

@keyframes pulseRing {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }

  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

@keyframes dotBounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

@keyframes rippleEffect {
  0% {
    top: 36px;
    left: 36px;
    width: 8px;
    height: 8px;
    opacity: 1;
  }

  100% {
    top: 0px;
    left: 0px;
    width: 80px;
    height: 80px;
    opacity: 0;
  }
}

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

  100% {
    left: 100%;
  }
}

@keyframes textPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ============================================ */
/* LOADER ANIMATIONS */
/* ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  100% {
    transform: rotate(360deg);
  }
}

@keyframes unifiedFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }

  to {
    opacity: 1;
    backdrop-filter: blur(8px);
  }
}

@keyframes unifiedIconFloat {

  0%,
  100% {
    transform: translate(-50%, -50%) translateY(0px);
  }

  50% {
    transform: translate(-50%, -50%) translateY(-5px);
  }
}

@keyframes unifiedProgressPulse {

  0%,
  100% {
    background: #eff6ff;
    transform: scale(1);
  }

  50% {
    background: #dbeafe;
    transform: scale(1.01);
  }
}

@keyframes loadingDotPulse {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================ */
/* RESPONSIVE DESIGN */
/* ============================================ */
@media (max-width: 768px) {
  .loader-container {
    max-width: 320px;
    padding: 2rem 1.5rem;
    margin: 1rem;
  }

  .unified-loader-container {
    min-width: 300px;
    padding: 2rem 1.5rem;
  }

  .loader {
    width: 50px;
    height: 50px;
  }

  .unified-loader-spinner {
    width: 60px;
    height: 60px;
  }

  .unified-loader-title {
    font-size: 1.2rem;
  }

  .unified-loader-subtitle {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .unified-loader-container {
    min-width: 280px;
    padding: 1.5rem;
  }

  .unified-loader-spinner {
    width: 50px;
    height: 50px;
  }

  .unified-loader-dots {
    gap: 12px;
  }

  .unified-loader-dots .loading-dot {
    width: 6px;
    height: 6px;
  }
}

/* ============================================ */
/* ACCESSIBILITY */
/* ============================================ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .loader {
    border-color: #000;
    border-top-color: #000;
  }

  .unified-loader-spinner::before {
    border-color: #000;
    border-top-color: #000;
  }

  .unified-loader-dots .loading-dot {
    background: #000;
  }
}