/* widget.css */

/* Chat Widget Container */
#chat-box {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 320px;
  height: 80vh;
  max-height: 90vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
}

#chat-box.open {
  display: flex;
}

#messages {
  background-color: var(--messages-bg);
}

.chat-messages a{
  text-decoration:underline;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: var(--scroll-thumb, #000);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background-color: var(--scroll-track, #eee);
}

.chat-messages {
  scrollbar-color: var(--scroll-thumb, #ccc) var(--scroll-track, #eee);
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.chat-header {
  background: #0073aa;
  color: white;
  padding: 12px;
  font-weight: bold;
  text-align: center;
}

.chat-header-image {
  width: 100%;
  height: auto;
}

.chat-header-image img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.chat-footer {
  padding: 0px;
  font-size: 0.7rem;
  color: #888;
  text-align: center;
  border-top: 1px solid #eee;
  background: #f9f9f9;
}

.chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  border: none;
  border-radius: 50%;
  padding: 0px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  width: 80px;
  height: 80px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: transparent;
  background-image: var(--chat-fab-icon);
}

.chat-form {
  display: flex;
  padding: 10px;
  border-top: 1px solid #ddd;
  background: #f9f9f9;
  align-items: center;
}

.chat-form input {
  flex-grow: 1;
  padding: 8px 10px;
  border-radius: 6px 0 0 6px;
  border: 1px solid #ccc;
  font-size: 1rem;
}

.chat-form button,
.chat-submit {
  margin-left: 8px;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  background: #0073aa;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  margin: 0 0 40px 0;
  gap: 6px;
}

.chat-message.bot {
  justify-content: flex-start;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.bot,
.chat-message.loader {
  align-items: flex-end;
}

.chat-message.user .avatar,
.chat-message.user .avatar,
.chat-message.bot .avatar {
  order: 0;
  background: inherit;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  word-wrap: break-word;
  position: relative;
  display: inline-block;
  background: var(--bubble-bg);
  color: var(--bubble-color);
}

.chat-message.bot .chat-bubble,
.chat-message.loader .chat-bubble {
  margin-left: 0;
  align-self: flex-start;
}

.chat-message.user .chat-bubble {
  margin-left: auto;
  align-self: flex-start;
}

.chat-message.loader .chat-bubble::after,
.chat-message.bot .chat-bubble::after {
  content: "";
  position: absolute;
  left: 0px;
  bottom: 0px;
  border-width: 8px 10px 8px 0;
  border-style: solid;
  border-color: transparent transparent transparent var(--bot-bg) ;
}

.chat-message.user .chat-bubble::after {
  content: "";
  position: absolute;
  right: 0px;
  bottom: 0px;
  border-width: 8px 0px 8px 10px;
  border-style: solid;
  border-color: transparent var(--user-bg) transparent transparent ;
}

.chat-message .avatar {
  align-self: flex-end;
  margin-bottom: -30px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.typing {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bot-bg, #eee);
  border-radius: 14px;
  padding: 10px 14px;
  max-width: 85%;
  position: relative;
  color: var(--bot-text, #333);
  font-size: 1rem;
  font-style: italic;
  align-self: flex-start;
  margin-left: 0;
}

.typing .dot {
  width: 8px;
  height: 8px;
  background-color: var(--bot-text, #333);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
  opacity: 0.7;
  display: inline-block;
}

.typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

.bot-thinking-line {
  max-width: 85%;
  margin-top: 6px;
  font-size: 0.9rem;
  background-color: var(--bot-bg);
  color: var(--bot-text);
  padding: 10px 14px;
  border-radius: 14px;
  font-style: italic;
  position: relative;
  animation: fadeIn 0.4s ease-in;
  align-self: flex-start;
  margin-left: 0;
}

.bot-thinking-line::after {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 10px;
  border-width: 6px 8px 6px 0;
  border-style: solid;
  border-color: transparent inherit var(--bot-bg) transparent;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bubble-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

/* Enhanced topic buttons to match chat bubble style */
#topic-buttons,
.related-topic-button-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 10px;
}

.topic-button {
  background-color: var(--bot-bg, #ab8d3f);
  color: var(--bot-text, #fff);
  border: none;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  margin: 4px 4px 0 0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.topic-button:hover {
  filter: brightness(1.1);
}

.topic-button.related {
  background-color: var(--bot-bg, #000);
  color: var(--bot-text, #fff);
}

.chat-related-intro {
  font-weight: bold;
  margin-bottom: 8px;
  text-align: center;
}


#related-topic-buttons {
  display: none;
  padding: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-message.bot.related-intro {
  margin-top: 1rem;
}

.chat-bubble.related-intro-bubble {
  font-size: 0.8rem;
  font-style: italic;
  opacity: 0.9;
}
.chat-message.loader {
  align-items: flex-start;
  position: relative;
}

.chat-message.loader .avatar {
  margin-top: -6px; /* ensures avatar aligns with first bubble */
}

.related-intro-bubble {
  position: relative;
  padding-right: 28px; /* make space for the close button */
}

.close-related-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.close-related-btn:hover {
  color: #ff6b6b;
}

