/**
 * Unified Loading Animation Styles
 * Consistent loading experience across all analyzer pages
 */

/* Loading Container */
.analyzer-loading {
  display: none;
  background: linear-gradient(135deg, rgba(26, 35, 50, 0.98) 0%, rgba(18, 25, 35, 0.98) 100%);
  border: 1px solid rgba(0, 255, 65, 0.2);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem auto;
  max-width: 800px;
  box-shadow: 0 4px 24px rgba(0, 255, 65, 0.1);
  backdrop-filter: blur(10px);
}

.analyzer-loading.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

/* Loading Header */
.loading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.loading-title {
  font-size: 1.1rem;
  color: #00ff41;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.loading-subtitle {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

/* Progress Indicators */
.progress-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.progress-step {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-step::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.3s ease;
}

.progress-step.pending {
  opacity: 0.4;
}

.progress-step.pending::before {
  background: rgba(255, 255, 255, 0.15);
}

.progress-step.active {
  background: rgba(0, 255, 65, 0.04);
  border-color: rgba(0, 255, 65, 0.3);
  opacity: 1;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.1);
}

.progress-step.active::before {
  background: #00ff41;
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
}

.progress-step.complete {
  opacity: 0.8;
}

.progress-step.complete::before {
  background: #00ff41;
}

.progress-step.error::before {
  background: #ff4444;
}

/* Step Icon */
.step-icon {
  font-size: 1.2rem;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-step.pending .step-icon::before {
  content: '◯';
  color: rgba(255, 255, 255, 0.25);
  font-weight: 300;
}

.progress-step.active .step-icon::before {
  content: '◉';
  color: #00ff41;
  animation: pulse 1.5s ease-in-out infinite;
  font-weight: 400;
}

.progress-step.complete .step-icon::before {
  content: '✓';
  color: #00ff41;
  font-weight: 600;
}

.progress-step.error .step-icon::before {
  content: '✗';
  color: #ff4444;
  font-weight: 600;
}

/* Step Text */
.step-text {
  flex: 1;
  min-width: 0;
}

.step-label {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
  margin: 0 0 0.15rem 0;
  line-height: 1.3;
}

.step-detail {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.3;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-step.active .step-label {
  color: #00ff41;
}

.progress-step.active .step-detail {
  color: rgba(0, 255, 65, 0.8);
  opacity: 1;
}

/* Spinner Animation */
.analyzer-spinner {
  width: 60px;
  height: 60px;
  margin: 2rem auto;
  border: 4px solid rgba(0, 255, 65, 0.1);
  border-top: 4px solid #00ff41;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Progress Bar */
.loading-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin: 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00ff41, #00cc33);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}

/* Estimated Time */
.estimated-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.time-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
  font-weight: 500;
}

.time-value {
  font-size: 0.9rem;
  color: #00ff41;
  font-weight: 600;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.time-label.overrun {
  color: #ffd166;
}

.time-value.overrun {
  color: #ffd166;
  animation: etaPulse 1.2s ease-in-out infinite;
}

/* Loading Messages */
.loading-messages {
  text-align: center;
  margin: 1.5rem 0;
}

.loading-message {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.8);
  margin: 0.5rem 0;
  animation: fadeInOut 2s ease-in-out infinite;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.8;
  }
}

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

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

@keyframes etaPulse {
  0%, 100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
}

/* Dots Animation */
.dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% {
    content: '';
  }
  40% {
    content: '.';
  }
  60% {
    content: '..';
  }
  80%, 100% {
    content: '...';
  }
}

/* Responsive */
@media (max-width: 768px) {
  .analyzer-loading {
    padding: 1.25rem;
    margin: 1rem;
  }
  
  .loading-title {
    font-size: 1rem;
  }
  
  .progress-steps {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .progress-step {
    padding: 0.6rem;
  }
  
  .step-label {
    font-size: 0.8rem;
  }
  
  .step-detail {
    font-size: 0.7rem;
  }
  
  .step-icon {
    font-size: 1rem;
    min-width: 20px;
  }
}

/* ========================================
   LIGHT THEME OVERRIDES
   ======================================== */

body.white-theme .analyzer-loading {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 1px solid rgba(76, 175, 80, 0.3);
  box-shadow: 0 4px 24px rgba(76, 175, 80, 0.12);
}

body.white-theme .loading-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.white-theme .loading-title {
  color: #2e7d32;
}

body.white-theme .progress-step {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

body.white-theme .progress-step.active {
  background: rgba(76, 175, 80, 0.08);
  border-color: rgba(76, 175, 80, 0.4);
  box-shadow: 0 0 16px rgba(76, 175, 80, 0.15);
}

body.white-theme .progress-step.active::before {
  background: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

body.white-theme .progress-step.complete::before {
  background: #66bb6a;
}

body.white-theme .step-label {
  color: #1a1a1a;
}

body.white-theme .step-detail {
  color: #666666;
}

body.white-theme .progress-step.active .step-label {
  color: #2e7d32;
}

body.white-theme .progress-step.active .step-detail {
  color: #388e3c;
}

body.white-theme .progress-step.pending .step-icon::before {
  color: rgba(0, 0, 0, 0.2);
  font-weight: 300;
}

body.white-theme .progress-step.active .step-icon::before {
  color: #2e7d32;
  font-weight: 500;
}

body.white-theme .progress-step.complete .step-icon::before {
  color: #388e3c;
  font-weight: 600;
}

body.white-theme .loading-progress-bar {
  background: rgba(0, 0, 0, 0.08);
}

body.white-theme .progress-bar-fill {
  background: linear-gradient(90deg, #2e7d32, #4caf50);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

body.white-theme .estimated-time {
  border-top-color: rgba(0, 0, 0, 0.08);
}

body.white-theme .time-label {
  color: #666666;
}

body.white-theme .time-value {
  color: #2e7d32;
}

body.white-theme .time-label.overrun {
  color: #c2410c;
}

body.white-theme .time-value.overrun {
  color: #c2410c;
}

body.white-theme #progressPercentage {
  color: #2e7d32 !important;
}
