.website-help-chat {
    bottom: 1.5rem;
    font-family: system-ui, sans-serif;
    font-size: 0.9em;
    position: fixed;
    right: 1.5rem;
    z-index: 1000;
}

/* ── Host-site reset ─────────────────────────────────────────────────
   Hosts routinely set global rules on button / input / ul / li / a
   that leak into the widget (text-transform, shadows, list bullets,
   funky underlines). These rules pin sensible defaults inside the
   widget so the component styles below have a clean canvas. Doubled
   selectors (parent + child) lift specificity above most host themes
   without reaching for !important. */
.website-help-chat,
.website-help-chat *,
.website-help-chat *::before,
.website-help-chat *::after {
    box-sizing: border-box;
}

.website-help-chat button {
    font: inherit;
    color: inherit;
    margin: 0;
    text-transform: none;
    letter-spacing: normal;
    text-shadow: none;
    box-shadow: none;
    line-height: 1.2;
    -webkit-appearance: none;
    appearance: none;
}

.website-help-chat input,
.website-help-chat textarea,
.website-help-chat select {
    font: inherit;
    color: inherit;
    background: #fff;
    margin: 0;
    line-height: 1.4;
    text-transform: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.website-help-chat ul,
.website-help-chat ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.website-help-chat li {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.website-help-chat a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    background: transparent;
}

.website-help-chat a:hover {
    text-decoration-thickness: 2px;
}

.website-help-chat__toggle {
    align-items: center;
    background: #1463ff;
    border: 0;
    border-radius: 999px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    gap: 0.5rem;
    font: inherit;
    padding: 0.75rem 1rem;
}

.website-help-chat .website-help-chat__toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px #1463ff;
}

/* Screen-reader-only utility — used by the textarea label. Independent of
   Contao's .invisible class so the widget works on any host theme. */
.website-help-chat .website-help-chat__visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.website-help-chat__avatar {
    aspect-ratio: 1;
    border-radius: 999px;
    display: block;
    flex: 0 0 auto;
    height: 2rem;
    object-fit: cover;
    width: 2rem;
}

.website-help-chat__toggle .website-help-chat__avatar {
    border: 2px solid rgb(255 255 255 / 58%);
    height: 1.8rem;
    width: 1.8rem;
}

.website-help-chat__panel[hidden],
.website-help-chat__toggle[hidden] {
    display: none !important;
}

.website-help-chat--open .website-help-chat__toggle {
    display: none;
}

.website-help-chat__panel {
    background: #fff;
    border: 1px solid #d7dce2;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgb(0 0 0 / 16%);
    margin-bottom: 0.75rem;
    max-width: min(24rem, calc(100vw - 3rem));
    width: 24rem;
}

.website-help-chat__panel-head {
    align-items: center;
    border-bottom: 1px solid #e7ebef;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem 0.5rem 1rem;
}

.website-help-chat__identity {
    align-items: center;
    display: flex;
    gap: 0.6rem;
    min-width: 0;
}

.website-help-chat__title {
    color: #172033;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.website-help-chat .website-help-chat__minimize {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: #172033;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    height: 2rem;
    justify-content: center;
    padding: 0;
    width: 2rem;
    min-width: 2rem;
}

.website-help-chat .website-help-chat__minimize:hover {
    background: #eef2f7;
}

.website-help-chat .website-help-chat__minimize:focus-visible {
    background: #eef2f7;
    outline: 2px solid #1463ff;
    outline-offset: 2px;
}

.website-help-chat .website-help-chat__minimize span {
    background: currentcolor;
    border-radius: 999px;
    display: block;
    height: 2px;
    width: 0.9rem;
}

.website-help-chat__messages {
    max-height: 24rem;
    overflow: auto;
    padding: 1rem;
}

.website-help-chat__message {
    line-height: 1.45;
    margin: 0 0 0.6rem;
    max-width: 82%;
    width: fit-content;
    padding: 0.5rem 0.75rem;
    border-radius: 16px;
    overflow-wrap: anywhere;
}

/* Preserve newlines in the message text only — not on the bubble itself,
   so template indentation between <strong> and <span> isn't rendered as
   visible whitespace before the welcome greeting. */
.website-help-chat .website-help-chat__message-text {
    white-space: pre-wrap;
}

.website-help-chat__message:last-child {
    margin-bottom: 0;
}

/* Sender label ("You:" / "Oliver:") — the bubble side and colour already
   convey who is speaking, so hide it visually but keep it for screen readers. */
