/**
 * The public assistant widget.
 *
 * Its own stylesheet, and every selector prefixed .wb-as-, because it is loaded on
 * the marketing pages AND inside the compiled app - two places with completely
 * different CSS - and it must not touch either of them or be touched by them.
 *
 * Bottom-left: the bottom-right corner already has the WhatsApp button and the
 * human live-chat bubble.
 */

.wb-as-root {
    --wb-as-accent: #2f80ed;
    --wb-as-deep: #0d2f4d;
    --wb-as-ink: #1f2124;
    --wb-as-muted: #6b6c72;
    --wb-as-line: #e3e5e8;

    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    font-family: 'Figtree', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ------------------------------------------------------------------ launcher -- */
.wb-as-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    border: 0;
    border-radius: 999px;
    background: var(--wb-as-deep);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(13, 47, 77, 0.28);
    transition: transform 0.15s ease, background 0.15s ease;
}

.wb-as-launcher:hover {
    background: #143f66;
    transform: translateY(-2px);
}

.wb-as-launcher svg {
    flex: 0 0 auto;
}

/* --------------------------------------------------------------------- panel -- */
.wb-as-panel[hidden] {
    display: none !important;
}

.wb-as-panel {
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    overflow: hidden;
    border: 1px solid var(--wb-as-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 26px 70px rgba(13, 47, 77, 0.26);
}

.wb-as-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    background: var(--wb-as-deep);
    color: #fff;
}

.wb-as-title strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

.wb-as-title span {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.7);
}

.wb-as-close {
    flex: 0 0 auto;
    padding: 0 4px;
    border: 0;
    background: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.wb-as-close:hover {
    color: #fff;
}

/* ----------------------------------------------------------------- messages -- */
.wb-as-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background: #f7f8fa;
}

.wb-as-msg {
    display: flex;
    margin-bottom: 10px;
}

.wb-as-me {
    justify-content: flex-end;
}

.wb-as-bubble {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.55;
    white-space: normal;
    word-wrap: break-word;
}

.wb-as-bot .wb-as-bubble {
    border: 1px solid var(--wb-as-line);
    border-bottom-left-radius: 4px;
    background: #fff;
    color: var(--wb-as-ink);
}

.wb-as-me .wb-as-bubble {
    border-bottom-right-radius: 4px;
    background: var(--wb-as-accent);
    color: #fff;
}

.wb-as-thinking .wb-as-bubble {
    color: var(--wb-as-muted);
    font-style: italic;
}

/* Openers, so the first message is not a blank stare. */
.wb-as-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 10px;
}

.wb-as-chip {
    padding: 7px 13px;
    border: 1px solid var(--wb-as-line);
    border-radius: 999px;
    background: #fff;
    color: var(--wb-as-accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease;
}

.wb-as-chip:hover {
    background: #e8f1fc;
}

/* -------------------------------------------------------------------- input -- */
.wb-as-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--wb-as-line);
    background: #fff;
}

.wb-as-input {
    flex: 1 1 auto;
    min-width: 0;
    /* A textarea, so a paragraph is readable before it is sent. It starts one
       line tall and grows with the text; the script caps it at six lines so the
       conversation above it never disappears. */
    height: 42px;
    max-height: 132px;
    padding: 11px 14px;
    border: 1px solid var(--wb-as-line);
    border-radius: 9px;
    font-size: 14.5px;
    font-family: inherit;
    line-height: 1.4;
    color: var(--wb-as-ink);
    background: #fff;
    resize: none;
    overflow-y: auto;
}

.wb-as-input:focus {
    outline: none;
    border-color: var(--wb-as-accent);
    box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.14);
}

.wb-as-send {
    flex: 0 0 auto;
    padding: 0 18px;
    border: 0;
    border-radius: 9px;
    background: var(--wb-as-accent);
    color: #fff;
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.wb-as-send:disabled {
    background: #9dc2f2;
    cursor: default;
}

.wb-as-note {
    padding: 0 14px 12px;
    background: #fff;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--wb-as-muted);
}

/* ---------------------------------------------------------------- small screens -- */
@media (max-width: 560px) {
    .wb-as-root {
        left: 14px;
        right: 14px;
        bottom: 14px;
        align-items: stretch;
    }

    .wb-as-launcher {
        align-self: flex-start;
    }

    /* The launcher is a bubble on a phone; the words would take the whole row. */
    .wb-as-launcher span {
        display: none;
    }

    .wb-as-launcher {
        padding: 14px;
    }

    .wb-as-panel {
        width: 100%;
        max-width: none;
        height: calc(100vh - 120px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wb-as-launcher {
        transition: none;
    }
}

/* ------------------------------------------------------- header controls -- */
.wb-as-tools {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
}

.wb-as-expand {
    padding: 0 4px;
    border: 0;
    background: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.wb-as-expand:hover {
    color: #fff;
}

/* ------------------------------------------------------------ wide mode -- */
/* Ctrl+Enter, or the arrow in the header. A 380px column is right for "what
   does it cost" and cramped for an answer listing six plans, so the panel can
   become a proper reading window without leaving the page. */
.wb-as-wide .wb-as-panel {
    width: 640px;
    height: 78vh;
    max-height: calc(100vh - 100px);
}

@media (max-width: 720px) {
    /* There is no room for a second size on a phone; the panel is already
       nearly the whole screen. */
    .wb-as-wide .wb-as-panel {
        width: 100%;
        height: calc(100vh - 120px);
    }
}
