/*!
 * PiG Agent Widget — Standalone CSS
 * Sources: _chatbot.scss, _chat.scss, _pig.scss, _shame.scss,
 *          _buttons.scss, _position.scss, _outputs.scss, _themes.scss
 *
 * [충돌 방지 전략]
 *   모든 유틸리티 클래스는 위젯 루트 ID (#chatbotPanelWidget, #btnSupportFloating)
 *   하위로 스코프 제한.
 *   - 아웃바운드 방지: 우리 .btn-slim 등이 호스트 페이지 요소에 영향 없음
 *   - 인바운드 방어: ID 특이도(1,1,0)가 호스트 단순 클래스(0,1,0)보다 높음
 *   CSS 변수는 :root 대신 루트 요소에 직접 선언 → 전역 오염 없음
 *
 * Resolved SCSS variables:
 *   $border-radius-xl / lg / md / sm → 1rem / 8px / 6px / 4px
 *   $font-weight-normal / medium     → 400 / 500
 *   $font-size-base / sm / xs / xl   → 1rem / 0.9rem / 0.8rem / 1.5rem
 *   $line-height-base / sm           → 1.7 / 1.5
 *   $icon-btn-width                  → 32px
 */


/* ============================================================
   1. CSS Custom Properties
      :root 대신 위젯 루트 요소에 직접 선언 → 전역 오염 없음
   ============================================================ */

/* Light theme */
#chatbotPanelWidget,
#btnSupportFloating {
  --pig-color-text: #212529;
  --pig-color-subtext: #6c757d;
  --pig-color-bg: #ffffff;
  --pig-color-border: #e7e7e7;
  --pig-color-border-thick: #d0d0d0;
  --pig-color-border-subtle: #e9ecef;
  --pig-color-bg-lighter: #f1f1ef;
  --pig-color-bg-subtle: #f8f9fa;
  --pig-color-hover-bg: #ffffff;
  --pig-color-hover-bg-subtle: #f0f2f4;
  --pig-color-bg-overlay: rgba(255, 255, 255, 0.95);
  --pig-color-primary: #1e1d2f;
  --pig-color-primary-rgb: 30, 29, 47;
  --pig-color-text-muted: #adb5bd;
}

/* Dark theme */
html[data-theme="dark"] #chatbotPanelWidget,
html[data-theme="dark"] #btnSupportFloating {
  --pig-color-text: #e1e1e1;
  --pig-color-subtext: #a1a1a1;
  --pig-color-bg: #131314;
  --pig-color-border: #3e3e42;
  --pig-color-border-thick: #3e3e42;
  --pig-color-border-subtle: #3e3e42;
  --pig-color-bg-lighter: #222221;
  --pig-color-bg-subtle: #252526;
  --pig-color-hover-bg: #3a3a3a;
  --pig-color-hover-bg-subtle: #3e3e42;
  --pig-color-bg-overlay: transparent;
  --pig-color-primary: #f0f0ea;
  --pig-color-primary-rgb: 240, 240, 234;
  --pig-color-text-muted: #888888;
}


/* ============================================================
   2. Keyframes
      이름 앞에 pig- 접두사 → 호스트 @keyframes 이름 충돌 방지
   ============================================================ */

@keyframes pig-bubble-float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes pig-agent-breath {

  0%,
  100% {
    transform: translateY(var(--breath-y-0, 0)) scale(var(--breath-scale-0, 1));
  }

  50% {
    transform: translateY(var(--breath-y-50, -3px)) scale(var(--breath-scale-50, 1.03));
  }
}

@keyframes pig-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pig-message-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(10px) translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes pig-message-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-10px) translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes pig-dots {

  0%,
  20% {
    content: '.';
  }

  40% {
    content: '..';
  }

  60%,
  100% {
    content: '...';
  }
}

@keyframes pig-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes pig-blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

@keyframes pig-typing-dot {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}


/* ============================================================
   3. Utility classes — ID 스코프 적용
      #chatbotPanelWidget 하위로 제한 → 호스트 페이지 오염 없음
   ============================================================ */

