.chatbot-widget {
  --chatbot-color-primary: #C68A3A;
  --chatbot-color-primary-light: #F5E9D5;
  --chatbot-color-text: #2D2418;
  --chatbot-color-bg: #FFFCF6;
  --chatbot-color-border: rgba(0, 0, 0, 0.08);
  --chatbot-font-body: 'Inter', system-ui, sans-serif;
  --chatbot-font-heading: 'Cormorant Garamond', serif;
  --chatbot-radius: 12px;
  --chatbot-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  font-family: var(--chatbot-font-body);
}

.chatbot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--chatbot-color-primary);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
}
.chatbot-toggle:hover { filter: brightness(1.05); }
.chatbot-toggle:focus-visible { outline: 2px solid var(--chatbot-color-primary); outline-offset: 2px; }

.chatbot-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  height: 520px;
  max-height: 80vh;
  background: var(--chatbot-color-bg);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--chatbot-color-border);
  overflow: hidden;
  padding: 0;
  margin: 0;
}
/* Ensure the [hidden] attribute hides the panel even when display:flex is set.
   Some browsers implement [hidden]{display:none} without !important in their UA
   stylesheet, which means author CSS display rules can silently override it. */
.chatbot-panel[hidden] {
  display: none;
}

.chatbot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--chatbot-color-border);
  background: var(--chatbot-color-primary);
  color: white;
}
.chatbot-header h2 {
  flex: 1;
  margin: 0;
  font-family: var(--chatbot-font-heading);
  font-size: 18px;
  font-weight: 600;
}
.chatbot-header button {
  background: transparent;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  font-family: inherit;
}
.chatbot-header button:hover { opacity: 0.85; }

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chatbot-bubble ul.chatbot-md-list { margin: 0.3em 0; padding-left: 1.3em; }
.chatbot-bubble ul.chatbot-md-list li { margin: 0.12em 0; }
.chatbot-bubble code { background: rgba(0,0,0,0.06); padding: 0.05em 0.3em; border-radius: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; }
.chatbot-bubble hr { border: 0; border-top: 1px solid rgba(0,0,0,0.12); margin: 0.5em 0; }
.chatbot-bubble-user {
  align-self: flex-end;
  background: var(--chatbot-color-primary-light);
  color: var(--chatbot-color-text);
}
.chatbot-bubble-assistant {
  align-self: flex-start;
  background: white;
  color: var(--chatbot-color-text);
  border: 1px solid var(--chatbot-color-border);
}
.chatbot-bubble-typing::after {
  content: '...';
  animation: chatbot-typing 1.2s infinite;
}
@keyframes chatbot-typing {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.chatbot-sources {
  padding: 4px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chatbot-source-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chatbot-color-primary-light);
  color: var(--chatbot-color-text);
  text-decoration: none;
  border: 1px solid var(--chatbot-color-border);
}
.chatbot-source-chip:hover {
  background: var(--chatbot-color-primary);
  color: white;
}

.chatbot-suggestions {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chatbot-suggestion {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--chatbot-color-primary);
  border: 1px solid var(--chatbot-color-primary);
  cursor: pointer;
  font-family: inherit;
}
.chatbot-suggestion:hover {
  background: var(--chatbot-color-primary);
  color: white;
}

.chatbot-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--chatbot-color-border);
}
.chatbot-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--chatbot-color-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}
.chatbot-form textarea:focus {
  outline: 2px solid var(--chatbot-color-primary);
  outline-offset: -2px;
}
.chatbot-send {
  background: var(--chatbot-color-primary);
  color: white;
  border: none;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  font-family: inherit;
}
.chatbot-send:hover { filter: brightness(1.05); }

.chatbot-footer {
  padding: 6px 12px;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.5);
  text-align: center;
}
.chatbot-footer a { color: var(--chatbot-color-primary); }

@media (max-width: 640px) {
  .chatbot-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}

.visually-hidden {
  position: absolute;
  clip: rect(0 0 0 0);
  width: 1px;
  height: 1px;
  overflow: hidden;
}
