/* Public Live Chat assistant widget. All rules are scoped under #assisto-livechat so they can be
   dropped onto any Assisto host page (Marketing, public ReportView) without clashing. */

#assisto-livechat,
#assisto-livechat * {
    box-sizing: border-box;
}

#assisto-livechat {
    --alc-accent: var(--assisto-primary, #0ba292);
    --alc-accent-hover: var(--assisto-primary-focus, #0b8f81);
    --alc-accent-contrast: #ffffff;
    --alc-bg: #ffffff;
    --alc-fg: #1c2330;
    --alc-muted: #6b7280;
    --alc-border: #e5e7eb;
    --alc-user-bg: var(--assisto-primary, #0ba292);
    --alc-user-fg: #ffffff;
    --alc-bot-bg: #f3f4f6;
    --alc-bot-fg: #1c2330;
    position: fixed;
    right: 20px;
    /* Sits at the bottom-right corner; the page's "back to top" arrow (report + marketing) is stacked
       just ABOVE this launcher (its bottom offset clears the ~48px pill). The panel below is anchored
       relative to this container, so it rises with the launcher. */
    bottom: 24px;
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Labeled pill launcher (icon + text) so visitors see at a glance that it's an assistant they can
   ask compliance questions. Grows leftward from the right-anchored container. */
#assisto-livechat .alc-launcher {
    width: auto;
    height: 48px;
    padding: 0 18px 0 14px;
    gap: 8px;
    border-radius: 24px;
    border: none;
    background: var(--alc-accent);
    color: var(--alc-accent-contrast);
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#assisto-livechat .alc-launcher-label {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    color: inherit;
}

#assisto-livechat .alc-launcher:hover {
    background: var(--alc-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

#assisto-livechat .alc-launcher svg {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

#assisto-livechat .alc-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    /* Account for the launcher (bottom: 24px) + panel offset (70px) so the panel never clips the top on
       short windows. */
    max-height: calc(100vh - 124px);
    background: var(--alc-bg);
    color: var(--alc-fg);
    border: 1px solid var(--alc-border);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.18s ease, height 0.18s ease;
}

#assisto-livechat.alc-open .alc-panel {
    display: flex;
}

/* Maximized: grow into a large reading pane while staying anchored to the bottom-right launcher. */
#assisto-livechat.alc-maximized .alc-panel {
    width: min(820px, calc(100vw - 40px));
    height: calc(100vh - 114px);
    max-height: calc(100vh - 114px);
}

/* Roomier message bubbles when there's width to spare. */
#assisto-livechat.alc-maximized .alc-msg {
    max-width: 78%;
}

#assisto-livechat .alc-header {
    background: var(--alc-accent);
    color: var(--alc-accent-contrast);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#assisto-livechat .alc-header-title {
    font-weight: 600;
}

#assisto-livechat .alc-header-sub {
    font-size: 12px;
    opacity: 0.85;
}

#assisto-livechat .alc-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#assisto-livechat .alc-close {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 4px;
}

#assisto-livechat .alc-clear {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
}

#assisto-livechat .alc-clear:hover {
    opacity: 1;
}

#assisto-livechat .alc-clear svg {
    width: 16px;
    height: 16px;
    display: block;
}

#assisto-livechat .alc-maximize {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
}

#assisto-livechat .alc-maximize:hover {
    opacity: 1;
}

#assisto-livechat .alc-maximize svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* One button, two glyphs: show the restore (compress) glyph only while maximized. */
#assisto-livechat .alc-maximize .alc-icon-restore { display: none; }
#assisto-livechat.alc-maximized .alc-maximize .alc-icon-maximize { display: none; }
#assisto-livechat.alc-maximized .alc-maximize .alc-icon-restore { display: block; }

#assisto-livechat .alc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#assisto-livechat .alc-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

#assisto-livechat .alc-msg-user {
    align-self: flex-end;
    background: var(--alc-user-bg);
    color: var(--alc-user-fg);
    border-bottom-right-radius: 4px;
}

#assisto-livechat .alc-msg-bot {
    align-self: flex-start;
    background: var(--alc-bot-bg);
    color: var(--alc-bot-fg);
    border-bottom-left-radius: 4px;
}

#assisto-livechat .alc-msg-error {
    align-self: center;
    background: #fff4f4;
    color: #b42318;
    border: 1px solid #f3c9c4;
    font-size: 13px;
}