/* 3-0. Bootstrap 대체 레이아웃 유틸리티
   외부 프로젝트에 Bootstrap이 없을 경우를 대비해 위젯 내부에서만 적용 */
#chatbotPanelWidget .d-flex {
  display: flex;
}

#chatbotPanelWidget .align-items-center {
  align-items: center;
}

#chatbotPanelWidget .gap-0 {
  gap: 0;
}

/* 3-1. btn-no-deco */
#chatbotPanelWidget .btn-no-deco {
  background: none;
  border: none;
  padding: 0;
  outline: none;
  box-shadow: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}

#chatbotPanelWidget .btn-no-deco:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* 3-2. btn-slim (전송 버튼) */
#chatbotPanelWidget .btn-slim {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  border-radius: 20%;
  padding: 5px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#chatbotPanelWidget .btn-slim:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#chatbotPanelWidget .btn-slim:disabled:hover,
#chatbotPanelWidget .btn-slim:disabled:focus {
  background-color: transparent !important;
}

#chatbotPanelWidget .btn-slim:hover,
#chatbotPanelWidget .btn-slim:focus {
  background-color: var(--pig-color-hover-bg);
}

#chatbotPanelWidget .btn-slim.active {
  background-color: var(--pig-color-hover-bg);
}

#chatbotPanelWidget .btn-slim svg {
  width: 24px;
  height: 24px;
}

/* Lucide: stroke="currentColor" → color 상속으로 자동 테마 적용 */
#chatbotPanelWidget .btn-slim svg.lucide {
  width: 19px;
  height: 19px;
}

/* fontawesome path(fill 기반): 테마별 명시 */
#chatbotPanelWidget .btn-slim svg.fontawesome {
  fill: var(--pig-color-text);
}

#chatbotPanelWidget .btn-slim.active svg.fontawesome {
  fill: var(--pig-color-text);
}

/* 3-3. action-icon-btn (헤더 eraser · minus 버튼) */
#chatbotPanelWidget .action-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: none;
  cursor: pointer;
  border-radius: 8px;
  background-color: var(--pig-color-bg-overlay);
  color: var(--pig-color-text);
  /* Lucide SVG stroke 상속 */
  transition: all 0.2s ease;
  position: relative;
}

#chatbotPanelWidget .action-icon-btn:hover {
  background-color: var(--pig-color-bg-lighter);
}

#chatbotPanelWidget .action-icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* 3-4. icon-18 */
#chatbotPanelWidget .icon-18 {
  width: 18px;
  height: 18px;
}

#chatbotPanelWidget .icon-18 svg {
  width: 100%;
  height: 100%;
}

/* 3-5. flex-center */
#chatbotPanelWidget .flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ============================================================
   4. Markdown content — ID 스코프 적용
      (_outputs.scss 기반)
   ============================================================ */

#chatbotPanelWidget .markdown-content {
  line-height: 1.7;
  font-size: 1rem;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content strong {
  font-weight: 500;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content h1 {
  font-size: 1.75rem;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content h2 {
  font-size: 1.5rem;
  line-height: 1.35;
  margin-bottom: 0.75rem;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content h3 {
  font-size: 1.25rem;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content h4 {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content h5 {
  font-size: 1rem;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content p {
  margin: 0.25rem 0;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content ul,
#chatbotPanelWidget .markdown-content ol {
  margin: 0.5rem 0 1rem;
  padding-inline-start: 1.6875rem;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content li {
  margin: 0.5rem 0;
}

#chatbotPanelWidget .markdown-content code {
  background-color: var(--pig-color-bg-subtle);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-weight: 400;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content pre {
  background-color: var(--pig-color-bg-subtle);
  padding: 0.75rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}

#chatbotPanelWidget .markdown-content pre code {
  background: transparent;
  padding: 0;
}

#chatbotPanelWidget .markdown-content hr {
  width: 100%;
  border-top: 1px solid var(--pig-color-border);
  margin: 1rem 0;
}

#chatbotPanelWidget .markdown-content blockquote {
  min-height: 22px;
  margin: 0.5rem 0;
  padding: 0 1rem;
  font-size: 1rem;
  border-left: 3px solid var(--pig-color-text);
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content table {
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  width: 100%;
}

#chatbotPanelWidget .markdown-content table th,
#chatbotPanelWidget .markdown-content table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--pig-color-border-subtle);
  vertical-align: top;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .markdown-content table th {
  font-weight: 500;
  background-color: var(--pig-color-bg-lighter);
}

#chatbotPanelWidget .markdown-content table tbody tr:nth-child(even) {
  background-color: var(--pig-color-bg-lighter);
}

#chatbotPanelWidget .markdown-content table p {
  margin: 0;
}

#chatbotPanelWidget .markdown-content em {
  font-style: italic;
}

#chatbotPanelWidget .markdown-content del {
  text-decoration: line-through;
  opacity: 0.7;
}

#chatbotPanelWidget .markdown-content a {
  color: var(--pig-color-primary, #4f6ef7);
  text-decoration: none;
}

#chatbotPanelWidget .markdown-content a:hover {
  text-decoration: underline;
}

