/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-in;
}

.loading-content {
  text-align: center;
  max-width: 400px;
  padding: 2rem;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #404040;
  border-top-color: #00d4ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

.loading-message {
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
}

.loading-progress {
  margin-top: 1.5rem;
}

.loading-progress-bar {
  width: 100%;
  height: 8px;
  background: #404040;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.loading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00d4ff, #00a8cc);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.loading-progress-text {
  color: #00d4ff;
  font-size: 0.9rem;
  font-weight: bold;
}

.loading-cancel-btn {
  margin-top: 1.5rem;
  background: transparent;
  border: 2px solid #666;
  color: #aaa;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 1rem;
}

.loading-cancel-btn:hover {
  border-color: #00d4ff;
  color: #00d4ff;
}

/* Error Overlay */
.error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-in;
}

.error-content {
  background: #2d2d2d;
  border-radius: 12px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  border: 2px solid #ff6b6b;
  text-align: center;
  animation: slideUp 0.3s ease-out;
}

.error-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.error-title {
  color: #ff6b6b;
  font-size: 1.5rem;
  margin: 0 0 1rem 0;
}

.error-message {
  color: #ccc;
  font-size: 1rem;
  margin: 0 0 1.5rem 0;
  line-height: 1.5;
}

.error-details {
  margin: 1.5rem 0;
  text-align: left;
  background: #1a1a1a;
  border-radius: 4px;
  padding: 1rem;
}

.error-details summary {
  color: #00d4ff;
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.error-details summary:hover {
  text-decoration: underline;
}

.error-details pre {
  color: #aaa;
  font-size: 0.8rem;
  overflow-x: auto;
  margin: 0.5rem 0 0 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.error-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.error-action-btn {
  background: #404040;
  border: 2px solid #666;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 1rem;
  font-weight: 500;
}

.error-action-btn:hover {
  background: #555;
  border-color: #888;
  transform: translateY(-2px);
}

.error-action-btn.primary {
  background: #00d4ff;
  border-color: #00d4ff;
  color: #000;
}

.error-action-btn.primary:hover {
  background: #00a8cc;
  border-color: #00a8cc;
}

/* Page Loading Indicator */
.page-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.page-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #404040;
  border-top-color: #00d4ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.page-loading-text {
  color: #aaa;
  font-size: 0.9rem;
}

/* Inline Loading (for library cards, etc) */
.inline-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #aaa;
  font-size: 0.9rem;
}

.inline-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #404040;
  border-top-color: #00d4ff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Toast notifications (smaller, auto-hide errors) */
.error-overlay .error-content {
  animation: slideUp 0.3s ease-out;
}

.error-overlay.toast .error-content {
  max-width: 300px;
  padding: 1rem;
  border: none;
  background: #1a1a1a;
}

.error-overlay.toast .error-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.error-overlay.toast .error-message {
  font-size: 0.9rem;
  margin: 0;
}

/* Responsive */
@media (max-width: 600px) {
  .loading-content,
  .error-content {
    width: 95%;
    padding: 1.5rem;
  }

  .error-title {
    font-size: 1.2rem;
  }

  .error-actions {
    flex-direction: column;
  }

  .error-action-btn {
    width: 100%;
  }
}
