/* help-chat-widget.css — B10 H1 live-chat widget.
   Semantic tokens only (no raw dark/light values) so it reads correctly in
   every theme. Fixed bottom-right; panel is a card with a token border. */

/* The panel, start form, and conversation all use display:flex, which would
   otherwise override the [hidden] attribute and leave them visible. Force
   hidden to win so the start form actually disappears when the chat opens
   (otherwise the compose box stacks underneath it). */
#hcw [hidden] { display: none !important; }

.hcw {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1200;
    font-size: 14px;
    font-family: var(--hcw-font, inherit);
    /* Accent: tenant-chosen colour if set, else the theme primary. One alias so
       every accented surface (launcher, header, buttons, visitor bubble) tracks it. */
    --hcw-c: var(--hcw-accent, var(--color-primary, #2c7cff));
}

/* Admin-selected bottom-left placement. The launcher + panel have no fixed
   width, so flipping the anchor side re-aligns both to the left edge. */
.hcw--bl { right: auto; left: 20px; }

/* Honeypot — off-screen, never shown, not focusable. Bots fill it; humans don't. */
.hcw__hp { position: absolute !important; left: -9999px !important; top: auto; width: 1px; height: 1px; overflow: hidden; }
.hcw__captcha strong { font-weight: 700; }

/* Embedded on an external site there's no tenant theme to inherit, so the admin
   picks light (default, via the token fallbacks) or dark. 'auto' follows the OS. */
.hcw[data-theme="dark"] {
    --color-bg-card: #1c2330;
    --color-text-primary: #e7ecf3;
    --color-text-secondary: #aeb8c8;
    --color-text-muted: #93a0b4;
    --color-border: rgba(255, 255, 255, 0.14);
    --color-bg-input: #232c3c;
    --color-bg-elevated: rgba(255, 255, 255, 0.08);
}
@media (prefers-color-scheme: dark) {
    .hcw[data-theme="auto"] {
        --color-bg-card: #1c2330;
        --color-text-primary: #e7ecf3;
        --color-text-secondary: #aeb8c8;
        --color-text-muted: #93a0b4;
        --color-border: rgba(255, 255, 255, 0.14);
        --color-bg-input: #232c3c;
        --color-bg-elevated: rgba(255, 255, 255, 0.08);
    }
}

.hcw__launcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: var(--hcw-rl, 999px);
    background: var(--hcw-c);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.hcw__launcher:hover { filter: brightness(1.05); }
.hcw__launcher i { font-size: 16px; }
.hcw.is-open .hcw__launcher { display: none; }

.hcw__panel {
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 460px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: var(--color-bg-card, #fff);
    color: var(--color-text-primary, #1c2330);
    border: 1px solid var(--color-border, rgba(15, 23, 42, 0.12));
    border-radius: var(--hcw-rp, 14px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.hcw__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--hcw-c);
    color: #fff;
}
.hcw__title { font-weight: 700; }
.hcw__close {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.85;
}
.hcw__close:hover { opacity: 1; }

.hcw__start { padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.hcw__intro { margin: 0 0 4px; color: var(--color-text-secondary, #51607a); }
.hcw__field { display: flex; flex-direction: column; gap: 4px; }
.hcw__field span { font-size: 12px; font-weight: 600; color: var(--color-text-muted, #5b6477); }
.hcw__field input,
.hcw__field textarea,
.hcw__compose textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--color-border, rgba(15, 23, 42, 0.15));
    border-radius: 8px;
    background: var(--color-bg-input, var(--color-bg-card, #fff));
    color: var(--color-text-primary, #1c2330);
    font: inherit;
    box-sizing: border-box;
    resize: none;
}
.hcw__field input:focus,
.hcw__field textarea:focus,
.hcw__compose textarea:focus {
    outline: none;
    border-color: var(--hcw-c);
}

.hcw__btn,
.hcw__send {
    border: none;
    border-radius: 8px;
    background: var(--hcw-c);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.hcw__btn { padding: 10px 14px; }
.hcw__btn:hover { filter: brightness(1.05); }

.hcw__error { margin: 0; color: var(--color-danger, #d6455d); font-size: 13px; }

.hcw__convo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hcw__messages {
    list-style: none;
    margin: 0;
    padding: 14px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.hcw__msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: var(--hcw-rb, 12px);
    line-height: 1.4;
    word-wrap: break-word;
}
.hcw__msg p { margin: 0; }
.hcw__msg--visitor {
    align-self: flex-end;
    background: var(--hcw-c);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.hcw__msg--agent {
    align-self: flex-start;
    background: var(--color-bg-elevated, rgba(127, 127, 127, 0.12));
    color: var(--color-text-primary, #1c2330);
    border-bottom-left-radius: 3px;
}
.hcw__msg--system {
    align-self: center;
    background: transparent;
    color: var(--color-text-muted, #5b6477);
    font-size: 12px;
    font-style: italic;
}
.hcw__msg-who { display: block; font-size: 11px; font-weight: 700; opacity: 0.8; margin-bottom: 2px; }

.hcw__compose {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--color-border, rgba(15, 23, 42, 0.1));
}
.hcw__compose textarea { flex: 1; max-height: 96px; }
.hcw__send { padding: 0 14px; }
.hcw__send:hover { filter: brightness(1.05); }

.hcw__end {
    background: none;
    border: none;
    color: var(--color-text-muted, #5b6477);
    font-size: 12px;
    padding: 6px 12px 12px;
    cursor: pointer;
    text-align: center;
}
.hcw__end:hover { color: var(--color-danger, #d6455d); }

@media (max-width: 480px) {
    .hcw { right: 12px; bottom: 12px; }
    .hcw--bl { right: auto; left: 12px; }
    .hcw__panel { width: calc(100vw - 24px); height: calc(100vh - 24px); }
}