#chatbotPanelWidget .markdown-content img {
  max-width: 100%;
  border-radius: 0.5rem;
}


/* ============================================================
   5. Chatbot Panel  (_chatbot.scss)
   ============================================================ */

.chatbot-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* --- Widget 모드 --- */

.chatbot-panel.widget {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  z-index: -1;
  position: fixed;
  top: 50%;
  right: 20px;
  width: 620px;
  height: 620px;
  border: 1px solid var(--pig-color-border-thick);
  box-shadow: 1px 1px 11px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  transform: translateY(-50%);
  min-width: 320px;
  min-height: 600px;
  max-width: 80vw;
  max-height: 90vh;
  background-color: var(--pig-color-bg);
  overflow: hidden;
}

.chatbot-panel.widget.active {
  opacity: 1;
  z-index: 1050;
}

.chatbot-panel.widget.dragging {
  user-select: none;
  transition: none;
}

.chatbot-panel.widget .chatbot-header {
  cursor: move;
  user-select: none;
}

/* --- Header --- */

.chatbot-panel .chatbot-header {
  padding: 10px 12px 10px 20px;
  border-bottom: 1px solid var(--pig-color-border);
  background: var(--pig-color-bg);
  border-radius: 1rem 1rem 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chatbot-panel .chatbot-header .chatbot-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--pig-color-text);
}

/* --- Body --- */

.chatbot-panel .chatbot-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.chatbot-panel .chatbot-body .chatbot-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* --- Messages --- */

.chatbot-panel .chatbot-messages {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1rem;
  align-items: flex-start;
  width: 100%;
  box-sizing: border-box;
  flex-grow: 1;
  container-type: inline-size;
  container-name: pig-messages-container;
}

/* Welcome / Empty State */

.chatbot-panel .chatbot-messages .welcome-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chatbot-panel .chatbot-messages .welcome-content .empty-state-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  gap: 10px;
  animation: pig-fade-in-up 0.6s ease-out both;
}

.chatbot-panel .chatbot-messages .welcome-content .empty-state-view .agent-welcome-bubble {
  position: relative;
  background: var(--pig-color-bg);
  border: 1px solid var(--pig-color-border);
  padding: 16px 24px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  font-size: 15px;
  line-height: 1.6;
  color: var(--pig-color-text);
  margin-bottom: 5px;
  animation: pig-bubble-float 3s ease-in-out infinite;
}

.chatbot-panel .chatbot-messages .welcome-content .empty-state-view .agent-welcome-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--pig-color-border);
}

.chatbot-panel .chatbot-messages .welcome-content .empty-state-view .agent-welcome-bubble::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 9px solid var(--pig-color-bg);
  z-index: 1;
}

.chatbot-panel .chatbot-messages .welcome-content .empty-state-view .agent-stand-graphic {
  width: 180px;
  height: 200px;
  background-image: url('/images/stand/idle.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center bottom;
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.08));
  animation: pig-agent-breath 3s ease-in-out infinite;
}

/* --- Messages (user / assistant) — ID 스코프로 .message 충돌 방지 --- */

