/* Card Manager Styles */
.card-manager {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  margin: 16px 0;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.card-manager.animating {
  transform: scale(1.02);
  box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-header {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.card-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: rotate(45deg);
  animation: shimmer 3s infinite;
}

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

.card-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title h3::before {
  content: '🤖';
  font-size: 20px;
}

.step-counter {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
  font-weight: 400;
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.history-button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.history-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.card-content {
  padding: 20px;
  background: white;
  min-height: 100px;
}

.step-item {
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(20px);
  animation: slideInUp 0.5s ease forwards;
}

.step-item.new-step {
  animation: slideInUp 0.5s ease forwards, highlightPulse 2s ease 0.5s;
}

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

@keyframes highlightPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.1);
  }
}

.card-footer {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #d1fae5;
}

.completion-message {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.new-query-button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.new-query-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* History Modal Styles */
.history-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

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

.history-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  animation: slideInModal 0.3s ease;
}

@keyframes slideInModal {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.history-header {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.history-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.clear-history-button,
.close-history-button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.clear-history-button:hover,
.close-history-button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.close-history-button {
  padding: 6px;
  font-size: 16px;
  line-height: 1;
}

.history-content {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.no-history {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 40px 20px;
}

.history-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  background: #f9fafb;
  transition: all 0.2s ease;
}

.history-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-card-title {
  font-weight: 600;
  color: #374151;
  font-size: 14px;
}

.history-card-meta {
  font-size: 12px;
  color: #6b7280;
}

.history-card-preview {
  margin-bottom: 12px;
}

.history-step-preview {
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 4px;
  padding-left: 8px;
  border-left: 2px solid #e5e7eb;
}

.history-step-more {
  font-size: 11px;
  color: #9ca3af;
  font-style: italic;
  padding-left: 8px;
  border-left: 2px solid #e5e7eb;
}

.restore-card-button {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.restore-card-button:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

/* In-Place Card Transitions */
.current-step-container {
  position: relative;
  overflow: hidden;
  min-height: 200px;
  transition: min-height 0.3s ease-in-out;
}

/* No container animation – instant switch */

.component-container.current-step {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
  position: relative;
  overflow: hidden;
}

/* Loading step with sliding border animation */
/* Shared loading border lives on the persistent container so it continues across swaps */
.current-step-container.loading-border::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #3b82f6, #06b6d4, transparent);
  animation: borderSlide 2.5s ease-in-out infinite;
  z-index: 1;
}

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

@keyframes borderSlideReverse {
  0% {
    right: -100%;
  }
  100% {
    right: 100%;
  }
}

/* No appear animation */

/* Non-current steps rendered only in reasoning list; no fade */
.component-container:not(.current-step) {}

/* Reasoning Process Collapse Animation */
.reasoning-section {
  transition: all 0.5s ease-in-out;
}

.reasoning-content {
  transition: max-height 0.5s ease-in-out, opacity 0.3s ease-in-out;
  overflow: hidden;
}

.reasoning-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.reasoning-content.expanded {
  max-height: 2000px;
  opacity: 1;
}

/* Step Fade Transitions */
.step-fade-enter {
  opacity: 0;
  transform: translateY(20px);
}

.step-fade-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.step-fade-exit {
  opacity: 1;
  transform: translateY(0);
}

.step-fade-exit-active {
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

/* Enhanced Card Hover Effects */
.component-container:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.component-container.current-step:hover {
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.2);
}

/* Smooth Loading Animation */
.loading-shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Responsive Design */
@media (max-width: 640px) {
  .card-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .card-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .history-modal {
    width: 95%;
    margin: 20px;
  }
  
  .card-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .new-query-button {
    width: 100%;
  }
  
  .current-step-container.loading-border::before,
  .current-step-container.loading-border::after {
    display: none;
  }
  
  .current-step-container {
    min-height: 150px;
  }
}
