/* AI 챗봇 스타일 */
.ai-chat-floating-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--hero-purple) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  transition: var(--transition-smooth);
  z-index: 9999;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.ai-chat-floating-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.ai-chat-floating-btn:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 4px;
}

.ai-chat-icon {
  width: 28px;
  height: 28px;
  color: white;
}

.ai-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 2rem;
  width: 400px;
  max-height: 600px;
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.ai-chat-header {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--hero-purple) 100%);
  display: flex;
  flex-shrink: 0; /* 헤더가 줄어들지 않도록 */
  justify-content: space-between;
  align-items: center;
  border-radius: 16px 16px 0 0;
}

.ai-chat-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

.ai-chat-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-base);
}

.ai-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-chat-close-icon {
  width: 18px;
  height: 18px;
  color: white;
}

/* 워크플로우 섹션 */
.ai-workflow-section {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-light);
  flex-shrink: 0; /* 워크플로우 영역이 줄어들지 않도록 */
}

.ai-workflow-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ai-workflow-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-workflow-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-base);
  color: var(--text-gray);
}

.ai-workflow-toggle-btn:hover {
  color: var(--primary-blue);
}

.ai-toggle-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.ai-workflow-toggle-btn.collapsed .ai-toggle-icon {
  transform: rotate(-90deg);
}

.ai-workflow-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.ai-workflow-list::-webkit-scrollbar {
  width: 4px;
}

.ai-workflow-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.ai-workflow-btn {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  transition: var(--transition-base);
  text-align: left;
}

.ai-workflow-btn:hover {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
}

.ai-workflow-empty {
  font-size: 0.85rem;
  color: var(--text-gray);
  text-align: center;
  padding: 1rem;
}

/* 메시지 리스트 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2.0rem;
  background: var(--bg-white);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 200px;
  max-height: 400px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 6px;
}

.ai-message-bot,
.ai-message-user {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  animation: fadeInUp 0.3s ease;
}

.ai-message-user {
  flex-direction: row-reverse;
}

.ai-message-bubble {
  max-width: 75%;
  padding: 0.875rem 1.125rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px var(--shadow-light);
}

.ai-message-bot .ai-message-bubble {
  background: #f5f5f5;
  color: var(--text-dark);
  border-radius: 12px 12px 12px 2px;
}

.ai-message-user .ai-message-bubble {
  background: var(--bg-light);
  color: var(--text-dark);
  border-radius: 12px 12px 2px 12px;
}

.ai-message-text {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
  word-wrap: break-word;
}

/* 로딩 스피너 */
.ai-chat-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-light);
  border-top: 1px solid var(--border-light);
}

.ai-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.ai-loading-text {
  font-size: 0.85rem;
  color: var(--text-gray);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 에러 토스트 */
.ai-chat-error {
  position: absolute;
  top: 80px;
  left: 1rem;
  right: 1rem;
  background: #f44336;
  color: white;
  padding: 0.875rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
  animation: slideDown 0.3s ease;
  z-index: 10;
}

.ai-error-text {
  font-size: 0.85rem;
  font-weight: 500;
  flex: 1;
}

.ai-error-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.ai-error-close:hover {
  opacity: 1;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 단계 진행 UI */
.ai-step-section {
  padding: 0.5rem 1rem;
  background: var(--bg-light);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0; /* 버튼 영역이 줄어들지 않도록 */
}

.ai-step-header {
  display: none; /* 계층 구조에서는 사용하지 않음 */
}

.ai-step-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
}

.ai-step-counter {
  font-size: 0.85rem;
  color: var(--text-gray);
  background: var(--bg-white);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border-light);
}

.ai-step-actions {
  display: none; /* 계층 구조에서는 사용하지 않음 */
}

.ai-step-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.ai-step-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-base);
  border: none;
}

.ai-step-btn-primary {
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--hero-purple) 100%);
  color: white;
  width: 100%;
}

.ai-step-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-step-btn-secondary {
  background: var(--bg-white);
  color: var(--text-dark);
  border: 1px solid var(--border-light);
}

.ai-step-btn-secondary:hover {
  background: var(--bg-gray);
}

.ai-step-btn-cancel {
  background: var(--bg-white);
  color: var(--text-gray);
  border: 1px solid var(--border-light);
}

.ai-step-btn-cancel:hover {
  background: #f44336;
  color: white;
  border-color: #f44336;
}

.ai-step-btn-success {
  background: var(--primary-green);
  color: white;
  width: 100%;
}

.ai-step-btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 200, 81, 0.3);
}

/* 입력창 */
.ai-chat-input-section {
  padding: 1rem 1.5rem;
  background: var(--bg-white);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0; /* 입력창이 줄어들지 않도록 */
}

.ai-input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-chat-input {
  flex: 1;
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-dark);
  transition: var(--transition-base);
}

.ai-chat-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.ai-chat-input::placeholder {
  color: var(--text-gray);
  opacity: 0.6;
}

.ai-chat-send-btn {
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--hero-purple) 100%);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-base);
  flex-shrink: 0;
}

.ai-chat-send-btn:hover {
  transform: scale(1.1);
}

.ai-send-icon {
  width: 18px;
  height: 18px;
  color: white;
}

/* 반응형 디자인 - 태블릿 */
@media (max-width: 768px) {
  .ai-chat-floating-btn {
    width: 52px;
    height: 52px;
    bottom: 1.25rem;
    right: 1.25rem;
  }

  .ai-chat-icon {
    width: 24px;
    height: 24px;
  }

  .ai-chat-header {
    padding: 1rem;
  }

  .ai-chat-title {
    font-size: 1rem;
  }

  .ai-workflow-section {
    padding: 0.875rem 1rem;
  }

  .ai-chat-messages {
    padding: 1rem;
    min-height: 150px;
    max-height: 250px;
  }

  .ai-message-bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
  }

  .ai-message-text {
    font-size: 0.85rem;
  }

  .ai-step-section {
    padding: 0.875rem 1rem;
  }

  .ai-chat-input-section {
    padding: 0.875rem 1rem;
  }

  .ai-chat-input {
    padding: 0.625rem 1rem;
    font-size: 0.85rem;
  }

  .ai-chat-send-btn {
    width: 36px;
    height: 36px;
  }

  .ai-send-icon {
    width: 16px;
    height: 16px;
  }
}

/* 반응형 디자인 - 모바일 */
@media (max-width: 480px) {
  .ai-chat-panel {
    width: 90%;
    right: 5%;
    bottom: 80px;
  }
}