#chatbotPanelWidget .message {
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  margin-bottom: 12px;
  width: fit-content;
  font-size: 1rem;
  color: var(--pig-color-text);
}

#chatbotPanelWidget .message p {
  margin: 0;
}

#chatbotPanelWidget .message.user {
  max-width: 75%;
  padding: 12px 16px;
  margin-left: auto;
  margin-right: 6px;
  background-color: var(--pig-color-bg-lighter);
  color: var(--pig-color-text);
  border-radius: 20px 0 20px 20px;
  animation: pig-message-slide-in-right 0.25s cubic-bezier(0.2, 0, 0.2, 1) both;
}

#chatbotPanelWidget .message.assistant {
  position: relative;
  top: 3px;
  line-height: 1.5;
  color: var(--pig-color-text);
}

/* --- Typing indicator --- */

.chatbot-panel .typing-indicator {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--pig-color-bg-subtle);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  font-style: italic;
  color: var(--pig-color-subtext);
  font-size: 14px;
  margin-bottom: 12px;
}

.chatbot-panel .typing-indicator .dots {
  display: inline-block;
}

.chatbot-panel .typing-indicator .dots::after {
  content: '';
  animation: pig-dots 1.4s infinite;
}

/* --- Loading message (appendAILoadingMessage에서 생성) --- */

#chatbotPanelWidget .message.loading-message {
  padding: 10px 16px;
  background-color: transparent;
  border-radius: 0;
  margin-bottom: 0;
  width: auto;
}

#chatbotPanelWidget .typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

#chatbotPanelWidget .typing-dots span {
  width: 8px;
  height: 8px;
  background-color: var(--pig-color-subtext);
  border-radius: 50%;
  display: inline-block;
  animation: pig-typing-dot 1.4s infinite ease-in-out;
}

#chatbotPanelWidget .typing-dots span:nth-child(1) {
  animation-delay: 0s;
}

#chatbotPanelWidget .typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

#chatbotPanelWidget .typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* --- Input area --- */

.chatbot-panel .chatbot-input {
  padding: 0 10px 10px;
  border-bottom-left-radius: 1rem;
  border-bottom-right-radius: 1rem;
  position: relative;
  z-index: 1;
}

.chatbot-panel .chatbot-input .chatbot-input-wrapper {
  position: relative;
  border-radius: 24px;
  background-color: var(--pig-color-bg-lighter);
}

.chatbot-panel .chatbot-input .chatbot-input-wrapper .chatbot-textarea {
  width: 100%;
  resize: none;
  border: 0;
  padding: 12px 20px 0;
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', '돋움', Dotum, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  min-height: 2rem;
  max-height: 150px;
  overflow-y: auto;
  background-color: transparent;
  color: var(--pig-color-text);
  field-sizing: content;
}

.chatbot-panel .chatbot-input .chatbot-input-wrapper .chatbot-textarea::placeholder {
  color: var(--pig-color-subtext);
  opacity: 0.7;
}

.chatbot-panel .chatbot-input .chatbot-input-wrapper .chatbot-textarea:focus {
  outline: none;
}

.chatbot-panel .chatbot-input .chatbot-footer {
  padding: 12px 14px;
  display: flex;
  justify-content: flex-end;
}

/* --- Resize handle --- */

.chatbot-panel .chatbot-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.chatbot-panel .chatbot-resize-handle::before {
  content: '';
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  background-image:
    radial-gradient(circle at 2px 2px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 6px 2px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 2px 6px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 10px 2px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 6px 6px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 2px 10px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 10px 6px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 6px 10px, var(--pig-color-subtext) 1px, transparent 1px),
    radial-gradient(circle at 10px 10px, var(--pig-color-subtext) 1px, transparent 1px);
  background-size: 12px 12px;
}

.chatbot-panel .chatbot-resize-handle:hover {
  opacity: 1;
}

.chatbot-panel .chatbot-resize-handle:hover::before {
  background-image:
    radial-gradient(circle at 2px 2px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 6px 2px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 2px 6px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 10px 2px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 6px 6px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 2px 10px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 10px 6px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 6px 10px, var(--pig-color-text) 1px, transparent 1px),
    radial-gradient(circle at 10px 10px, var(--pig-color-text) 1px, transparent 1px);
}

