/**
 * RAG Chatbot — chat block styles.
 * Intentionally minimal to integrate cleanly with any Drupal theme.
 */

.rag-chatbot {
  display: flex;
  flex-direction: column;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  overflow: hidden;
  font-family: inherit;
  max-width: 680px;
  margin: 0 auto;
  margin-bottom: 50px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ── Header ── */
.rag-chatbot__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #003a70; /* DCPAS navy — override in your theme if needed */
  color: #ffffff;
}

.rag-chatbot__icon {
  font-size: 1.25rem;
  line-height: 1;
}

.rag-chatbot__title {
  font-weight: 600;
  font-size: 1rem;
}

/* ── Message list ── */
.rag-chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 260px;
  max-height: 420px;
  background: #f8f9fa;
}

/* ── Individual messages ── */
.rag-chatbot__message {
  padding: 0.625rem 0.875rem;
  border-radius: 6px;
  line-height: 1.5;
  font-size: 0.9375rem;
  max-width: 88%;
  word-break: break-word;
  white-space: pre-wrap;
}

.rag-chatbot__message--user {
  background: #003a70;
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.rag-chatbot__message--assistant {
  background: #ffffff;
  color: #1a1a1a;
  align-self: flex-start;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 2px;
}

.rag-chatbot__message--error {
  background: #fdecea;
  color: #b71c1c;
  align-self: flex-start;
  border: 1px solid #f5c6c6;
  font-size: 0.875rem;
}

/* Animated dots for loading state */
.rag-chatbot__message--loading {
  color: #666666;
  font-style: italic;
}

/* ── Markdown inside assistant bubbles ── */
.rag-chatbot__message--assistant p { margin: 0 0 0.5em; }
.rag-chatbot__message--assistant p:last-child { margin-bottom: 0; }
.rag-chatbot__message--assistant h1,
.rag-chatbot__message--assistant h2,
.rag-chatbot__message--assistant h3 { margin: 0.5em 0 0.25em; font-size: 1em; font-weight: 700; }
.rag-chatbot__message--assistant ul,
.rag-chatbot__message--assistant ol { margin: 0.25em 0 0.5em 1.25em; padding: 0; }
.rag-chatbot__message--assistant li { margin: 0.15em 0; }
.rag-chatbot__message--assistant code { background: #f0f0f0; padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.875em; }
.rag-chatbot__message--assistant pre { background: #f0f0f0; padding: 0.75em; border-radius: 4px; overflow-x: auto; margin: 0.5em 0; }
.rag-chatbot__message--assistant pre code { background: none; padding: 0; }

/* ── Sources list ── */
.rag-chatbot__sources {
  font-size: 0.8125rem;
  color: #555555;
  padding: 0 0.5rem 0.25rem;
}

.rag-chatbot__sources span {
  font-weight: 600;
  margin-right: 0.25rem;
}

.rag-chatbot__sources ul {
  margin: 0.25rem 0 0 1rem;
  padding: 0;
  list-style: disc;
}

.rag-chatbot__sources li {
  margin: 0.15rem 0;
}

.rag-chatbot__sources a {
  color: #003a70;
  word-break: break-all;
}

/* ── Input row ── */
.rag-chatbot__form {
  padding: 0.75rem;
  border-top: 1px solid #e0e0e0;
  background: #ffffff;
}

.rag-chatbot__input-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rag-chatbot__input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  border: 1px solid #c0c0c0;
  border-radius: 4px;
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.rag-chatbot__input:focus {
  border-color: #003a70;
  box-shadow: 0 0 0 2px rgba(0, 58, 112, 0.2);
}

.rag-chatbot__input:disabled {
  background: #f0f0f0;
  cursor: not-allowed;
}

.rag-chatbot__submit {
  width: 100%;
  padding: 0.5rem 1.125rem;
  background: #003a70;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 0.9375rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.rag-chatbot__submit:hover:not(:disabled) {
  background: #00509e;
}

.rag-chatbot__submit:disabled {
  background: #7a9bbf;
  cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .rag-chatbot {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .rag-chatbot__message {
    max-width: 95%;
  }
}
