/* Humedit AI Chatbot widget styles */

/* --- Chat launcher --- */
#humedit-chat-launcher {
  position: fixed;
  bottom: 95px;
  right: 25px;
  width: 54px;
  height: 54px;
  background: #fff;
  border: 3px solid #1f6fb2;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  transition: transform 0.2s ease-in-out;
  z-index: 100010;
}
#humedit-chat-launcher:hover {
  transform: scale(1.08);
}
#humedit-chat-launcher img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
#humedit-chat-launcher .humedit-launcher-label {
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  background: #1f6fb2;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 9px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* --- Chat container --- */
#humedit-chat-container {
  position: fixed;
  bottom: 165px;
  right: 25px;
  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: 100011;
  padding-bottom: 5px;
}
#humedit-chat-container.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  visibility: visible;
}

/* Input area */
#humedit-input-area {
  padding: 2vw;
  border-bottom: 1px solid #eee;
}
#humedit-input-area form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1vw;
  margin: 0;
}
#humedit-message-input {
  width: 100%;
  min-height: 8vh;
  max-height: 16vh;
  box-sizing: border-box;
  overflow-y: auto;
  resize: none;
  border: 2px solid #a9cbe8;
  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;
}
#humedit-message-input::-webkit-scrollbar {
  display: none;
}

#humedit-send-button {
  background-color: #1f6fb2;
  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;
}
#humedit-send-button:hover {
  background-color: #17588f;
}

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

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

/* Progress bar shown while an answer is being put together. It is a
   progress *indication*, not a measurement — the request has no milestones to
   report, so the bar eases towards 90% and stops there until the answer lands. */
.humedit-progress {
  margin-top: 8px;
  height: 4px;
  width: 100%;
  max-width: 220px;
  background: #eaf3fb;
  border-radius: 999px;
  overflow: hidden;
}
.humedit-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #1f6fb2, #143f5e);
  animation: humedit-progress-grow 14s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}
@keyframes humedit-progress-grow {
  0%   { width: 0; }
  12%  { width: 32%; }
  40%  { width: 62%; }
  100% { width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  .humedit-progress-fill { animation: none; width: 60%; }
}

/* Shown under the dots while a question needs a second search */
.humedit-wait-notice {
  margin-top: 4px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #888;
}

/* Source links */
.humedit-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%;
}
.humedit-source-links a {
  display: inline-flex !important;
  white-space: nowrap !important;
  color: #17588f;
  text-decoration: underline;
  font-size: 12px;
  background: #fff;
  border: 1px solid #a9cbe8;
  border-radius: 8px;
  padding: 2px 10px;
  margin-bottom: 0;
  flex-shrink: 0;
}

/* Scroll to bottom button */
#humedit-scroll-to-bottom {
  position: fixed !important;
  bottom: 190px;
  right: 25px;
  width: 35px;
  height: 35px;
  background-color: #1f6fb2;
  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(31, 111, 178, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100012;
}
#humedit-scroll-to-bottom.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#humedit-scroll-to-bottom:hover {
  background-color: #17588f;
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(23, 88, 143, 0.4);
}
#humedit-scroll-to-bottom svg {
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

/* ===== Positioning notes =====
   humedit.ph has a Facebook Messenger bubble fixed at bottom:25px/right:25px
   (z-index 100000, see understrap-child/assets/css/style-main.css) plus a
   full-width sticky promo banner along the very bottom of the viewport. This
   widget is placed above both: the launcher sits at bottom:95px so the
   Messenger bubble stays visible below it, and everything here uses
   z-index >= 100010 so it layers above the Messenger bubble's 100000.
   These offsets are a starting point — confirm by eye against the live site
   and adjust if the promo banner's height changes. */

@media (min-width: 768px) and (max-width: 1024px) {
  #humedit-chat-container { width: 98vw; right: 1.5vw; height: 58vh; }
  #humedit-message-input { font-size: 18px; min-height: 60px; max-height: 120px; }
  #humedit-send-button { font-size: 16px; padding: 0 20px; height: 45px; }
  #humedit-messages-area { padding: 1.5vw; }
}
@media (min-width: 481px) and (max-width: 767px) {
  #humedit-chat-container { width: 98vw; right: 1.5vw; height: 55vh; }
  #humedit-message-input { font-size: 16px; min-height: 60px; max-height: 120px; }
  #humedit-send-button { font-size: 16px; padding: 0 20px; height: 45px; }
  #humedit-messages-area { padding: 1.5vw; }
}
@media (max-width: 767px) {
  #humedit-chat-launcher {
    right: 12px;
    bottom: 88px;
    width: 50px;
    height: 50px;
  }
  #humedit-chat-container {
    right: 3vw;
    width: 94vw;
    bottom: 150px;
    height: min(56vh, 440px);
  }
  #humedit-scroll-to-bottom {
    right: 12px;
    bottom: 175px;
  }
}
@media (max-width: 400px) {
  #humedit-chat-launcher {
    right: 10px;
    bottom: 84px;
    width: 46px;
    height: 46px;
  }
  #humedit-chat-container {
    bottom: 144px;
    height: min(54vh, 400px);
  }
  #humedit-scroll-to-bottom {
    right: 10px;
    bottom: 168px;
  }
  #humedit-chat-launcher .humedit-launcher-label { font-size: 9px; padding: 2px 6px; bottom: -8px; }
}

/* Occasional gentle wiggle so returning visitors notice the launcher.
   Off entirely under prefers-reduced-motion, and paused on hover / while
   the chat window is open. */
@keyframes humedit-attention {
  0%   { transform: rotate(0deg) scale(1); }
  4%   { transform: rotate(-10deg) scale(1.05); }
  8%   { transform: rotate(9deg) scale(1.05); }
  12%  { transform: rotate(-7deg) scale(1.04); }
  16%  { transform: rotate(6deg) scale(1.03); }
  20%  { transform: rotate(-4deg) scale(1.02); }
  24%  { transform: rotate(2deg) scale(1.01); }
  28%, 100% { transform: rotate(0deg) scale(1); }
}
@media (prefers-reduced-motion: no-preference) {
  #humedit-chat-launcher {
    animation: humedit-attention 9s ease-in-out 2s infinite;
    transform-origin: 50% 60%;
    will-change: transform;
  }
}
#humedit-chat-launcher:hover { animation: none; }
#humedit-chat-container.open ~ #humedit-chat-launcher { animation: none; }