.website-help-chat__message strong {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Assistant: left-aligned grey bubble. Colours come from the profile when
   set (--hc-assistant-bg / --hc-assistant-fg), otherwise the defaults. */
.website-help-chat__message--assistant {
    background: var(--hc-assistant-bg, #f1f3f6);
    color: var(--hc-assistant-fg, #172033);
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

/* Visitor: right-aligned brand-blue bubble (matches the launcher). */
.website-help-chat__message--visitor {
    background: var(--hc-visitor-bg, #1463ff);
    color: var(--hc-visitor-fg, #fff);
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.website-help-chat__message--error {
    background: #fdecea;
    color: #b00020;
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

/* Blinking caret shown at the end of an assistant message while it
   "types" itself out. Lives on the text-wrap span so it sits right after
   the text — not after the <hr>/<ul> citation block appended inside the
   bubble. The class toggles on the bubble during typing. */
.website-help-chat__message--typing .website-help-chat__message-text::after {
    content: '';
    display: inline-block;
    width: 0.45em;
    height: 1em;
    margin-left: 1px;
    vertical-align: -0.15em;
    background: currentcolor;
    opacity: 0.55;
    animation: website-help-chat-caret 1s steps(1) infinite;
}

@keyframes website-help-chat-caret {
    50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .website-help-chat__message--typing .website-help-chat__message-text::after {
        animation: none;
    }
}

/* ── Thinking indicator ───────────────────────────────────────────
   Shown in a pending assistant bubble while the model is composing a
   reply. Three small dots bounce in sequence — sized small so they fit
   the bubble nicely. */
.website-help-chat .website-help-chat__thinking-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    vertical-align: middle;
    padding: 0.15em 0;
}

.website-help-chat .website-help-chat__thinking-dots span {
    animation: website-help-chat-dot 1.2s infinite ease-in-out;
    background: currentcolor;
    border-radius: 999px;
    height: 6px;
    opacity: 0.4;
    width: 6px;
}

.website-help-chat .website-help-chat__thinking-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.website-help-chat .website-help-chat__thinking-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes website-help-chat-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Sweep mode: a Siri-style rotating gradient runs around the panel
   border while thinking. The trick — a two-layer background where the
   padding-box layer covers the inside in white and the border-box layer
   holds a rotating conic-gradient that only the 1px border shows
   through. Border colour switches to transparent so the conic peeks
   through; everything else (radius, shadow, size) is unchanged so the
   layout doesn't shift on/off. */
@property --hc-thinking-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.website-help-chat--thinking-sweep .website-help-chat__panel {
    background:
        linear-gradient(#fff, #fff) padding-box,
        conic-gradient(
            from var(--hc-thinking-angle),
            #d7dce2 0deg,
            var(--hc-link, #0e51d3) 60deg,
            #d7dce2 140deg,
            #d7dce2 360deg
        ) border-box;
    border-color: transparent;
    border-width: 3px;
    animation: website-help-chat-sweep 2s linear infinite;
}

@keyframes website-help-chat-sweep {
    to { --hc-thinking-angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
    .website-help-chat .website-help-chat__thinking-dots span {
        animation: none;
        opacity: 0.6;
    }

    .website-help-chat--thinking-sweep .website-help-chat__panel {
        animation: none;
    }
}

/* Subtle divider inside the assistant bubble between the answer text and
   its citation list. Uses currentColor so it tints with the bubble's text. */
.website-help-chat .website-help-chat__bubble-divider {
    border: 0;
    border-top: 1px solid currentcolor;
    height: 0;
    margin: 0.55rem 0 0.4rem;
    opacity: 0.18;
}

/* Citation list inside an assistant bubble. Bullets are our own (custom
   ::before dot) so the host site's li::marker / list-style / margins
   can't change the look. The link colour comes from --hc-link so the
   profile setting wins. */
.website-help-chat .website-help-chat__links {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
}

.website-help-chat .website-help-chat__links li {
    border: 0;
    line-height: 1.4;
    margin: 0 0 0.2rem;
    padding: 0 0 0 1rem;
    position: relative;
}

.website-help-chat .website-help-chat__links li::before {
    background: currentcolor;
    border-radius: 999px;
    content: '';
    height: 4px;
    left: 0.25rem;
    opacity: 0.45;
    position: absolute;
    top: 0.6em;
    width: 4px;
}

.website-help-chat .website-help-chat__links a {
    color: var(--hc-link, #0e51d3);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    word-break: break-word;
}

.website-help-chat .website-help-chat__links a:hover {
    text-decoration-thickness: 2px;
}

.website-help-chat .website-help-chat__links a:focus-visible {
    outline: 2px solid var(--hc-link, #0e51d3);
    outline-offset: 2px;
    border-radius: 2px;
}

.website-help-chat__feedback {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: -0.25rem 0 0.75rem;
}

.website-help-chat .website-help-chat__feedback button {
    background: #fff;
    border: 1px solid #d7dce2;
    border-radius: 999px;
    color: #374151;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    height: auto;
    min-height: 0;
    padding: 0.3rem 0.85rem;
    transition: background-color .15s, border-color .15s, color .15s;
}

.website-help-chat .website-help-chat__feedback button:hover {
    background: #f3f6fa;
    border-color: #c5cdd5;
}

.website-help-chat .website-help-chat__feedback button:focus-visible {
    outline: 2px solid #1463ff;
    outline-offset: 2px;
}

.website-help-chat .website-help-chat__feedback button:disabled {
    opacity: 0.65;
    cursor: default;
}

.website-help-chat__feedback-status {
    flex-basis: 100%;
    font-size: 0.875rem;
}

.website-help-chat__form {
    border-top: 1px solid #e7ebef;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.website-help-chat .website-help-chat__form textarea {
    background: #fff;
    border: 1px solid #d7dce2;
    border-radius: 6px;
    color: #172033;
    display: block;
    /* iOS Safari auto-zooms (and shifts the underlying page) when a focused
       input has a font-size < 16px. Lock the textarea to 16px so the page
       behind the chat doesn't move when the visitor taps in to type. */
    font-size: max(16px, 1em);
    min-height: 3.4em;
    padding: 0.45rem 0.65rem;
    resize: none;
    width: 100%;
}

.website-help-chat .website-help-chat__form textarea:focus {
    border-color: #1463ff;
    box-shadow: 0 0 0 2px rgba(20, 99, 255, 0.18);
    outline: none;
}

.website-help-chat .website-help-chat__form button[type="submit"] {
    background: var(--hc-send-bg, #1463ff);
    border: 0;
    border-radius: 6px;
    color: var(--hc-send-fg, #fff);
    cursor: pointer;
    display: block;
    font-weight: 600;
    padding: 0.5rem 0.95rem;
    width: 100%;
}

.website-help-chat .website-help-chat__form button[type="submit"]:hover {
    background: var(--hc-send-hover, #0e51d3);
}

.website-help-chat .website-help-chat__form button[type="submit"]:focus-visible {
    outline: 2px solid #1463ff;
    outline-offset: 2px;
}

.website-help-chat .website-help-chat__form button[type="submit"]:disabled {
    cursor: wait;
    opacity: 0.65;
}

.website-help-chat__form--loading {
    opacity: 0.72;
}

/* ── Contact form fallback ────────────────────────────────────────
   Replaces the chat input when the LLM is unavailable. Three stacked
   fields (name / email / message) + submit, with inline status text. */

.website-help-chat__contact {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.85rem;
    border-top: 1px solid #e7ebef;
    background: #fafbfc;
}

.website-help-chat__contact-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.website-help-chat__contact-field span {
    font-weight: 600;
    color: #374151;
}

.website-help-chat__contact-field input,
.website-help-chat__contact-field textarea {
    padding: 0.4rem 0.55rem;
    border: 1px solid #d4d4d4;
    border-radius: 4px;
    font: inherit;
    /* Same iOS-Safari auto-zoom guard as the chat textarea above. */
    font-size: max(16px, 1em);
    width: 100%;
    box-sizing: border-box;
}

.website-help-chat .website-help-chat__contact-field input:focus,
.website-help-chat .website-help-chat__contact-field textarea:focus {
    border-color: #1463ff;
    box-shadow: 0 0 0 2px rgba(20, 99, 255, 0.18);
    outline: none;
}

.website-help-chat__contact-field textarea {
    resize: vertical;
    min-height: 70px;
}

.website-help-chat__contact-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.website-help-chat__contact-submit {
    padding: 0.45rem 1rem;
    background: #2e6ebf;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
}

.website-help-chat__contact-submit:hover {
    background: #1d4f99;
}

.website-help-chat__contact-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.website-help-chat .website-help-chat__contact-submit:focus-visible {
    outline: 2px solid #1463ff;
    outline-offset: 2px;
}

.website-help-chat__contact-status {
    font-size: 0.8rem;
    color: #6b7280;
}

.website-help-chat__contact-thanks {
    padding: 1rem;
    border-top: 1px solid #e7ebef;
    background: #f1faf3;
    color: #15803d;
    font-weight: 500;
}

/* ── Source highlight ──────────────────────────────────────────────
   Applied to <mark> wrappers when a visitor follows a chat citation.
   Double-flashes to grab attention, then settles into a soft highlight
   so the cited passage stays findable. Site-agnostic colours. */
mark.website-help-chat-highlight {
    color: inherit;
    background-color: rgba(255, 214, 0, 0.45);
    border-radius: 2px;
    padding: 0.05em 0.05em;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    animation: website-help-chat-flash 2.8s ease both;
}

@keyframes website-help-chat-flash {
    0%   { background-color: rgba(255, 214, 0, 0); box-shadow: 0 0 0 0 rgba(255, 196, 0, 0); }
    12%  { background-color: rgba(255, 214, 0, 0.95); box-shadow: 0 0 0 6px rgba(255, 196, 0, 0.4); }
    30%  { background-color: rgba(255, 214, 0, 0.35); box-shadow: 0 0 0 0 rgba(255, 196, 0, 0); }
    52%  { background-color: rgba(255, 214, 0, 0.95); box-shadow: 0 0 0 5px rgba(255, 196, 0, 0.3); }
    100% { background-color: rgba(255, 214, 0, 0.4); box-shadow: 0 0 0 0 rgba(255, 196, 0, 0); }
}

@media (prefers-reduced-motion: reduce) {
    mark.website-help-chat-highlight {
        animation: none;
        background-color: rgba(255, 214, 0, 0.5);
    }
}
