/* shared/chat-widget.css
   Layout and structure ONLY. Every colour, radius, typeface and shadow is
   pulled from per-site custom properties. There are deliberately no hex codes,
   no rgb()/hsl(), and no colour keywords anywhere in this file — a site that
   forgets to define the variables gets an unstyled-but-functional widget, not
   this file's idea of a colour.

   Consumed variables (each site must define all eight):
     --chat-bg  --chat-fg  --chat-accent  --chat-accent-fg
     --chat-bubble-user  --chat-bubble-bot  --chat-radius  --chat-font
   Plus one per-site glyph:  --chat-icon  (an SVG mask for the bubble)
*/

#quana-chat {
  position: fixed;
  right: clamp(0.9rem, 3vw, 1.6rem);
  bottom: clamp(0.9rem, 3vw, 1.6rem);
  z-index: 2147483000;
  font-family: var(--chat-font);
  /* Shadow colour is derived from the site's foreground so this file stays
     colour-free while still honouring the brief's per-site shadow. */
  --qchat-shadow: 0 10px 34px color-mix(in srgb, var(--chat-fg) 26%, transparent);
  --qchat-shadow-sm: 0 4px 14px color-mix(in srgb, var(--chat-fg) 20%, transparent);
}

/* ---- launcher bubble ------------------------------------------------- */

.qchat__bubble {
  width: 56px;
  height: 56px;
  border-radius: var(--chat-radius);
  display: grid;
  place-items: center;
  background: var(--chat-accent);
  color: var(--chat-accent-fg);
  box-shadow: var(--qchat-shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
  margin-left: auto;
}

.qchat__bubble:hover {
  transform: translateY(-2px);
  box-shadow: var(--qchat-shadow);
}

.qchat__bubble-icon {
  width: 24px;
  height: 24px;
  background: var(--chat-accent-fg);
  -webkit-mask: var(--chat-icon) center / contain no-repeat;
  mask: var(--chat-icon) center / contain no-repeat;
}

/* ---- panel ----------------------------------------------------------- */

.qchat__panel {
  position: absolute;
  right: 0;
  bottom: calc(56px + 0.9rem);
  width: 380px;
  height: 560px;
  max-height: min(560px, calc(100vh - 2rem));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--chat-bg);
  color: var(--chat-fg);
  border-radius: var(--chat-radius);
  box-shadow: var(--qchat-shadow);
  transform-origin: bottom right;
  animation: qchat-in 220ms ease;
}

.qchat__panel[hidden] {
  display: none;
}

@keyframes qchat-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- header ---------------------------------------------------------- */

.qchat__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: var(--chat-accent);
  color: var(--chat-accent-fg);
}

.qchat__header-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  background: var(--chat-accent-fg);
  -webkit-mask: var(--chat-icon) center / contain no-repeat;
  mask: var(--chat-icon) center / contain no-repeat;
}

.qchat__title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.qchat__status {
  margin-left: auto;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.qchat__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.qchat__close {
  color: inherit;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--chat-radius);
  font-size: 1.35rem;
  line-height: 1;
}

/* ---- message log ----------------------------------------------------- */

.qchat__log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.qchat__msg {
  max-width: 82%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--chat-radius);
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: var(--qchat-shadow-sm);
}

.qchat__msg--bot {
  align-self: flex-start;
  background: var(--chat-bubble-bot);
  color: var(--chat-fg);
  border-bottom-left-radius: 0;
}

.qchat__msg--user {
  align-self: flex-end;
  background: var(--chat-bubble-user);
  color: var(--chat-fg);
  border-bottom-right-radius: 0;
}

/* ---- suggestion chips ------------------------------------------------ */

.qchat__chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem 1rem 0;
}

.qchat__chip {
  font-family: inherit;
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 0.45rem 0.7rem;
  border-radius: var(--chat-radius);
  color: var(--chat-accent);
  background: transparent;
  border: 1px solid var(--chat-accent);
  transition: background 140ms ease, color 140ms ease;
}

.qchat__chip:hover {
  background: var(--chat-accent);
  color: var(--chat-accent-fg);
}

/* ---- disabled input -------------------------------------------------- */

.qchat__input {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 1rem 1rem;
}

.qchat__field {
  flex: 1 1 auto;
  padding: 0.6rem 0.8rem;
  border-radius: var(--chat-radius);
  border: 1px solid color-mix(in srgb, var(--chat-fg) 22%, transparent);
  background: color-mix(in srgb, var(--chat-fg) 5%, transparent);
  color: var(--chat-fg);
  font-size: 0.85rem;
  cursor: not-allowed;
}

.qchat__field::placeholder {
  color: var(--chat-fg);
  opacity: 0.55;
}

.qchat__send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--chat-radius);
  background: var(--chat-accent);
  color: var(--chat-accent-fg);
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- focus (visible everywhere) -------------------------------------- */

#quana-chat :focus-visible {
  outline: 2px solid var(--chat-accent);
  outline-offset: 2px;
}

.qchat__bubble:focus-visible {
  outline-offset: 3px;
}

/* ---- full-screen sheet below 640px ----------------------------------- */

@media (max-width: 640px) {
  .qchat__panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qchat__panel { animation: none; }
  .qchat__bubble { transition: none; }
  .qchat__bubble:hover { transform: none; }
}
