
.chatbot-toggler {
  position: fixed;
  bottom: 20px;
  right: 20px;
  outline: none;
  border: none;
  height: 50px;
  width: 50px;
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-red);
  border: 2px solid var(--color-white);
  box-shadow: 0 12px 30px rgba(var(--brand-red-rgb), 0.38), 0 4px 12px rgba(var(--brand-navy-rgb), 0.22);
  z-index: 9999;
  transition: all 0.2s ease;
}

.chatbot-toggler:hover {
  background: var(--brand-red-dark);
  box-shadow: 0 14px 34px rgba(var(--brand-red-rgb), 0.48), 0 4px 12px rgba(var(--brand-navy-rgb), 0.24);
}

body.show-chatbot .chatbot-toggler {
  transform: rotate(90deg);
}

.chatbot-toggler span {
  color: var(--color-white);
  position: absolute;
}

.chatbot-toggler span:last-child,
body.show-chatbot .chatbot-toggler span:first-child {
  opacity: 0;
}

body.show-chatbot .chatbot-toggler span:last-child {
  opacity: 1;
}

.chatbot {
    position: fixed;
    right: 35px;
    bottom: 90px;
    width: 420px;
    height: 600px;
    max-height: calc(100vh - 110px);
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border-radius: 15px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transform-origin: bottom right;
    box-shadow: 0 0 128px 0 rgba(var(--color-black-rgb), 0.1),
      0 32px 64px -48px rgba(var(--color-black-rgb), 0.5);
    transition: all 0.1s ease;
}

body.show-chatbot .chatbot {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
    z-index: 99999999;
}

.chatbot header {
    padding: 16px 0;
    position: relative;
    text-align: center;
    color: var(--color-white);
    background: var(--brand-red);
    box-shadow: 0 2px 10px rgba(var(--color-black-rgb), 0.1);
}

.chatbot header span {
    position: absolute;
    right: 15px;
    top: 50%;
    display: none;
    cursor: pointer;
    transform: translateY(-50%);
}

.chatbot header h2 {
    font-size: 1.4rem;
}

.chatbot .chatbox {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 20px 12px;
    margin: 0;
}

.chatbot :where(.chatbox, textarea)::-webkit-scrollbar {
    width: 6px;
}

.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-track {
    background: var(--color-white);
    border-radius: 25px;
}

.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-thumb {
    background: var(--color-border-medium);
    border-radius: 25px;
}

.chatbox .chat {
    display: flex;
    list-style: none;
}

.chatbox .outgoing {
    margin: 20px 0;
    justify-content: flex-end;
}

.chatbox .incoming img {
    width: 25px;
    height: 25px;
    color: var(--color-white);
    cursor: default;
    text-align: center;
    line-height: 32px;
    align-self: flex-start;
    border-radius: 4px;
    margin: 2px 10px 7px 0;
    cursor: pointer;
}

.chatbox .chat .chat-message {
    /* pre-line keeps real line breaks but collapses stray runs of spaces so
       knowledge-base text reads naturally instead of with large gaps. */
    white-space: pre-line;
    padding: 12px 16px;
    border-radius: 10px 10px 0 10px;
    max-width: 75%;
    color: var(--color-white);
    font-size: 0.95rem;
    line-height: 1.5;
    background: var(--brand-blue);
    word-break: break-word;
}

.chatbox .incoming .chat-message {
    border-radius: 10px 10px 10px 0;
}

.chatbox .chat .chat-message.error {
    color: var(--color-error-text);
    background: var(--color-error-bg);
}

.chatbox .incoming .chat-message {
    color: var(--color-black);
    background: var(--color-chat-incoming);
    margin-bottom: 1rem;
    word-break: break-word;
}

.chatbot .chat-input {
    display: flex;
    gap: 5px;
    flex: 0 0 auto;
    width: 100%;
    background: var(--color-white);
    padding: 3px 20px;
    border-top: 1px solid var(--color-border);
}

.chat-input textarea {
    height: 55px;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    max-height: 180px;
    padding: 15px 15px 15px 0;
    font-size: 0.95rem;
}

.chat-input span {
    align-self: flex-end;
    color: var(--brand-red);
    cursor: pointer;
    height: 55px;
    display: flex;
    align-items: center;
    visibility: hidden;
    font-size: 1.35rem;
}

.chat-input textarea:valid~span {
    visibility: visible;
}

@media (max-width: 490px) {
    .chatbot-toggler {
      right: 20px;
      bottom: 20px;
    }

    .chatbot {
      right: 0;
      bottom: 0;
      height: 100%;
      max-height: 100%;
      border-radius: 0;
      width: 100%;
    }

    .chatbot .chatbox {
      padding: 20px 15px 10px;
    }

    .chatbot .chat-input {
      padding: 5px 15px;
    }

    .chatbot header span {
      display: block;
    }
}

/* Quick-action chips for the knowledge-base chatbot */
#chatbot-agent-menu-buttons {
  flex: 0 0 auto;
  background: var(--color-white);
  max-height: 130px;
  overflow-y: auto;
}
#chatbot-agent-menu-buttons .chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 20px 4px;
}
#chatbot-agent-menu-buttons .chat-chip {
  border: 1px solid rgba(var(--brand-navy-rgb), 0.25);
  background: var(--color-white);
  color: var(--brand-navy);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.15s ease;
}
#chatbot-agent-menu-buttons .chat-chip:hover {
  border-color: var(--brand-red);
  color: var(--brand-red);
}
#chatbot-agent-menu-buttons .chat-chip-human {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: var(--color-white);
}
#chatbot-agent-menu-buttons .chat-chip-human:hover {
  color: var(--color-white);
  opacity: 0.92;
}
#chatbot-agent-menu-buttons .chat-quick-note {
  font-size: 12px;
  color: var(--brand-navy);
  opacity: 0.7;
  padding: 4px 4px 0;
}

/* Typing indicator shown while the assistant composes a reply. */
.chatbox .chat-typing .chat-message {
    padding: 14px 16px;
}
.chat-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.chat-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-black);
    opacity: 0.28;
    transform: scale(0.72);
    animation: chatTypingBloom 1.15s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
.chat-typing-status {
    min-height: 1.25rem;
    padding: 0 20px 6px;
}
@keyframes chatTypingBloom {
    0%, 70%, 100% { transform: scale(0.72); opacity: 0.28; }
    35% { transform: scale(1.22); opacity: 0.9; }
}
