/* Loading Screen Styles */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  background: linear-gradient(135deg, var(--gradient-from) 0%, var(--gradient-mid) 50%, var(--gradient-to) 100%);
  color: var(--text-primary);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  opacity: 1;
  transition: opacity 0.3s ease-out;
  padding: 2rem 0;
  box-sizing: border-box;
}

.loading-screen.hiding {
  opacity: 0;
  pointer-events: none;
}

.loading-screen.success {
  animation: successGlow 0.8s ease-out forwards;
}

@keyframes successGlow {
  0% {
    box-shadow: inset 0 0 0 rgba(var(--accent-rgb), 0);
  }
  100% {
  }
}

.success-message {
  text-align: center;
  padding: 1rem;
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease-out;
}

.loading-screen.success .success-message {
  opacity: 1;
  transform: translateY(0);
}

.success-message h2 {
  margin: 0;
  font-size: 2rem;
  background: linear-gradient(45deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.success-message p {
  margin: 0.5rem 0 0 0;
  color: var(--accent);
  font-size: 1.1rem;
}

.loading-container {
  max-width: 600px;
  width: 90%;
  padding: 2rem;
}

.loading-subtitle {
  margin-top: 1rem;
}

#loading-status-text {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Progress Bar */
.loading-progress {
  margin-bottom: 3rem;
}

.progress-bar-container {
  background: rgba(var(--text-rgb), 0.1);
  border-radius: 8px;
  padding: 2px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(var(--text-rgb), 0.1);
}

.progress-bar {
  height: 8px;
  background: rgba(var(--text-rgb), 0.05);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 20px;
  width: 0%;
  transition: width 0.3s ease-out;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(var(--text-rgb), 0.3), 
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding: 0 0.5rem;
  font-size: 0.9rem;
}

#progress-percentage {
  font-weight: 600;
  color: var(--accent);
}

#progress-details {
  color: var(--text-secondary);
}

/* System Status Cards */
.loading-systems {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  max-height: 268px; /* Fixed height */
  overflow-y: auto; /* Scrollbar when content overflows */
  padding-right: 0.5rem; /* Space for scrollbar */
}

/* Custom scrollbar styling */
.loading-systems::-webkit-scrollbar {
  width: 6px;
}

.loading-systems::-webkit-scrollbar-track {
  background: rgba(var(--text-rgb), 0.05);
  border-radius: 3px;
}

.loading-systems::-webkit-scrollbar-thumb {
  background: rgba(var(--accent-rgb), 0.3);
  border-radius: 3px;
}

.loading-systems::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--accent-rgb), 0.5);
}

.system-card {
  background: rgba(var(--text-rgb), 0.05);
  border: 1px solid rgba(var(--text-rgb), 0.1);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.system-card:hover {
  background: rgba(var(--text-rgb), 0.08);
  transform: translateY(-2px);
}

.system-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--text-rgb), 0.1);
  border-radius: 8px;
}

.system-info {
  flex: 1;
  text-align: left;
}

.system-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.system-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.system-indicator {
  font-size: 1.2rem;
}

/* System Card States */
.system-card.checking {
  border-color: var(--status-warning);
  background: rgba(var(--status-warning-rgb), 0.1);
}

.system-card.checking .system-status {
  color: var(--status-warning);
}

.system-card.retrying {
  border-color: var(--status-warning);
  background: rgba(var(--status-warning-rgb), 0.1);
  animation: pulse-retry 2s infinite;
}

.system-card.retrying .system-status {
  color: var(--status-warning);
}

.system-card.waiting {
  border-color: var(--status-danger);
  background: rgba(var(--status-danger-rgb), 0.1);
  animation: pulse-wait 3s infinite;
}

.system-card.waiting .system-status {
  color: var(--status-danger);
}

.system-card.passed {
  border-color: #86efac;
  background: rgba(134, 239, 172, 0.10);
}

.system-card.passed .system-status {
  color: #86efac;
}

.system-card.failed {
  border-color: var(--status-danger);
  background: rgba(var(--status-danger-rgb), 0.1);
}

.system-card.failed .system-status {
  color: var(--status-danger);
}

