/* Hiro AI Chatbot widget styles */

/* --- Chat launcher --- */
#hai-chat-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 12vw;
  max-width: 80px;
  height: 12vw;
  max-height: 80px;
  filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.1));
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease-in-out;
  z-index: 9998;
}
#hai-chat-launcher:hover {
  transform: scale(1.1);
}
#hai-chat-launcher img {
  width: 100%;
}

/* --- Chat container --- */
#hai-chat-container {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 90vw;
  max-width: 380px;
  height: 70vh;
  max-height: 650px;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  transform-origin: bottom right;
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  visibility: hidden;
  z-index: 9999;
  padding-bottom: 5px;
}
#hai-chat-container.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  visibility: visible;
}

/* Input area */
#hai-input-area {
  padding: 2vw;
  border-bottom: 1px solid #eee;
}
#hai-input-area form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1vw;
  margin: 0;
}
#hai-message-input {
  width: 100%;
  min-height: 8vh;
  max-height: 16vh;
  box-sizing: border-box;
  overflow-y: auto;
  resize: none;
  border: 2px solid #f8b0c0;
  border-radius: 16px;
  padding: 10px 15px;
  font-size: min(20px, 4vw);
  font-family: inherit;
  line-height: 1.3;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
#hai-message-input::-webkit-scrollbar {
  display: none;
}

#hai-send-button {
  background-color: #f8b0c0;
  color: white;
  border: none;
  border-radius: 16px;
  padding: 0 28px;
  font-size: min(22px, 4vw);
  font-weight: bold;
  cursor: pointer;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#hai-send-button:hover {
  background-color: #f48ca5;
}

/* Messages area */
#hai-messages-area {
  flex-grow: 1;
  overflow-y: auto;
  padding: 2vw;
  position: relative;
}
.hai-message-wrapper {
  display: flex;
  margin-bottom: 20px;
}
.hai-user-message-wrapper {
  justify-content: flex-end;
}
.hai-bot-message-wrapper {
  justify-content: flex-start;
  position: relative;
}

.hai-message {
  padding: 15px;
  border-radius: 18px;
  max-width: 85%;
  line-height: 1.5;
  font-size: 16px;
  font-weight: 400;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
.hai-message,
.hai-message p,
.hai-message span {
  word-break: normal !important;
  overflow-wrap: break-word !important;
  white-space: pre-wrap !important;
}
.hai-user-message {
  background-color: #fde8ed;
  color: #333;
}
.hai-bot-message {
  background-color: #fff;
  color: #333;
  border: 2px solid #f8b0c0;
  position: relative;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
}
.hai-bot-message::after {
  content: '';
  position: absolute;
  bottom: -12px;
  right: 20px;
  width: 0;
  height: 0;
  border: 12px solid transparent;
  border-top-color: #f8b0c0;
  border-bottom: 0;
  border-right: 0;
}
.hai-bot-message::before {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 22px;
  width: 0;
  height: 0;
  border: 10px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
  border-right: 0;
  z-index: 1;
}

/* Typing indicator */
.hai-typing-indicator {
  display: flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  gap: 4px;
  justify-content: flex-start;
}
.hai-typing-dot {
  width: 8px;
  height: 8px;
  background: #888;
  border-radius: 50%;
  opacity: 0.6;
  animation: hai-typing-bounce 1.2s infinite;
}
.hai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.hai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes hai-typing-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.6; }
  40% { transform: scale(1); opacity: 1; }
}

/* Source links */
.hai-source-links {
  margin-top: 12px;
  display: inline-flex !important;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
  scrollbar-width: thin;
  flex-wrap: nowrap;
  gap: 10px;
  min-width: 0;
  width: 100%;
}
.hai-source-links a {
  display: inline-flex !important;
  white-space: nowrap !important;
  color: #f48ca5;
  text-decoration: underline;
  font-size: 12px;
  background: #fff;
  border: 1px solid #f8b0c0;
  border-radius: 8px;
  padding: 2px 10px;
  margin-bottom: 0;
  flex-shrink: 0;
}

/* Scroll to bottom button */
#hai-scroll-to-bottom {
  position: fixed !important;
  bottom: 115px;
  right: 20px;
  width: 35px;
  height: 35px;
  background-color: #f8b0c0;
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(248, 176, 192, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
}
#hai-scroll-to-bottom.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#hai-scroll-to-bottom:hover {
  background-color: #f48ca5;
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(244, 140, 165, 0.4);
}
#hai-scroll-to-bottom svg {
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

@media (min-width: 768px) and (max-width: 1024px) {
  #hai-chat-container { width: 98vw; bottom: 70px; right: 1.5vw; height: 58vh; }
  #hai-message-input { font-size: 18px; min-height: 60px; max-height: 120px; }
  #hai-send-button { font-size: 16px; padding: 0 20px; height: 45px; }
  #hai-chat-launcher { width: 55px; height: 55px; }
  #hai-messages-area { padding: 1.5vw; }
}
@media (min-width: 481px) and (max-width: 767px) {
  #hai-chat-container { width: 98vw; bottom: 75px; right: 1.5vw; height: 55vh; }
  #hai-message-input { font-size: 16px; min-height: 60px; max-height: 120px; }
  #hai-send-button { font-size: 16px; padding: 0 20px; height: 45px; }
  #hai-chat-launcher { width: 50px; height: 50px; }
  #hai-messages-area { padding: 1.5vw; }
}
@media (max-width: 767px) {
  #hai-chat-launcher { position: relative; inset: 3px 6px auto auto; }
}
@media (max-width: 400px) {
  #hai-chat-launcher { position: fixed; inset: 90px 10px auto auto; }
  #hai-chat-container { bottom: auto; top: 150px; }
}
@media (max-width: 480px) {
  #hai-chat-container { width: 100vw; bottom: 75px; right: 1vw; height: 55vh; }
  #hai-message-input { font-size: 15px; min-height: 60px; max-height: 120px; }
  #hai-send-button { font-size: 14px; padding: 0 20px; height: 45px; }
  #hai-chat-launcher { width: 50px; height: 50px; }
  #hai-messages-area { padding: 1.5vw; }
  .hai-message.hai-bot-message { font-size: 15px; }
}
