/* css/chatbot.css */
body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
}

#header{
  z-index: 10000 !important;
}

/* --- Chat launcher --- */
#chat-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 12vw; /* responsive width */
  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;
}
#chat-launcher:hover {
  transform: scale(1.1);
}
#chat-launcher img {
  width: 100%;
}
#chat-launcher svg {
  width: 50%;
  height: 50%;
}

/* --- Chat container --- */
#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;
}
#chat-container.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  visibility: visible;
}

/* Input area */
#input-area {
  padding: 2vw;
  border-bottom: 1px solid #eee;
}
#input-area form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1vw;
  margin: 0;
}
#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;
}
#message-input::-webkit-scrollbar {
  display: none;
}

#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;
}
#send-button:hover {
  background-color: #f48ca5;
}

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

.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;
}
.message,
.message p,
.message span,
.message font {
  word-break: normal !important;
  overflow-wrap: break-word !important;
  white-space: pre-wrap !important;
}
.user-message {
  background-color: #fde8ed;
  color: #333;
}
.bot-message {
  background-color: #fff;
  color: #333;
  border: 2px solid #f8b0c0;
  position: relative;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
}
.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;
}
.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 */
.typing-indicator { 
  display: flex;
  align-items: center; 
  height: 24px; 
  padding: 0 8px; 
  gap: 4px; 
  justify-content: flex-start; 
}
.typing-dot {
  width: 8px; 
  height: 8px; 
  background: #888; 
  border-radius: 50%; 
  opacity: 0.6; 
  animation: typing-bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.6; }
  40% { transform: scale(1); opacity: 1; }
}

/* Source links */
.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%;
}
.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 */
#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;
}
#scroll-to-bottom.show { 
  opacity: 1; 
  visibility: visible; 
  transform: translateY(0); 
}
#scroll-to-bottom:hover { 
  background-color: #f48ca5; 
  transform: scale(1.1); 
  box-shadow: 0 4px 16px rgba(244, 140, 165, 0.4); 
}
#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) {
    #chat-container {
    width: 98vw;
    bottom: 70px;
    right: 1.5vw;
    height: 58vh;
  }
  #message-input {
    font-size: 18px;
    min-height: 60px;
    max-height: 120px;
  }
  #send-button {
    font-size: 16px;
    padding: 0 20px;
    height: 45px;
  }
  #chat-launcher {
    width: 55px;
    height: 55px;
  }
  #messages-area {
    padding: 1.5vw;
  }
}
@media (min-width: 481px)  and (max-width: 767px) {
  #chat-container {
    width: 98vw;
    bottom: 75px;
    right: 1.5vw;
    height: 55vh;
  }
  #message-input {
    font-size: 16px;
    min-height: 60px;
    max-height: 120px;
  }
  #send-button {
    font-size: 16px;
    padding: 0 20px;
    height: 45px;
  }
  #chat-launcher {
    width: 50px;
    height: 50px;
  }
  #messages-area {
    padding: 1.5vw;
  }
}
@media (max-width: 767px) {
  #chat-launcher {
    position: relative;
    inset: 3px 6px auto auto;
  }
}
@media (max-width: 400px) {
  #chat-launcher {
    position: fixed;
    inset: 90px 10px auto auto;
  }
  #chat-container {
    bottom: auto;
    top: 150px;
  }
}

@media (max-width: 480px) {
  #chat-container {
        width: 100vw;
        bottom: 75px;
        right: 1vw;
        height: 55vh;
  }
  #message-input {
    font-size: 15px;
    min-height: 60px;
    max-height: 120px;
  }
  #send-button {
    font-size: 14px;
    padding: 0 20px;
    height: 45px;
  }
  #chat-launcher {
    width: 50px;
    height: 50px;
  }
  #messages-area {
    padding: 1.5vw;
  }
  .message.bot-message {
    font-size: 15px;
  }
}