/*
 * The site chatbot's widget (DST #334). Source of truth: build/chat/widget.css.
 * A site sets its look through --chat-* on :root in its own stylesheet; the
 * fallbacks are Workdome's token names.
 */
.dst-chat-open,
.dst-chat-panel {
  --_accent: var(--chat-accent, var(--primary, #105fff));
  --_on-accent: var(--chat-on-accent, var(--primary-fg, #ffffff));
  --_bg: var(--chat-bg, var(--bg, #ffffff));
  --_fg: var(--chat-fg, var(--fg, #0a0a0a));
  --_muted: var(--chat-muted, var(--muted, #525252));
  --_line: var(--chat-line, var(--border, #e5e5e5));
  --_soft: var(--chat-soft, var(--surface, #f3f4f6));
  font-family: inherit;
}

.dst-chat-open[hidden],
.dst-chat-panel[hidden] { display: none; }

.dst-chat-open {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--_accent);
  color: var(--_on-accent);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}

.dst-chat-open .dst-chat-dot { fill: var(--_accent); }

/* The cookie banner sits at the bottom of the screen and is removed once the
 * visitor chooses; keep the chat button out of its way until then. */
body:has(> .consent) .dst-chat-open { display: none; }

.dst-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 901;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  height: min(590px, calc(100vh - 40px));
  height: min(590px, calc(100dvh - 40px));
  border: 1px solid var(--_line);
  border-radius: 14px;
  background: var(--_bg);
  color: var(--_fg);
  font-size: 15px;
  line-height: 1.45;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.dst-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 16px;
  background: var(--_accent);
  color: var(--_on-accent);
}

.dst-chat-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.dst-chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
}

.dst-chat-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dst-chat-user {
  align-self: flex-end;
  background: var(--_accent);
  color: var(--_on-accent);
}

.dst-chat-bot {
  align-self: flex-start;
  background: var(--_soft);
  color: var(--_fg);
}

.dst-chat-pending { color: var(--_muted); }

.dst-chat-msg a { color: inherit; text-decoration: underline; }

.dst-chat-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--_line);
  color: var(--_muted);
  font-size: 14px;
}

.dst-chat-suggest {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.dst-chat-suggest button {
  padding: 7px 12px;
  border: 1px solid var(--_accent);
  border-radius: 999px;
  background: transparent;
  color: var(--_fg);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.dst-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--_line);
}

.dst-chat-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 110px;
  padding: 9px 10px;
  border: 1px solid var(--_line);
  border-radius: 8px;
  background: var(--_bg);
  color: var(--_fg);
  font: inherit;
  /* 16px stops iOS zooming the page when the field takes focus. */
  font-size: 16px;
  resize: none;
}

.dst-chat-send {
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--_accent);
  color: var(--_on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.dst-chat-send:disabled { opacity: 0.55; cursor: default; }

.dst-chat-notice {
  margin: 0;
  padding: 0 12px 8px;
  text-align: right;
  color: var(--_muted);
  font-size: 14px;
  line-height: 1.35;
}

.dst-chat-notice a { color: inherit; text-decoration: underline; }

.dst-chat-open:focus-visible,
.dst-chat-close:focus-visible,
.dst-chat-send:focus-visible,
.dst-chat-suggest button:focus-visible,
.dst-chat-form textarea:focus-visible,
.dst-chat-log:focus-visible,
.dst-chat-panel a:focus-visible {
  outline: 2px solid var(--_fg);
  outline-offset: 2px;
}

@media print {
  .dst-chat-open,
  .dst-chat-panel { display: none; }
}
