/* Mila Chatbot — WhatsApp-style widget */

#mila-chatbot-root,
#mila-chatbot-root * {
  box-sizing: border-box;
}

/* ---------- Floating action button ---------- */
.mila-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25d366;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999998;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  padding: 0;
}
.mila-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
}
.mila-fab svg {
  width: 32px;
  height: 32px;
  fill: #fff;
  display: block;
}
.mila-fab .mila-fab-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: #25d366;
  opacity: 0.4;
  animation: mila-pulse 1.8s infinite;
  z-index: -1;
}
@keyframes mila-pulse {
  0%   { transform: scale(0.85); opacity: 0.45; }
  70%  { transform: scale(1.25); opacity: 0;    }
  100% { transform: scale(1.25); opacity: 0;    }
}

/* ---------- Chat window ---------- */
.mila-window {
  position: fixed;
  right: 22px;
  bottom: 96px;
  width: 370px;
  max-width: calc(100vw - 30px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #efeae2;
  border-radius: 12px;
  overflow: hidden;
  display: none;
  flex-direction: column;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.32);
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #111b21;
}
.mila-window.is-open {
  display: flex;
  animation: mila-slide-up 0.22s ease;
}
@keyframes mila-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---------- Header ---------- */
.mila-header {
  background: #008069;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.mila-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #25d366;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  font-size: 15px;
  letter-spacing: 0.5px;
}
.mila-header-info {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.mila-header-info .mila-name {
  font-weight: 600;
  font-size: 15px;
}
.mila-header-info .mila-status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mila-header-info .mila-status .mila-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
}
.mila-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.mila-close:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- Messages area ---------- */
.mila-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: #efeae2;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'><g fill='%23d8d2c8' opacity='0.55'><circle cx='10' cy='10' r='1.2'/><circle cx='40' cy='25' r='1'/><circle cx='65' cy='12' r='0.8'/><circle cx='20' cy='55' r='1.1'/><circle cx='55' cy='45' r='0.9'/><circle cx='75' cy='65' r='1'/><circle cx='30' cy='75' r='0.8'/></g></svg>");
}
.mila-messages::-webkit-scrollbar { width: 6px; }
.mila-messages::-webkit-scrollbar-thumb { background: #b9b3a7; border-radius: 3px; }

.mila-msg-row {
  display: flex;
  width: 100%;
}
.mila-msg-row.is-user { justify-content: flex-end; }
.mila-msg-row.is-bot  { justify-content: flex-start; }

/* ---------- Bubbles ---------- */
.mila-msg {
  max-width: 78%;
  padding: 6px 9px 8px;
  border-radius: 7.5px;
  position: relative;
  word-wrap: break-word;
  word-break: break-word;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  font-size: 14.2px;
  line-height: 1.4;
  color: #111b21;
}
.mila-msg-bot {
  background: #ffffff;
  margin-left: 10px;
  border-top-left-radius: 0;
}
.mila-msg-user {
  background: #d9fdd3;
  margin-right: 10px;
  border-top-right-radius: 0;
}

/* Proper WhatsApp-style triangular tails */
.mila-msg-bot::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 10px 0;
  border-color: transparent #ffffff transparent transparent;
  filter: drop-shadow(-1px 0.5px 0.5px rgba(0, 0, 0, 0.08));
}
.mila-msg-user::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 10px 8px;
  border-color: transparent transparent transparent #d9fdd3;
  filter: drop-shadow(1px 0.5px 0.5px rgba(0, 0, 0, 0.08));
}

/* Inline timestamp anchored bottom-right inside the bubble */
.mila-msg-text {
  display: inline;
  white-space: pre-wrap;
}
.mila-msg-text::after {
  content: "\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0";
  display: inline-block;
  width: 56px;
}
.mila-meta {
  position: absolute;
  right: 8px;
  bottom: 3px;
  font-size: 11px;
  color: #667781;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
}
.mila-meta .mila-ticks {
  display: inline-block;
  margin-left: 3px;
  color: #53bdeb;
  font-size: 13px;
  letter-spacing: -3px;
  vertical-align: -1px;
}

.mila-msg a {
  color: #027eb5;
  text-decoration: underline;
  word-break: break-all;
}

/* ---------- Typing indicator ---------- */
.mila-typing-bubble {
  padding: 10px 12px;
}
.mila-typing-bubble::after { content: none; }
.mila-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 14px;
}
.mila-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #99a2a8;
  animation: mila-bounce 1.2s infinite;
}
.mila-typing span:nth-child(2) { animation-delay: 0.18s; }
.mila-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes mila-bounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1;   }
}

/* ---------- Quick replies ---------- */
.mila-quick {
  padding: 6px 10px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f0f2f5;
  flex-shrink: 0;
}
.mila-quick:empty { display: none; }
.mila-quick button {
  background: #fff;
  border: 1px solid #e1e3e6;
  color: #008069;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
}
.mila-quick button:hover { background: #f5f5f5; }

/* ---------- Input row ---------- */
.mila-input-row {
  background: #f0f2f5;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  margin: 0;
}
.mila-input {
  flex: 1;
  border: none;
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 110px;
  min-height: 42px;
  line-height: 1.35;
  color: #111b21;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.08);
}
.mila-input::placeholder { color: #8696a0; }
.mila-input:focus { box-shadow: 0 0 0 1px #00806955; }
.mila-send {
  background: #00a884;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
  padding: 0;
}
.mila-send:hover { background: #008f72; }
.mila-send:disabled { background: #b8d8cf; cursor: not-allowed; }
.mila-send svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  display: block;
  margin-left: 1px;
}

.mila-disclaimer {
  font-size: 10.5px;
  color: #667781;
  text-align: center;
  padding: 4px 8px 6px;
  background: #f0f2f5;
  flex-shrink: 0;
  border-top: 1px solid #e9ebee;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .mila-window {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
  }
  .mila-fab {
    right: 14px;
    bottom: 14px;
  }
}
