/* Chatbot feature styles. Loaded via <link> in public/index.html. */

.page-chatbot { background: var(--bg-secondary, #f8f9fa); }

/* ---------- Buttons (one ghost variant only) ---------- */
.chatbot-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  line-height: 1;
}

.chatbot-btn--ghost {
  background: transparent;
  color: var(--accent-blue, #003366);
  border-color: var(--accent-blue, #003366);
}
.chatbot-btn--ghost:hover { background: rgba(0, 51, 102, 0.08); }

/* ---------- Page layout ---------- */
.chatbot-session { padding: 60px 0 100px; }

.chatbot-session__toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

/* ---------- Chat window ---------- */
.chatbot-window {
  background: #fff;
  border: 1px solid #E6E9EF;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.chatbot-window__messages {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 60vh;
  min-height: 360px;
  overflow-y: auto;
}

.chatbot-window__empty {
  color: var(--text-gray, #6C757D);
  text-align: center;
  margin: auto 0;
  padding: 2rem;
}

.chatbot-window__error {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

/* ---------- Message bubbles ---------- */
.chatbot-msg {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  max-width: 85%;
}

.chatbot-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.chatbot-msg--assistant { align-self: flex-start; }

.chatbot-msg__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-tertiary, #F0F2F5);
  color: var(--accent-blue, #003366);
}

.chatbot-msg--user .chatbot-msg__avatar {
  background: var(--accent-blue, #003366);
  color: #fff;
}

.chatbot-msg__body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.chatbot-msg__bubble {
  background: var(--bg-tertiary, #F0F2F5);
  color: var(--text-dark, #2C3E50);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border-top-left-radius: 4px;
  white-space: pre-wrap;
  line-height: 1.5;
}

.chatbot-msg--user .chatbot-msg__bubble {
  background: var(--accent-blue, #003366);
  color: #fff;
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}

/* Typing indicator */
.chatbot-msg__bubble--typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 56px;
}

.chatbot-msg__bubble--typing span {
  width: 6px;
  height: 6px;
  background: var(--text-gray, #6C757D);
  border-radius: 50%;
  animation: chatbot-typing 1.2s ease-in-out infinite;
}
.chatbot-msg__bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-msg__bubble--typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Composer ---------- */
.chatbot-composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #EEF1F5;
  background: #FAFBFD;
}

.chatbot-composer__input {
  flex: 1;
  border: 1px solid #D7DCE3;
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  background: #fff;
}

.chatbot-composer__input:focus {
  outline: none;
  border-color: var(--accent-blue, #003366);
  box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.15);
}

.chatbot-composer__send {
  background: var(--accent-blue, #003366);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.chatbot-composer__send:hover { background: #002347; }
.chatbot-composer__send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Thinking panel (native <details>) ---------- */
.chatbot-thinking { margin-top: 0.25rem; }

.chatbot-thinking > summary {
  list-style: none;
  cursor: pointer;
  color: var(--accent-blue, #003366);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.25rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.chatbot-thinking > summary::-webkit-details-marker { display: none; }
.chatbot-thinking > summary::before {
  content: "▶";
  font-size: 0.65em;
  transition: transform 0.15s;
}
.chatbot-thinking[open] > summary::before { transform: rotate(90deg); }
.chatbot-thinking > summary:hover { text-decoration: underline; }

.chatbot-thinking__body {
  margin-top: 0.5rem;
  background: #FAFBFD;
  border: 1px solid #E6E9EF;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chatbot-thinking__heading {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-gray, #6C757D);
  font-weight: 700;
}

.chatbot-thinking__sources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chatbot-thinking__sources li {
  background: #fff;
  border: 1px solid #EAEEF3;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.chatbot-thinking__score {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light, #95A5A6);
  margin-bottom: 0.25rem;
}

.chatbot-thinking__snippet {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--text-dark, #2C3E50);
  background: transparent;
  padding: 0;
}

.chatbot-thinking__reasoning {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-dark, #2C3E50);
  font-size: 0.9rem;
}
.chatbot-thinking__reasoning li { margin-bottom: 0.25rem; }

.chatbot-thinking__empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-gray, #6C757D);
  font-style: italic;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .chatbot-window__messages { padding: 1rem; max-height: 65vh; }
  .chatbot-msg { max-width: 95%; }
}
