/* Bootstrap System Styles */

/* Loading States */
.app-loading {
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.app-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  z-index: 1000;
}

/* Bootstrap Loading Indicator */
.bootstrap-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg-secondary);
  z-index: 10001;
  overflow: hidden;
}

.bootstrap-loader::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  height: 100%;
  width: 100%;
  background: var(--brand-gradient);
  animation: loading-progress 2s linear infinite;
}

@keyframes loading-progress {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Module Status Indicators */
.module-status {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
  z-index: 10000;
  max-width: 300px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.module-status.visible {
  opacity: 1;
  transform: translateY(0);
}

.module-status-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.module-status-item:last-child {
  margin-bottom: 0;
}

.module-status-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.module-status-icon.loading {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.module-status-icon.loaded {
  background: var(--success);
}

.module-status-icon.error {
  background: var(--error);
}

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

/* Error States */
.bootstrap-error {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--error);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 500px;
  width: 90vw;
  text-align: center;
  z-index: 10002;
  box-shadow: var(--shadow-lg);
}

.bootstrap-error-icon {
  font-size: 3rem;
  color: var(--error);
  margin-bottom: var(--space-md);
}

.bootstrap-error-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.bootstrap-error-message {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.bootstrap-error-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

.bootstrap-error-button {
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
}

.bootstrap-error-button:hover {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
}

.bootstrap-error-button.primary {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

.bootstrap-error-button.primary:hover {
  background: var(--brand-primary-dark);
}

/* Degraded Mode Styles */
.degraded-mode {
  position: relative;
}

.degraded-mode::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: repeating-linear-gradient(
    45deg,
    var(--warning),
    var(--warning) 10px,
    var(--warning-light) 10px,
    var(--warning-light) 20px
  );
  z-index: 10000;
  animation: degraded-warning 3s linear infinite;
}

@keyframes degraded-warning {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 40px 0;
  }
}

/* Fallback Styles */
.fallback-notice {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--warning);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 10001;
  max-width: 350px;
  box-shadow: var(--shadow-md);
  animation: slide-in-right 0.3s ease;
}

@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.fallback-notice-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  margin-left: var(--space-sm);
  padding: 0;
}

/* Retry Mechanism Styles */
.retry-indicator {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: var(--info);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  z-index: 10000;
  animation: bounce-in 0.3s ease;
}

@keyframes bounce-in {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Debug Panel Styles */
.debug-panel {
  position: fixed;
  top: 100px;
  right: 20px;
  width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-size: 0.75rem;
  z-index: 9999;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  font-family: monospace;
}

.debug-panel-header {
  font-weight: 600;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.debug-panel-section {
  margin-bottom: var(--space-sm);
}

.debug-panel-section-title {
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.debug-panel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  border-bottom: 1px dotted var(--border-light);
}

.debug-panel-status {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 500;
}

.debug-panel-status.loaded {
  background: var(--success-light);
  color: var(--success-dark);
}

.debug-panel-status.loading {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.debug-panel-status.error {
  background: var(--error-light);
  color: var(--error-dark);
}

/* Performance Metrics */
.performance-metrics {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--text-secondary);
  z-index: 9998;
  min-width: 200px;
  opacity: 0.8;
}

.performance-metrics:hover {
  opacity: 1;
}

.performance-metric {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

.performance-metric:last-child {
  margin-bottom: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .fallback-notice,
  .debug-panel,
  .module-status,
  .performance-metrics {
    position: fixed;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }
  
  .bootstrap-error {
    width: 95vw;
    padding: var(--space-lg);
  }
  
  .bootstrap-error-actions {
    flex-direction: column;
    gap: var(--space-sm);
  }
}

/* Dark Theme Support */
[data-theme="dark"] .app-loading::after {
  background: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .degraded-mode::before {
  opacity: 0.8;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .module-status-icon,
  .debug-panel-status {
    border: 1px solid currentColor;
  }
  
  .bootstrap-error {
    border-width: 2px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .bootstrap-loader::after,
  .module-status-icon.loading,
  .degraded-mode::before,
  .retry-indicator {
    animation: none;
  }
  
  .app-loading,
  .module-status,
  .fallback-notice,
  .bootstrap-error-button {
    transition: none;
  }
}