/* Live chat bubble and panel (public/helpdesk-chat.js). Uses the helpdesk tokens. */
.hd-chat {
  --chat-brand: #001B3F;
  --chat-accent: #951A81;
  --chat-surface: var(--surface, #fff);
  --chat-ink: var(--ink-950, #0f172a);
  --chat-muted: var(--ink-500, #6b5b66);
  --chat-line: var(--ink-200, #e6dce2);
  --chat-mine: #e8eef8;
  --chat-theirs: #f6f1f4;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  font-family: inherit;
}
.hd-chat-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--chat-brand);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  box-shadow: 0 6px 20px rgba(0, 27, 63, 0.25);
  cursor: pointer;
  position: relative;
}
.hd-chat-bubble:focus-visible { outline: 3px solid var(--chat-accent); outline-offset: 2px; }
.hd-chat.is-open .hd-chat-bubble { display: none; }
.hd-chat-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid var(--chat-brand);
}
.hd-chat-panel {
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(560px, calc(100vh - 40px));
  background: var(--chat-surface);
  color: var(--chat-ink);
  border: 1px solid var(--chat-line);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 27, 63, 0.22);
  overflow: hidden;
}
.hd-chat-panel[hidden] { display: none; }
.hd-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--chat-brand);
  color: #fff;
}
.hd-chat-title { flex: 1; font-size: 15px; }
.hd-chat-end {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.hd-chat-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  width: 36px;
  height: 36px;
  cursor: pointer;
  border-radius: 8px;
}
.hd-chat-end:focus-visible, .hd-chat-close:focus-visible { outline: 2px solid #fff; }
.hd-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hd-chat-msg { max-width: 85%; }
.hd-chat-msg.is-mine { align-self: flex-end; }
.hd-chat-msg.is-theirs { align-self: flex-start; }
.hd-chat-msg.is-system { align-self: center; color: var(--chat-muted); font-size: 13px; text-align: center; }
.hd-chat-meta { font-size: 12px; color: var(--chat-muted); margin: 0 4px 3px; }
.hd-chat-msg.is-mine .hd-chat-meta { text-align: right; }
.hd-chat-text {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.hd-chat-msg.is-mine .hd-chat-text { background: var(--chat-mine); border-bottom-right-radius: 4px; }
.hd-chat-msg.is-theirs .hd-chat-text { background: var(--chat-theirs); border-bottom-left-radius: 4px; }
.hd-chat-text img { max-width: 100%; height: auto; border-radius: 6px; }
.hd-chat-text ul, .hd-chat-text ol { margin: 4px 0; padding-left: 20px; }
.hd-chat-msg.is-summary {
  align-self: stretch;
  max-width: none;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fbeaf7;
  border: 1px solid #e7b6dc;
  font-size: 14px;
  line-height: 1.5;
}
.hd-chat-msg.is-summary ul { margin: 6px 0 0; padding-left: 20px; }
.hd-chat-msg.is-summary > br { display: none; }
.hd-chat-msg.is-summary > strong:first-child { display: block; font-weight: 700; color: #5b0f4e; }
.hd-chat-ended { border-top: 1px solid var(--chat-line); padding-top: 12px; }
.hd-chat-ok { margin: 8px 0 0; color: #047857; font-size: 14px; font-weight: 600; }
.hd-chat-notice { font-size: 14px; line-height: 1.5; color: var(--chat-ink); }
.hd-chat-notice p { margin: 0 0 12px; }
.hd-chat-notice.is-soft { color: var(--chat-muted); text-align: center; font-size: 13px; }
.hd-chat-notice a { color: #265CB6; font-weight: 600; margin-left: 4px; }
.hd-chat-first, .hd-chat-compose textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--chat-line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--chat-ink);
  resize: none;
}
.hd-chat-first { margin-bottom: 12px; min-height: 88px; height: 88px; }
.hd-chat-compose textarea { min-height: 44px; height: 64px; max-height: 120px; }
.hd-chat-first:focus, .hd-chat-compose textarea:focus { outline: 2px solid var(--chat-accent); outline-offset: 0; border-color: transparent; }
.hd-chat-primary, .hd-chat-send {
  border: 0;
  border-radius: 10px;
  background: var(--chat-brand);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  padding: 12px 16px;
  cursor: pointer;
}
.hd-chat-primary:disabled, .hd-chat-send:disabled { opacity: 0.6; cursor: default; }
.hd-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--chat-line);
}
.hd-chat-compose[hidden] { display: none; }
.hd-chat-error { grid-column: 1 / -1; margin: 0; color: #b91c1c; font-size: 13px; }
.hd-chat-error[hidden] { display: none; }

@media (max-width: 600px) {
  .hd-chat { right: 16px; bottom: 16px; }
  .hd-chat.is-open { inset: 0; }
  .hd-chat-panel {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
  }
}

/* Embedded in the one chat bubble (ChatWidget.astro, tab "Colleague") */
.hd-chat.is-embedded {
  position: static;
  inset: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.hd-chat.is-embedded .hd-chat-panel {
  width: auto;
  height: auto;
  flex: 1;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.hd-chat.is-embedded .hd-chat-head {
  background: transparent;
  color: var(--chat-ink);
  border-bottom: 1px solid var(--chat-line);
  padding: 8px 14px;
}
.hd-chat.is-embedded .hd-chat-title { font-size: 14px; }
.hd-chat.is-embedded .hd-chat-end { color: var(--chat-brand); border-color: var(--chat-line); }
.hd-chat.is-embedded .hd-chat-end:focus-visible { outline: 2px solid var(--chat-accent); }
@media (max-width: 600px) {
  .hd-chat.is-embedded, .hd-chat.is-embedded.is-open { inset: auto; }
  .hd-chat.is-embedded .hd-chat-panel { height: auto; }
}

/* Embedded: take the colours of the host (Starlight light and dark theme). */
.hd-chat.is-embedded {
  --chat-surface: var(--sl-color-bg, #fff);
  --chat-ink: var(--sl-color-text, #0f172a);
  --chat-muted: var(--sl-color-gray-3, #6b5b66);
  --chat-line: var(--sl-color-gray-5, #e6dce2);
}
.hd-chat-first, .hd-chat-compose textarea { background: var(--chat-surface); }
:root[data-theme="dark"] .hd-chat.is-embedded {
  --chat-mine: #1f3556;
  --chat-theirs: #2b2f38;
  --chat-brand: #3b6fd1;
}
:root[data-theme="dark"] .hd-chat.is-embedded .hd-chat-msg.is-summary {
  background: #3a1d35;
  border-color: #6b2f60;
  color: var(--chat-ink);
}
:root[data-theme="dark"] .hd-chat.is-embedded .hd-chat-msg.is-summary > strong:first-child { color: #f3c4e9; }
:root[data-theme="dark"] .hd-chat.is-embedded .hd-chat-notice a { color: #8fb4ff; }
