/* ============================================
   Advanced AI Reasoning Process v2.0
   Professional AI Inference Visualization
   ============================================ */

/* ★ 수정: 메인 추론 컨테이너 - 밝은 색상으로 변경 */
.reasoning-bubble {
  color: #1a1a1a;
  border: 1px solid rgba(52, 152, 219, 0.3);
  border-radius: 16px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  box-shadow:
    0 4px 12px rgba(52, 152, 219, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
  padding: 16px;
}

/* ★ 수정: 신경망 배경 애니메이션 - 부드러운 페이드 효과 */
.reasoning-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 30% 50%, rgba(52, 152, 219, 0.05) 0%, transparent 60%),
    radial-gradient(circle at 70% 50%, rgba(155, 89, 182, 0.05) 0%, transparent 60%);
  animation: gentle-pulse 4s ease-in-out infinite;
  opacity: 0;
}

/* 추론 헤더 - 더 전문적으로 */
.reasoning-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(100, 180, 255, 0.2);
}

.reasoning-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
  color: #1a1a1a;
}

/* ★ 수정: AI 모델 인디케이터 - 밝은 색상 */
.model-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(52, 152, 219, 0.1);
  border: 1px solid rgba(52, 152, 219, 0.3);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: #3498db;
}

.model-indicator .status-dot {
  width: 6px;
  height: 6px;
  background: #27ae60;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* ★ 수정: 메트릭 표시 - 밝은 배경 */
.reasoning-metrics {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px;
  background: rgba(52, 152, 219, 0.05);
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid rgba(52, 152, 219, 0.1);
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  color: #5a6c7d;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.metric-value {
  color: #3498db;
  font-weight: 600;
  font-family: Monaco, 'Courier New', monospace;
}

/* 추론 단계 컨테이너 */
.reasoning-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ★ 수정: 개별 추론 단계 - 밝고 깨끗한 디자인 */
.reasoning-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid rgba(52, 152, 219, 0.2);
  border-radius: 12px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  opacity: 1;
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.reasoning-step:hover {
  background: #ffffff;
  border-color: rgba(52, 152, 219, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(52, 152, 219, 0.12);
}

/* ★ 추가: 활성 상태 스타일 */
.reasoning-step.active {
  opacity: 1;
  transform: translateY(0);
}

/* ★ 새로 추가: 페이드아웃 애니메이션 */

/* ★ 새로 추가: 준비 중 상태 */
.reasoning-step.step-preparing {
  opacity: 0.3;
  transform: translateY(5px) scale(0.98);
  transition: all 0.3s ease;
}

.reasoning-step.fade-out {
  opacity: 0;
  transform: translateY(-15px) scale(0.9);
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  filter: blur(1px);
}

/* 단계 타입 인디케이터 */
.step-type {
  position: absolute;
  top: 8px;
  right: 12px;
  padding: 2px 8px;
  background: rgba(100, 180, 255, 0.15);
  border-radius: 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7da5c7;
}

/* 프로세스 아이콘 */
.step-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.step-icon.processing {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  animation: icon-rotate 3s linear infinite;
}

.step-icon.completed {
  background: linear-gradient(135deg, #00c853 0%, #64dd17 100%);
}

.step-icon.analyzing {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 단계 내용 */
.step-content {
  flex: 1;
}

.step-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 4px;
  color: #1a1a1a;
}

.step-description {
  font-size: 11px;
  color: #2c3e50;
  line-height: 1.5;
}

/* ★ 수정: 기술적 상세 정보 - 밝은 색상 */
.step-technical {
  margin-top: 4px;
  padding: 6px;
  background: rgba(236, 240, 241, 0.5);
  border-radius: 6px;
  font-family: Monaco, 'Courier New', monospace;
  font-size: 10px;
  color: #5a6c7d;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tech-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tech-label {
  color: #5a7a94;
}

.tech-value {
  color: #4fc3f7;
  font-weight: 600;
}

/* 확률/신뢰도 표시 */
.confidence-bar {
  margin-top: 8px;
  height: 4px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, #4fc3f7 0%, #00c853 100%);
  border-radius: 2px;
  transition: width 0.6s ease;
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.5);
}

/* 병렬 처리 표시 */
.parallel-processes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.parallel-item {
  padding: 8px;
  background: rgba(100, 180, 255, 0.05);
  border: 1px solid rgba(100, 180, 255, 0.2);
  border-radius: 6px;
  font-size: 11px;
}

.parallel-label {
  color: #7da5c7;
  font-size: 9px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.parallel-value {
  color: #3498db;
  font-weight: 600;
}

/* 추론 트리 구조 */
.reasoning-tree {
  margin: 16px 0;
  padding: 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
}

.tree-node {
  display: flex;
  align-items: center;
  margin-left: 20px;
  padding: 6px 0;
  position: relative;
}

.tree-node::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  width: 12px;
  height: 1px;
  background: rgba(100, 180, 255, 0.3);
}

.tree-node.root {
  margin-left: 0;
}

.tree-node.root::before {
  display: none;
}

.node-label {
  padding: 4px 10px;
  background: rgba(100, 180, 255, 0.1);
  border: 1px solid rgba(100, 180, 255, 0.2);
  border-radius: 4px;
  font-size: 11px;
  color: #a8c5db;
}

.node-probability {
  margin-left: 8px;
  padding: 2px 6px;
  background: rgba(0, 200, 83, 0.2);
  border-radius: 3px;
  font-size: 10px;
  color: #64dd17;
  font-weight: 600;
}

/* 로딩 애니메이션 */
.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.thinking-dot {
  width: 4px;
  height: 4px;
  background: #4fc3f7;
  border-radius: 50%;
  animation: thinking-bounce 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }

/* 상태 표시 */
.step-status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.status-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(100, 180, 255, 0.2);
  border-top-color: #4fc3f7;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.status-check {
  color: #00c853;
  font-size: 16px;
  animation: check-pop 0.3s ease;
}

/* AI 대화 표시 */
.ai-dialogue {
  margin: 12px 0;
  padding: 10px;
  background: rgba(100, 180, 255, 0.05);
  border-left: 3px solid rgba(100, 180, 255, 0.3);
  border-radius: 4px;
  font-size: 12px;
  font-style: italic;
  color: #a8c5db;
}

.dialogue-label {
  font-weight: 600;
  color: #4fc3f7;
  margin-right: 8px;
}

/* 에러/경고 표시 */
.reasoning-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 152, 0, 0.1);
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: 6px;
  font-size: 11px;
  color: #ffb74d;
  margin: 8px 0;
}

