/* ── Layout raiz ──────────────────────────────────────────────────────────── */

.rt-chatbot-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Botão flutuante ──────────────────────────────────────────────────────── */

.rt-chatbot-fab {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 999px;
  background: #0055ff;
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 85, 255, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rt-chatbot-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 36px rgba(0, 85, 255, 0.4);
}

/* ── Janela do chat ───────────────────────────────────────────────────────── */

.rt-chatbot-window {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(360px, calc(100vw - 32px));
  height: 520px;
  display: none;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  border: 1px solid #e5e5e5;
}

.rt-chatbot-window.is-open {
  display: flex;
  flex-direction: column;
}

/* ── Cabeçalho ────────────────────────────────────────────────────────────── */

.rt-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0f172a;
  color: #fff;
  flex-shrink: 0;
}

.rt-chatbot-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.rt-chatbot-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.8;
  transition: opacity 0.1s;
}

.rt-chatbot-close:hover {
  opacity: 1;
}

/* ── Área de mensagens ────────────────────────────────────────────────────── */

.rt-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

/* ── Balões ───────────────────────────────────────────────────────────────── */

.rt-chatbot-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  max-width: 86%;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  /* Removido white-space: pre-wrap — conflitaria com o HTML gerado pelo parseMarkdown */
}

.rt-chatbot-bubble-user {
  margin-left: auto;
  background: #dbeafe;
  color: #1e3a8a;
}

.rt-chatbot-bubble-assistant {
  margin-right: auto;
  background: #eef2ff;
  color: #1f2937;
}

/* ── Markdown dentro dos balões do assistente ─────────────────────────────── */

.rt-chatbot-bubble-assistant p {
  margin: 0 0 6px;
}

.rt-chatbot-bubble-assistant p:last-child {
  margin-bottom: 0;
}

.rt-chatbot-bubble-assistant h1,
.rt-chatbot-bubble-assistant h2,
.rt-chatbot-bubble-assistant h3 {
  margin: 8px 0 4px;
  font-weight: 700;
  line-height: 1.3;
}

.rt-chatbot-bubble-assistant h1 { font-size: 15px; }
.rt-chatbot-bubble-assistant h2 { font-size: 14px; }
.rt-chatbot-bubble-assistant h3 { font-size: 13px; }

.rt-chatbot-bubble-assistant ul,
.rt-chatbot-bubble-assistant ol {
  margin: 4px 0 4px 18px;
  padding: 0;
}

.rt-chatbot-bubble-assistant li {
  margin: 3px 0;
}

.rt-chatbot-bubble-assistant strong {
  font-weight: 700;
}

.rt-chatbot-bubble-assistant em {
  font-style: italic;
}

.rt-chatbot-bubble-assistant code {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

/* ── Formulário ───────────────────────────────────────────────────────────── */

.rt-chatbot-form {
  display: flex;
  gap: 8px;
  border-top: 1px solid #e5e7eb;
  padding: 10px;
  background: #fff;
  flex-shrink: 0;
}

.rt-chatbot-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.rt-chatbot-input:focus {
  border-color: #0055ff;
}

.rt-chatbot-send {
  border: none;
  border-radius: 10px;
  background: #0055ff;
  color: #fff;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.rt-chatbot-send:hover:not(:disabled) {
  background: #0044dd;
}

.rt-chatbot-send:disabled,
.rt-chatbot-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* ── Responsivo ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .rt-chatbot-root {
    right: 12px;
    bottom: 12px;
  }

  .rt-chatbot-window {
    width: calc(100vw - 24px);
    height: min(72vh, 540px);
  }
}