#assisto-livechat .alc-msg-bot p:first-child { margin-top: 0; }
#assisto-livechat .alc-msg-bot p:last-child { margin-bottom: 0; }
#assisto-livechat .alc-msg-bot a { color: var(--alc-accent); }
#assisto-livechat .alc-msg-bot ul,
#assisto-livechat .alc-msg-bot ol { padding-left: 20px; margin: 6px 0; }
#assisto-livechat .alc-msg-bot blockquote {
    margin: 6px 0;
    padding-left: 10px;
    border-left: 3px solid var(--alc-border);
    color: var(--alc-muted);
}
#assisto-livechat .alc-msg-bot pre {
    background: #0d1117;
    color: #e6edf3;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
}
#assisto-livechat .alc-msg-bot code { font-size: 12px; }

#assisto-livechat .alc-typing {
    align-self: flex-start;
    display: none;
    gap: 4px;
    padding: 10px 12px;
}

#assisto-livechat.alc-typing-on .alc-typing { display: flex; }

#assisto-livechat .alc-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--alc-muted);
    animation: alc-bounce 1.2s infinite ease-in-out;
}

#assisto-livechat .alc-typing span:nth-child(2) { animation-delay: 0.15s; }
#assisto-livechat .alc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes alc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Transient "Searching deficiencies…" hint shown next to the typing dots while a tool runs. */
#assisto-livechat .alc-activity {
    align-self: flex-start;
    display: none;
    margin: -6px 0 0 12px;
    font-size: 12px;
    font-style: italic;
    color: var(--alc-muted);
}

#assisto-livechat.alc-activity-on .alc-activity { display: block; }

#assisto-livechat .alc-footer {
    border-top: 1px solid var(--alc-border);
    padding: 10px 12px;
}

#assisto-livechat .alc-turnstile {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

#assisto-livechat .alc-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#assisto-livechat .alc-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--alc-border);
    border-radius: 10px;
    padding: 9px 12px;
    font: inherit;
    color: var(--alc-fg);
    max-height: 120px;
    outline: none;
}

#assisto-livechat .alc-input:focus { border-color: var(--alc-accent); }

#assisto-livechat .alc-send {
    background: var(--alc-accent);
    color: var(--alc-accent-contrast);
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

#assisto-livechat .alc-send:hover:not(:disabled) {
    background: var(--alc-accent-hover);
}

#assisto-livechat .alc-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#assisto-livechat .alc-send svg { width: 18px; height: 18px; }

#assisto-livechat .alc-disclaimer {
    margin-top: 8px;
    font-size: 11px;
    color: var(--alc-muted);
    text-align: center;
}

@media (max-width: 480px) {
    /* Raised above the mobile "back to top" arrow (≈64px tall at bottom-right). */
    #assisto-livechat { right: 12px; bottom: 76px; }

    /* On mobile the open panel is a full-screen modal: break out of the bottom-right anchor and
       pin to the viewport edges so it covers the page rather than floating with margins. Use
       fixed positioning + dynamic viewport units (with a vh fallback) so it also accounts for the
       mobile browser's collapsing address bar. Square off the corners since they meet the edges. */
    #assisto-livechat .alc-panel,
    #assisto-livechat.alc-maximized .alc-panel {
        position: fixed;
        inset: 0;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border: none;
        border-radius: 0;
    }

    /* The panel already fills the screen on mobile, so the maximize toggle has nothing to do. */
    #assisto-livechat .alc-maximize { display: none; }

    /* Bigger, easier touch targets in the full-screen header: a larger close X and more breathing
       room between it and the trash button. */
    #assisto-livechat .alc-header-actions { gap: 16px; }
    #assisto-livechat .alc-close { font-size: 28px; padding: 4px 2px; }
    #assisto-livechat .alc-clear svg { width: 20px; height: 20px; }

    /* Tighten the pill launcher a touch so the label stays on one line on the narrowest phones. */
    #assisto-livechat .alc-launcher { height: 44px; padding: 0 16px 0 12px; }
    #assisto-livechat .alc-launcher-label { font-size: 13px; }

    /* Hide the launcher while the full-screen modal is open — it would float over the panel, and the
       header's close button is the way back out. */
    #assisto-livechat.alc-open .alc-launcher { display: none; }
}