.warning-icon {
  font-size: 14px;
}

/* ★ 수정: 애니메이션 정의 - 부드럽고 자연스러운 전환 */
@keyframes gentle-pulse {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes neural-flow {
  0% { transform: translateX(0); }
  100% { transform: translateX(50%); }
}

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

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

@keyframes thinking-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes check-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .reasoning-bubble {
    padding: 14px;
  }
  
  .reasoning-metrics {
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .step-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .step-title {
    font-size: 12px;
  }
  
  .step-description {
    font-size: 11px;
  }
  
  .parallel-processes {
    grid-template-columns: 1fr;
  }
}

/* 다크 모드 최적화 */
@media (prefers-color-scheme: dark) {
  .reasoning-bubble {
    background: linear-gradient(135deg, #0a0f1a 0%, #050810 100%);
  }
}

/* 모션 감소 설정 */
@media (prefers-reduced-motion: reduce) {
  .reasoning-bubble::before,
  .thinking-dot,
  .status-spinner,
  .model-indicator .status-dot {
    animation: none !important;
  }

  .reasoning-step {
    transition: none !important;
  }
}

/* ============================================
   점 3개 애니메이션 (대기 메시지용)
   ============================================ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  white-space: nowrap;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--bg-secondary) 68%, rgba(106, 85, 255, 0.2) 32%),
    color-mix(in srgb, var(--bg-chat) 90%, rgba(106, 85, 255, 0.1) 10%)
  );
  border: 1px solid color-mix(in srgb, var(--primary-color) 28%, transparent 72%);
  box-shadow: 0 12px 28px rgba(var(--shadow-rgb), 0.12);
  backdrop-filter: blur(12px);
  background-size: 200% 200%;
  animation: waitingGlow 6s ease-in-out infinite;
}

.dots,
.waiting-dots {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  gap: 2px;
  color: color-mix(in srgb, var(--primary-color) 75%, var(--text-secondary) 25%);
}

.dots span,
.waiting-dots span {
  opacity: 0;
  display: inline-block;
  width: 0.55ch;
  font-weight: 600;
  text-shadow: 0 0 10px color-mix(in srgb, var(--primary-color) 52%, transparent 48%);
  transform-origin: center;
  animation: waitingDotPulse 1.6s ease-in-out infinite;
}

.dots span:nth-child(1),
.waiting-dots span:nth-child(1) {
  animation-delay: 0s;
}

.dots span:nth-child(2),
.waiting-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.dots span:nth-child(3),
.waiting-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

@media (prefers-reduced-motion: reduce) {
  .status {
    backdrop-filter: none;
    box-shadow: 0 6px 18px rgba(var(--shadow-rgb), 0.08);
    animation: none;
  }

  .dots span,
  .waiting-dots span {
    animation: none;
    opacity: 1;
    transform: none;
    text-shadow: none;
  }
}
