/* ==========================================================================
   RBT Bank — FAQ Chatbot Widget (.chatbot*)
   Rule-based, no backend (see assets/js/chatbot.js). Shared — loaded on
   every page, same as nav.css/footer.css. Sits at bottom-right; the
   back-to-top button (footer.css) is deliberately offset 64px higher so
   the two never overlap.
   Requires style.css to be loaded first (design tokens).
   ========================================================================== */

.chatbot {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: 95;
}

.chatbot__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-blue) 0%, var(--color-blue-700) 100%);
  color: var(--color-white);
  box-shadow: var(--shadow-lg);
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.chatbot__toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chatbot__panel {
  position: absolute;
  right: 0;
  bottom: calc(56px + var(--space-4));
  display: flex;
  flex-direction: column;
  width: 22rem;
  max-width: calc(100vw - var(--space-8));
  /* Taller than the original 28rem to pay for the second row of chips. */
  height: 31rem;
  max-height: 70vh;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform-origin: bottom right;
  transform: translateY(12px) scale(0.98);
  transition:
    opacity var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-out),
    visibility 0s var(--duration-base);
}

.chatbot__panel[data-open="true"] {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition:
    opacity var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-out),
    visibility 0s;
}

.chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: var(--space-4) var(--space-6);
  background: var(--color-navy);
  color: var(--color-text-inverse);
}

.chatbot__header-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--font-size-sm);
}

.chatbot__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-inverse);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.chatbot__close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.chatbot__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-section-tint);
}

.chatbot__message {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-base);
}

.chatbot__message p {
  margin: 0;
  /* Requirement lists are written as newline-separated bullets in
     chatbot.js — without this they'd collapse into one run-on paragraph. */
  white-space: pre-line;
}

.chatbot__message--bot {
  align-self: flex-start;
  background: var(--color-white);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: var(--space-1);
}

.chatbot__message--user {
  align-self: flex-end;
  background: var(--color-blue);
  color: var(--color-white);
  border-bottom-right-radius: var(--space-1);
}

.chatbot__message-link {
  display: inline-block;
  margin-top: var(--space-2);
  font-weight: 600;
  color: var(--color-blue);
}

.chatbot__message--user .chatbot__message-link {
  color: var(--color-white);
  text-decoration: underline;
}

.chatbot__chips {
  display: flex;
  /* Wrapped, so every quick reply is visible at once — the labels are kept
     short enough to land in two rows and leave the messages room to breathe. */
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-3);
  background: var(--color-section-tint);
}

.chatbot__chip {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-white);
  color: var(--color-navy);
  font-size: var(--font-size-xs);
  font-weight: 600;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.chatbot__chip:hover {
  background: var(--color-light-gray);
}

.chatbot__form {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-white);
}

.chatbot__input {
  flex: 1;
  min-height: 40px;
  padding-inline: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.chatbot__input::placeholder {
  color: var(--color-text-muted);
}

.chatbot__input:focus-visible {
  outline: none;
  border-color: var(--color-blue);
}

.chatbot__send {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-blue);
  color: var(--color-white);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.chatbot__send:hover {
  background: var(--color-blue-700);
}
