/* The public website's chat widget (chatbot, static/website_chatbot/chat.js). Takes the theme's colours where the theme
   has them; Bot.accent_color overrides the accent. A theme can name the accent with --chat-accent. The accent carries
   white text, so it must be dark: --4-color, not the pale --1-color of the numbered palettes. */
.ns-chat {
    --ns-chat-accent-default: var(--chat-accent, var(--4-color, var(--orange, var(--lapis, var(--link, #2b5797)))));
    --ns-chat-bg: var(--white-color, var(--white, var(--paper, #ffffff)));
    --ns-chat-ink: var(--text-color, var(--ink, #1d232b));
    --ns-chat-muted: var(--muted-color, var(--muted, #5e6b78));
    --ns-chat-line: var(--line, rgba(0, 0, 0, 0.15));
    position: fixed;
    bottom: 1rem;
    z-index: 990;
    font-family: var(--font-sans, var(--font-body, system-ui, sans-serif));
    color: var(--ns-chat-ink);
}
.ns-chat--right { right: 1rem; }
.ns-chat--left { left: 1rem; }

.ns-chat__launcher,
.ns-chat__send {
    background: var(--ns-chat-accent, var(--ns-chat-accent-default));
    color: #fff;
    border: 0;
}
.ns-chat__launcher {
    display: block;
    margin-left: auto;
    padding: 0.7rem 1.1rem;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
.ns-chat--left .ns-chat__launcher { margin-left: 0; }
.ns-chat.is-open .ns-chat__launcher { display: none; }

.ns-chat__panel {
    display: flex;
    flex-direction: column;
    width: min(23rem, calc(100vw - 2rem));
    height: min(32rem, calc(100vh - 2rem));
    background: var(--ns-chat-bg);
    border: 1px solid var(--ns-chat-line);
    border-radius: var(--radius, 10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}
.ns-chat__panel[hidden] { display: none; }

.ns-chat__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: var(--ns-chat-accent, var(--ns-chat-accent-default));
    color: #fff;
}
.ns-chat__title { flex: 1; margin: 0; font-size: 1rem; color: inherit; font-family: inherit; }
.ns-chat__close {
    background: transparent;
    border: 0;
    color: inherit;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.ns-chat__log {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.ns-chat__msg { max-width: 88%; }
.ns-chat__msg--visitor { align-self: flex-end; }
.ns-chat__text {
    margin: 0;
    padding: 0.5rem 0.7rem;
    border-radius: 0.8rem;
    background: rgba(0, 0, 0, 0.06);
    white-space: pre-line;
    line-height: 1.4;
    font-size: 0.92rem;
}
.ns-chat__msg--visitor .ns-chat__text {
    background: var(--ns-chat-accent, var(--ns-chat-accent-default));
    color: #fff;
}
.ns-chat__link { display: inline-block; margin-top: 0.3rem; font-size: 0.85rem; }
.ns-chat__choices { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.ns-chat__choice {
    font: inherit;
    font-size: 0.85rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--ns-chat-accent, var(--ns-chat-accent-default));
    background: transparent;
    color: var(--ns-chat-ink);
    cursor: pointer;
    text-align: left;
}
.ns-chat__choice--primary {
    display: inline-block;
    margin-top: 0.4rem;
    background: var(--ns-chat-accent, var(--ns-chat-accent-default));
    color: #fff;
    font-weight: 600;
}
.ns-chat a.ns-chat__choice--primary,
.ns-chat a.ns-chat__choice--primary:hover,
.ns-chat a.ns-chat__choice--primary:visited { color: #fff; text-decoration: none; }
.ns-chat__rate { margin-top: 0.3rem; font-size: 0.8rem; color: var(--ns-chat-muted); }
.ns-chat__rate-btn {
    background: transparent;
    border: 1px solid var(--ns-chat-line);
    border-radius: 6px;
    margin-right: 0.25rem;
    padding: 0.1rem 0.4rem;
    color: var(--ns-chat-ink);
    cursor: pointer;
}
.ns-chat__typing { margin: 0; color: var(--ns-chat-muted); }

.ns-chat__form {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem;
    border-top: 1px solid var(--ns-chat-line);
}
.ns-chat__input {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: 0.92rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--ns-chat-line);
    border-radius: 6px;
    background: #fff;
    color: #1d232b;
}
.ns-chat__send {
    font: inherit;
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    cursor: pointer;
}
.ns-chat__send:disabled { opacity: 0.6; cursor: default; }

.ns-chat__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ns-chat button:focus-visible,
.ns-chat a:focus-visible,
.ns-chat input:focus-visible,
.ns-chat textarea:focus-visible,
.ns-chat__log:focus-visible {
    outline: 3px solid var(--ns-chat-accent, var(--ns-chat-accent-default));
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .ns-chat { bottom: 0.5rem; }
    .ns-chat--right { right: 0.5rem; }
    .ns-chat--left { left: 0.5rem; }
    .ns-chat__panel { width: calc(100vw - 1rem); height: calc(100vh - 1rem); }
}

@media (prefers-reduced-motion: reduce) {
    .ns-chat * { scroll-behavior: auto; }
}