/* --- AI thumbnail + message wrap --- */

.chatbot-panel .ai-thumbnail {
  width: 60px;
  height: 60px;
  background-image: url('/images/figure/idle.png');
  background-size: contain;
  background-position: top;
  background-repeat: no-repeat;
  flex: 0 0 60px;
}

.chatbot-panel .message-assistant-wrap {
  display: flex;
  align-items: flex-start;
  max-width: 85%;
  gap: 6px;
  padding: 20px 0;
  animation: pig-message-slide-in-left 0.25s cubic-bezier(0.2, 0, 0.2, 1) both;
}

.chatbot-panel .message-assistant-wrap .service-name {
  animation: pig-message-slide-in-left 0.25s cubic-bezier(0.2, 0, 0.2, 1) both;
}

/* --- Streaming status --- */

.chatbot-panel .chat-message.streaming-status .status-content {
  background-color: var(--pig-color-hover-bg-subtle);
  border-radius: 12px;
  padding: 16px 20px;
}

.chatbot-panel .chat-message.streaming-status .status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--pig-color-text);
}

.chatbot-panel .chat-message.streaming-status .status-icon {
  width: 20px;
  height: 20px;
  color: var(--pig-color-primary);
  flex-shrink: 0;
}

.chatbot-panel .chat-message.streaming-status .status-icon.spinning {
  animation: pig-spin 1s linear infinite;
}

.chatbot-panel .chat-message.streaming-status .status-text {
  font-size: 0.9rem;
  color: var(--pig-color-subtext);
}

/* streaming 커서 */
.chatbot-panel .chat-message.assistant.streaming .markdown-content::after {
  content: '|';
  animation: pig-blink 1s step-end infinite;
  color: var(--pig-color-primary);
  font-weight: bold;
}

/* --- Suggested questions --- */

.chatbot-panel .suggested-questions {
  margin-top: 12px;
  padding: 12px 16px;
  background-color: var(--pig-color-hover-bg-subtle);
  border-radius: 12px;
  width: fit-content;
  max-width: 80%;
}

.chatbot-panel .suggested-questions .suggest-label {
  font-size: 0.75rem;
  color: var(--pig-color-subtext);
  margin-bottom: 8px;
}

.chatbot-panel .suggested-questions .suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chatbot-panel .suggested-questions .suggest-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background-color: var(--pig-color-bg);
  border: 1px solid var(--pig-color-border);
  border-radius: 16px;
  font-size: 0.8rem;
  color: var(--pig-color-text);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-panel .suggested-questions .suggest-chip:hover {
  background-color: var(--pig-color-primary);
  color: var(--pig-color-bg);
  border-color: var(--pig-color-primary);
}

.chatbot-panel .suggested-questions .suggest-chip:active {
  transform: scale(0.98);
}

/* --- Source badge --- */

.chatbot-panel .source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  margin: 0 2px;
  background-color: var(--pig-color-hover-bg-subtle);
  border: 1px solid var(--pig-color-border);
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--pig-color-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  vertical-align: middle;
}

.chatbot-panel .source-badge:hover {
  background-color: var(--pig-color-primary);
  color: var(--pig-color-bg);
  border-color: var(--pig-color-primary);
}

.chatbot-panel .source-badge:hover .source-icon {
  color: var(--pig-color-bg);
}

.chatbot-panel .source-badge .source-icon {
  width: 12px;
  height: 12px;
  color: var(--pig-color-primary);
  flex-shrink: 0;
}

