/* 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 above the page's "back to top" arrow (≈76px tall stack at bottom-right on the report and
       marketing pages) so the launcher and the arrow no longer overlap. The panel below is anchored
       relative to this container, so it rises with the launcher. */
    bottom: 88px;
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

#assisto-livechat .alc-launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    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: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: 26px;
    height: 26px;
}

#assisto-livechat .alc-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    /* Account for the raised launcher (bottom: 88px) so the panel never clips the top on short windows. */
    max-height: calc(100vh - 188px);
    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 - 178px);
    max-height: calc(100vh - 178px);
}

/* 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: 2px;
}

#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; }
    #assisto-livechat .alc-panel,
    #assisto-livechat.alc-maximized .alc-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 154px);
        max-height: calc(100vh - 154px);
        bottom: 66px;
    }

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