.system-card.skipped {
  border-color: var(--text-muted);
  background: rgba(var(--text-rgb), 0.1);
}

.system-card.skipped .system-status {
  color: var(--text-muted);
}

/* Retry and waiting animations */
@keyframes pulse-retry {
  0%, 100% { 
    opacity: 1; 
  }
  50% { 
    opacity: 0.8; 
  }
}

@keyframes pulse-wait {
  0%, 100% { 
    opacity: 1; 
  }
  50% { 
    opacity: 0.7; 
  }
}

/* Command styling for tooltips and messages */
.command-box {
  background: var(--code-bg);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  border: 1px solid var(--border-strong);
  white-space: nowrap;
}

/* Actions */
.loading-actions {
  margin-bottom: 2rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  min-width: 120px;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(45deg, var(--accent), var(--accent-hover));
  color: var(--text-primary);
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(var(--text-rgb), 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(var(--text-rgb), 0.2);
}

.btn-secondary:hover {
  background: rgba(var(--text-rgb), 0.15);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon {
  font-size: 1.1rem;
}

/* Error Details */
.error-details {
  background: rgba(var(--status-danger-rgb), 0.1);
  border: 1px solid rgba(var(--status-danger-rgb), 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 0 auto 2rem auto; /* Push down from system cards, space before actions */
  max-width: 500px;
  text-align: left;
  animation: slideDown 0.3s ease-out;
}

.error-details h4 {
  margin: 0 0 1rem 0;
  color: var(--status-danger);
  font-size: 1.1rem;
}

.error-details ul {
  margin: 0;
  padding-left: 1.5rem;
  color: var(--status-danger);
}

.error-details li {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.error-details small {
  color: var(--status-danger);
  font-size: 0.85rem;
}

.error-details p {
  margin: 1rem 0 0 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Footer */
.loading-footer {
  margin-top: auto;
  padding-top: 2rem;
}

.loading-tips {
  background: rgba(var(--text-rgb), 0.05);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid rgba(var(--text-rgb), 0.1);
}

.loading-tips p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .loading-container {
    width: 95%;
    padding: 1rem;
  }
  
  .loading-logo h1 {
    font-size: 2.5rem;
  }
  
  .loading-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .btn {
    width: 100%;
    max-width: 250px;
  }
}

@media (max-width: 480px) {
  .loading-logo h1 {
    font-size: 2rem;
  }
  
  .loading-logo p {
    font-size: 1rem;
  }
  
  .loading-subtitle,
  #loading-status-text {
    font-size: 1rem;
  }
  
  .system-card {
    padding: 0.75rem;
  }
  
  .system-icon {
    width: 35px;
    height: 35px;
    font-size: 1.2rem;
  }
}

/* Custom scrollbar for error list */
.error-list-container::-webkit-scrollbar {
  width: 10px !important;
}

.error-list-container::-webkit-scrollbar-track {
  background: rgba(var(--text-rgb), 0.1) !important;
  border-radius: 4px !important;
}

.error-list-container::-webkit-scrollbar-thumb {
  background: rgba(var(--status-danger-rgb), 0.8) !important;
  border-radius: 4px !important;
  border: 1px solid rgba(var(--status-danger-rgb), 0.4) !important;
}

.error-list-container::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--status-danger-rgb), 1.0) !important;
}

/* Full page scrollbar for loading screen */
.loading-screen::-webkit-scrollbar {
  width: 12px;
}

.loading-screen::-webkit-scrollbar-track {
  background: rgba(var(--text-rgb), 0.05);
  border-radius: 6px;
}

.loading-screen::-webkit-scrollbar-thumb {
  background: rgba(var(--text-rgb), 0.2);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.loading-screen::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--text-rgb), 0.3);
  background-clip: content-box;
}

/* Error list container styling */
.error-list-container {
  max-height: 200px !important;
  overflow-y: auto !important;
  border: 1px solid var(--status-danger) !important;
  border-radius: 4px !important;
  padding: 10px !important;
  margin: 10px 0 !important;
  background: rgba(var(--status-danger-rgb), 0.1) !important;
}

.error-list-container ul {
  margin: 0 !important;
  padding-left: 20px !important;
}

.error-list-container li {
  margin-bottom: 8px !important;
}