.chatbot-panel .source-badge .source-text {
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Error message --- */

.chatbot-panel .chat-message.error .error-content {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 16px;
}

html[data-theme="dark"] .chatbot-panel .chat-message.error .error-content {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.chatbot-panel .chat-message.error .error-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.chatbot-panel .chat-message.error .error-icon {
  color: #ef4444;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.chatbot-panel .chat-message.error .error-text {
  font-weight: 500;
  color: #dc2626;
}

html[data-theme="dark"] .chatbot-panel .chat-message.error .error-text {
  color: #f87171;
}

.chatbot-panel .chat-message.error .error-detail {
  font-size: 0.875rem;
  color: var(--pig-color-subtext);
  margin-bottom: 12px;
  word-break: break-word;
}

.chatbot-panel .chat-message.error .js-retry-message {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
}

.chatbot-panel .chat-message.error .js-retry-message svg {
  width: 14px;
  height: 14px;
}

/* --- Scout result --- */

.chatbot-panel .scout-result {
  margin-top: 12px;
  padding: 16px;
  background-color: var(--pig-color-hover-bg-subtle);
  border-radius: 12px;
}

.chatbot-panel .scout-result .scout-header {
  font-size: 0.9rem;
  color: var(--pig-color-text);
  margin-bottom: 12px;
  font-weight: 500;
}

.chatbot-panel .scout-result .scout-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--pig-color-border);
}

.chatbot-panel .scout-result .scout-item:last-child {
  border-bottom: none;
}

.chatbot-panel .scout-result .scout-item .scout-project-name {
  flex: 1;
  font-size: 0.875rem;
  color: var(--pig-color-text);
}

.chatbot-panel .scout-result .scout-item .scout-count {
  font-size: 0.75rem;
  color: var(--pig-color-primary);
  background-color: rgba(var(--pig-color-primary-rgb), 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* --- PiG action link --- */

.chatbot-panel .pig-action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  margin: 4px 2px;
  background-color: var(--pig-color-bg);
  border: 1px solid var(--pig-color-primary);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--pig-color-primary);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chatbot-panel .pig-action-link:hover {
  background-color: var(--pig-color-primary);
  color: var(--pig-color-bg);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(var(--pig-color-primary-rgb), 0.3);
}

.chatbot-panel .pig-action-link:active {
  transform: translateY(0);
  box-shadow: none;
}

.chatbot-panel .pig-action-link::after {
  content: '→';
  font-weight: bold;
}

/* --- Scout no result --- */

.chatbot-panel .scout-no-result {
  padding: 16px;
  text-align: center;
  color: var(--pig-color-subtext);
  font-size: 0.875rem;
  background-color: var(--pig-color-hover-bg-subtle);
  border-radius: 12px;
  margin-top: 12px;
}

.chatbot-panel .scout-no-result .scout-no-result-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

/* --- Container query --- */

@container pig-messages-container (max-width: 380px) {
  .message-assistant-wrap {
    max-width: 100%;
  }
}


/* ============================================================
   6. PiG Blob Background  (_chatbot.scss)
   ============================================================ */

.pig-blob-bg {
  position: absolute;
  bottom: -57%;
  left: -50%;
  transform: translate(25%, -5%);
  width: 110%;
  height: 150%;
  border-radius: 12px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
  transition: opacity 1.2s ease-in-out;
}

.pig-blob-bg.is-welcome,
.pig-blob-bg.is-responding {
  opacity: 0.5;
}

.pig-blob-bg svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  overflow: visible;
}

/* 패널 활성화 시 플로팅 버튼 숨김 */
.chatbot-panel.widget.active~#btnSupportFloating {
  opacity: 0 !important;
  pointer-events: none !important;
}


/* ============================================================
   7. Floating Button — ID 기반으로 직접 스코프
      #btnSupportFloating 이 곧 .floating-actions 요소임
      (_chat.scss 기반)
   ============================================================ */

#btnSupportFloating {
  position: fixed;
  bottom: 40px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  transition: right 0.3s ease, bottom 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

#btnSupportFloating.dragging {
  z-index: 9999;
  opacity: 0.8;
  transform: scale(1.1);
  transition: none !important;
}

#btnSupportFloating.dragging .floating-action-btn {
  animation: none !important;
  opacity: 1 !important;
}

#btnSupportFloating .drag-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 22px;
  height: 22px;
  background-color: var(--pig-color-bg-subtle);
  border: 1px solid var(--pig-color-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  font-size: 10px;
  color: var(--pig-color-text-muted);
  z-index: 1;
}

