/* Legal Aid SA - "LASA" floating chat widget (vanilla, no framework).
   Mascot blob (bottom-left) -> movable chat panel with typing box.
   Answers come from an OpenAI-compatible endpoint when configured,
   otherwise from a built-in Legal Aid SA knowledge fallback. */
#ai-blob {
  position: fixed;
  left: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .12);
  cursor: pointer;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  z-index: 1055;
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  transition: transform .15s ease;
}
#ai-blob:hover { transform: scale(1.05); }
#ai-blob:focus-visible { outline: 3px solid #c80036; outline-offset: 2px; }
#ai-blob .ai-eye {
  width: 10px;
  height: 16px;
  border-radius: 9999px;
  background: #111111;
  animation: ai-blink 5s infinite;
  transition: transform .2s ease;
}
#ai-blob .ai-eye + .ai-eye { animation-delay: .15s; }
@keyframes ai-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.1); }
}
#ai-blob.ai-open { transform: translateX(6px) rotate(8deg); }
#ai-blob.ai-open .ai-eye { animation: none; transform: translateX(4px) scaleY(1); }
#ai-blob .ai-tip {
  position: absolute;
  left: 100%;
  margin-left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: #111111;
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
#ai-blob:hover .ai-tip { opacity: 1; }

/* Launch greeting bubble ("Hello", auto-dismisses). */
.aiw-hello {
  position: fixed;
  left: 86px;
  bottom: 30px;
  max-width: 240px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: #212529;
  z-index: 1055;
  cursor: pointer;
  animation: aiw-hello-in .3s ease;
}
.aiw-hello strong { color: #c80036; }
.aiw-hello.hide { opacity: 0; transition: opacity .4s ease; pointer-events: none; }
@keyframes aiw-hello-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#ai-chat {
  position: fixed;
  left: 18px;
  bottom: 88px;
  width: 330px;
  max-width: calc(100vw - 36px);
  height: 480px;
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  z-index: 1055;
  font-family: inherit;
  overflow: hidden;
}
#ai-chat[hidden] { display: none; }
#ai-chat.aiw-show { animation: aiw-pop .2s ease; }
@keyframes aiw-pop {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.aiw-head {
  padding: 12px 14px 10px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  position: relative;
  background: #0a2240;
}
.aiw-head:active { cursor: grabbing; }
.aiw-title { font-size: 14px; font-weight: 700; color: #ffffff; margin: 0 28px 1px 0; letter-spacing: .02em; }
.aiw-desc { font-size: 11.5px; line-height: 1.4; color: #b9c6d8; margin: 0 4px 0 0; }
.aiw-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  color: #b9c6d8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.aiw-close:hover { background: rgba(255, 255, 255, .15); color: #ffffff; }
.aiw-close svg { width: 14px; height: 14px; }
.aiw-msgs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  background: #f4f6f9;
  border-top: 1px solid rgba(0, 0, 0, .06);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.aiw-msg {
  max-width: 86%;
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 12px;
  word-wrap: break-word;
}
.aiw-bot {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, .1);
  color: #212529;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.aiw-user {
  background: #c80036;
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.aiw-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.aiw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #adb5bd;
  animation: aiw-blink-dot 1s infinite;
}
.aiw-typing span:nth-child(2) { animation-delay: .15s; }
.aiw-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes aiw-blink-dot {
  0%, 100% { opacity: .3; }
  50% { opacity: 1; }
}
.aiw-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px 4px;
}
.aiw-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, .2);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: #212529;
}
.aiw-input:focus { outline: 2px solid #c80036; outline-offset: 0; border-color: #c80036; }
.aiw-send {
  border: none;
  border-radius: 10px;
  background: #c80036;
  color: #ffffff;
  padding: 0 15px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.aiw-send:hover { background: #a5002c; }
.aiw-note {
  font-size: 10.5px;
  color: #adb5bd;
  text-align: center;
  padding: 4px 12px 10px;
}

.aiw-input:disabled { opacity: .55; }
.aiw-gate {
  background: #fff8e6;
  border-top: 1px solid #e0a92e;
  color: #5c4a12;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 14px;
}
.aiw-gate strong { display: block; margin-bottom: 2px; }
.aiw-gate-menu { display: flex; gap: 8px; margin-top: 8px; }
.aiw-gate-menu a {
  flex: 1;
  text-align: center;
  background: #c80036;
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 0;
  border-radius: 9px;
}
.aiw-gate-menu a.ghost { background: #ffffff; color: #c80036; border: 1px solid #c80036; }
