/* ============================================================
   Chatbot widget — shared by main page (index.html) + admin (admin.html)
   ============================================================ */

.chatbot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-chatbot);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cobalt);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(8, 102, 255, 0.4);
  transition: all var(--d-base);
}
.chatbot-fab:hover { transform: translateY(-3px) scale(1.05); }
.chatbot-fab svg { width: 26px; height: 26px; }

.chatbot-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-chatbot);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
}
.chatbot-panel.open {
  display: flex;
  animation: chat-open 320ms var(--ease-spring);
}
@keyframes chat-open {
  from { opacity: 0; transform: scale(0.9) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.chatbot-header {
  padding: 18px 20px;
  background: var(--ink-deep);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chatbot-header .who {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chatbot-header .who .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cobalt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  position: relative;
}
.chatbot-header .who .avatar::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--ink-deep);
}
.chatbot-header .who .avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  padding: 2px;
}
.chatbot-header .who .name { font-size: 14px; font-weight: 700; }
.chatbot-header .who .status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}
.chatbot-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  transition: all var(--d-fast);
}
.chatbot-close:hover { background: rgba(255, 255, 255, 0.1); }

/* 💾 대화 저장 버튼 + 드롭다운 메뉴 */
.chatbot-save {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  transition: all var(--d-fast);
}
.chatbot-save:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.chatbot-save svg { display: block; }

.chatbot-save-menu {
  position: absolute;
  top: 64px;
  right: 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
  min-width: 200px;
}
.chatbot-save-menu.open { display: flex; }
.chatbot-save-menu button {
  background: transparent;
  border: none;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink-deep, #1a1a1a);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--d-fast);
}
.chatbot-save-menu button:hover { background: var(--bg-soft, #f3f4f6); }
.chatbot-save-menu button span { font-size: 16px; line-height: 1; }
[data-theme="dark"] .chatbot-save-menu {
  background: var(--ink-deep, #1a1a1a);
  border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .chatbot-save-menu button { color: rgba(255, 255, 255, 0.92); }
[data-theme="dark"] .chatbot-save-menu button:hover { background: rgba(255, 255, 255, 0.08); }

.chatbot-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--surface-softer);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: fade-in 240ms var(--ease-out);
}
.chat-bubble.bot {
  background: var(--canvas);
  border: 1px solid var(--hairline-soft);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.chat-bubble.user {
  background: var(--cobalt);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.chat-bubble.typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px;
}
.chat-bubble.typing span {
  width: 6px;
  height: 6px;
  background: var(--stone);
  border-radius: 50%;
  animation: typing-dot 1.4s ease-in-out infinite;
}
.chat-bubble.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: var(--surface-softer);
}
.chat-suggestion {
  font-size: 12px;
  padding: 8px 12px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-full);
  color: var(--ink);
  transition: all var(--d-fast);
}
.chat-suggestion:hover {
  background: var(--cobalt-soft);
  border-color: var(--cobalt);
  color: var(--cobalt-deep);
}

.chatbot-input {
  padding: 12px 16px;
  border-top: 1px solid var(--hairline-soft);
  display: flex;
  gap: 8px;
  background: var(--canvas);
}
.chatbot-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-full);
  font-size: 14px;
  outline: none;
  background: var(--canvas);
  color: var(--ink);
}
.chatbot-input input:focus { border-color: var(--cobalt); }
.chatbot-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cobalt);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chatbot-input button:hover { background: var(--cobalt-deep); }

/* Action result card (rendered after tool calls) */
.chat-action-card {
  align-self: stretch;
}