#btnSupportFloating .drag-handle:hover {
  background-color: var(--pig-color-bg-lighter);
  color: var(--pig-color-text);
}

/* btn-support 기본 골격 */
#btnSupportFloating .floating-action-btn {
  width: 60px;
  height: 60px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* PNG 이미지 기반 캐릭터 버튼:
   CSS fill/stroke 불가 → 다크모드에서 brightness 보정으로 대응 */
#btnSupportFloating .floating-action-btn.btn-support {
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 120px;
  height: 140px;
  opacity: 1;
  position: relative;
  overflow: hidden;
  background-color: transparent;
  animation: pig-agent-breath 3s ease-in-out infinite;
  --idle-opacity: 1;
}

html[data-theme="dark"] #btnSupportFloating .floating-action-btn.btn-support {
  filter: brightness(0.9) contrast(1.05);
}

#btnSupportFloating .floating-action-btn.btn-support:hover,
#btnSupportFloating .floating-action-btn.btn-support.active {
  --breath-y-0: -4px;
  --breath-scale-0: 1.04;
  --breath-y-50: -10px;
  --breath-scale-50: 1.09;
  --expression-opacity: 1;
  --idle-opacity: 0;
}

html[data-theme="dark"] #btnSupportFloating .floating-action-btn.btn-support:hover,
html[data-theme="dark"] #btnSupportFloating .floating-action-btn.btn-support.active {
  filter: brightness(1.0) contrast(1.05);
}

#btnSupportFloating .floating-action-btn.btn-support::before,
#btnSupportFloating .floating-action-btn.btn-support::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 0.3s ease-in-out;
  pointer-events: none;
}

/* idle 레이어 */
#btnSupportFloating .floating-action-btn.btn-support::before {
  background-image: url('/images/stand/idle.png');
  opacity: var(--idle-opacity);
  z-index: 1;
}

/* 표정 변화 레이어 */
#btnSupportFloating .floating-action-btn.btn-support::after {
  background-image: var(--expression-bg);
  opacity: var(--expression-opacity, 0);
  z-index: 2;
}

#btnSupportFloating .floating-action-btn.btn-support.active {
  width: 75px;
  height: 75px;
}

#btnSupportFloating .floating-action-btn.btn-support:active {
  transform: translateY(-1px) scale(1.01);
  transition: all 0.1s ease;
}


/* ============================================================
   8. PiG Speech Bubble  (_pig.scss)
   ============================================================ */

#btnSupportFloating .pig-speech-bubble {
  position: absolute;
  top: 0;
  left: calc(100% - 10px);
  transform: translateY(-50%);
  background: rgba(33, 37, 41, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px 20px 20px 4px;
  padding: 12px 16px;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
  width: max-content;
  max-width: 210px;
  white-space: normal;
  word-break: keep-all;
  text-align: left;
  z-index: 100;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease-out, visibility 0.6s ease-out, left 0.6s ease-out;
}

#btnSupportFloating .pig-speech-bubble.show {
  opacity: 1;
  visibility: visible;
  left: calc(100% + 5px);
}

#btnSupportFloating .pig-speech-bubble .bubble-content {
  color: #ffffff;
  font-size: 14px;
  line-height: 1.7;
  margin-right: 14px;
}

/* Dark mode: 밝은 말풍선으로 반전 */
html[data-theme="dark"] #btnSupportFloating .pig-speech-bubble {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] #btnSupportFloating .pig-speech-bubble .bubble-content {
  color: #212529;
}

html[data-theme="dark"] #btnSupportFloating .pig-speech-bubble .bubble-close {
  color: #212529;
}

/* 버튼이 화면 우측에 있을 때: 말풍선 좌측 반전 */
#btnSupportFloating.is-on-right .pig-speech-bubble {
  left: auto;
  right: calc(100% - 10px);
  border-radius: 20px 20px 4px 20px;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
}

#btnSupportFloating.is-on-right .pig-speech-bubble.show {
  left: auto;
  right: calc(100% + 10px);
}

html[data-theme="dark"] #btnSupportFloating.is-on-right .pig-speech-bubble {
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
}