/* ==========================================================================
   WE BUY CASH KC — Cash Offer Assistant
   Reuses the site design tokens (navy / cash green / gold) so the widget
   reads as part of the brand rather than a bolted-on third-party bubble.
   ========================================================================== */

.cb {
    --cb-radius: 20px;
    --cb-panel-w: 400px;
    --cb-panel-h: min(640px, calc(100vh - 140px));
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 190;
    font-family: var(--font, system-ui, sans-serif);
}

/* Keep the existing back-to-top button clear of the launcher. */
.to-top { bottom: 88px; }
@media (max-width: 900px) { .to-top { bottom: 218px; } }

/* --------------------------------------------------------------------------
   LAUNCHER
   -------------------------------------------------------------------------- */
.cb-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1.15rem .65rem .65rem;
    border-radius: 100px;
    background: linear-gradient(180deg, var(--green-500, #1bb35c), var(--green-600, #149a4e));
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
    box-shadow: 0 10px 30px rgba(20, 154, 78, .38);
    cursor: pointer;
    transition: transform .25s var(--ease, ease), box-shadow .25s, opacity .2s;
}
.cb-launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 38px rgba(20, 154, 78, .5); }
.cb-launcher:active { transform: translateY(0); }
.cb-launcher-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: grid; place-items: center; flex: none;
}
.cb-launcher-avatar svg { width: 21px; height: 21px; }
.cb-launcher-label { white-space: nowrap; }
.cb-launcher-close { display: none; }

.cb.is-open .cb-launcher-label,
.cb.is-open .cb-launcher-avatar { display: none; }
.cb.is-open .cb-launcher-close { display: grid; place-items: center; width: 26px; height: 26px; }
.cb.is-open .cb-launcher-close svg { width: 22px; height: 22px; }
.cb.is-open .cb-launcher { padding: .8rem; border-radius: 50%; }

/* Unread pip */
.cb-pip {
    position: absolute; top: -3px; right: -3px;
    min-width: 21px; height: 21px; padding: 0 5px;
    border-radius: 100px;
    background: #e8453c; color: #fff;
    font-size: .72rem; font-weight: 800;
    display: none; place-items: center;
    box-shadow: 0 0 0 3px #fff;
}
.cb-pip.is-on { display: grid; }
.cb.is-open .cb-pip { display: none; }

/* Attention ring */
.cb-launcher::after {
    content: ""; position: absolute; inset: -4px;
    border-radius: 100px; border: 2px solid var(--green-500, #1bb35c);
    opacity: 0; pointer-events: none;
}
.cb.is-nudging .cb-launcher::after { animation: cbRing 2.2s ease-out 3; }
@keyframes cbRing {
    0%   { opacity: .7; transform: scale(1); }
    70%  { opacity: 0;   transform: scale(1.22); }
    100% { opacity: 0;   transform: scale(1.22); }
}

/* --------------------------------------------------------------------------
   TEASER BUBBLE
   -------------------------------------------------------------------------- */
.cb-teaser {
    position: absolute;
    right: 0; bottom: calc(100% + 12px);
    width: 290px;
    background: #fff;
    border: 1px solid var(--line, #dbe4ee);
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 18px 44px -14px rgba(12, 35, 64, .34);
    padding: .95rem 1.05rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(.96);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .3s var(--ease, ease), transform .3s var(--ease, ease), visibility .3s;
}
.cb-teaser.is-on { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.cb-teaser p { margin: 0; font-size: .92rem; line-height: 1.45; color: var(--ink, #152232); }
.cb-teaser p strong { font-weight: 800; }
.cb-teaser-dismiss {
    position: absolute; top: 6px; right: 6px;
    width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center;
    color: var(--muted, #7b8898);
}
.cb-teaser-dismiss:hover { background: var(--mist, #eff4f9); color: var(--ink, #152232); }
.cb-teaser-dismiss svg { width: 14px; height: 14px; }
.cb.is-open .cb-teaser { display: none; }

/* --------------------------------------------------------------------------
   PANEL
   -------------------------------------------------------------------------- */
.cb-panel {
    position: absolute;
    right: 0; bottom: calc(100% + 14px);
    width: var(--cb-panel-w);
    height: var(--cb-panel-h);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: var(--cb-radius);
    box-shadow: 0 34px 80px -22px rgba(12, 35, 64, .45), 0 0 0 1px rgba(12, 35, 64, .07);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.97);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .28s var(--ease, ease), transform .28s var(--ease, ease), visibility .28s;
}
.cb.is-open .cb-panel { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }

/* Header */
.cb-head {
    display: flex; align-items: center; gap: .7rem;
    padding: .95rem 1rem;
    background: linear-gradient(135deg, var(--navy-900, #0c2340), var(--navy-800, #10305a));
    color: #fff;
    flex: none;
}
.cb-head-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(180deg, var(--green-500, #1bb35c), var(--green-600, #149a4e));
    display: grid; place-items: center; flex: none;
    box-shadow: 0 4px 12px rgba(20, 154, 78, .4);
}
.cb-head-avatar svg { width: 22px; height: 22px; }
.cb-head-meta { min-width: 0; flex: 1; }
.cb-head-meta b { display: block; font-size: .98rem; font-weight: 800; color: #fff; line-height: 1.25; }
.cb-status { display: flex; align-items: center; gap: .35rem; font-size: .76rem; color: #a9c3de; margin-top: 1px; }
.cb-status i {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green-500, #1bb35c);
    box-shadow: 0 0 0 0 rgba(27, 179, 92, .7);
    animation: cbPulse 2.4s infinite;
}
@keyframes cbPulse {
    0%   { box-shadow: 0 0 0 0 rgba(27, 179, 92, .6); }
    70%  { box-shadow: 0 0 0 7px rgba(27, 179, 92, 0); }
    100% { box-shadow: 0 0 0 0 rgba(27, 179, 92, 0); }
}
.cb-head-actions { display: flex; gap: .15rem; flex: none; }
.cb-icon-btn {
    width: 34px; height: 34px; border-radius: 9px;
    display: grid; place-items: center;
    color: #c6d8ec;
    transition: background .18s, color .18s;
}
.cb-icon-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.cb-icon-btn svg { width: 19px; height: 19px; }
.cb-icon-btn.is-muted { color: #7f9ab8; }

/* Progress strip — shows how close the seller is to a finished request. */
.cb-progress { height: 3px; background: rgba(255, 255, 255, .14); flex: none; }
.cb-progress i {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, var(--green-500, #1bb35c), var(--gold, #f5a623));
    transition: width .45s var(--ease, ease);
}

/* Message log */
.cb-log {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.1rem 1rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    background:
        radial-gradient(circle at 15% 0%, rgba(27, 179, 92, .05), transparent 45%),
        var(--mist, #eff4f9);
    scroll-behavior: smooth;
}
.cb-log::-webkit-scrollbar { width: 7px; }
.cb-log::-webkit-scrollbar-thumb { background: #c3d2e2; border-radius: 100px; }
.cb-log::-webkit-scrollbar-track { background: transparent; }

.cb-row { display: flex; gap: .5rem; align-items: flex-end; max-width: 100%; }
.cb-row-bot { align-self: flex-start; max-width: 88%; }
.cb-row-user { align-self: flex-end; flex-direction: row-reverse; max-width: 82%; }

.cb-av {
    width: 27px; height: 27px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    background: linear-gradient(180deg, var(--green-500, #1bb35c), var(--green-600, #149a4e));
    color: #fff; margin-bottom: 2px;
}
.cb-av svg { width: 15px; height: 15px; }
.cb-row-user .cb-av { background: var(--navy-800, #10305a); }
.cb-row.cb-tail .cb-av { visibility: hidden; }

.cb-bubble {
    padding: .68rem .9rem;
    font-size: .93rem;
    line-height: 1.55;
    border-radius: 16px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: cbIn .3s var(--ease, ease) both;
}
@keyframes cbIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.cb-row-bot .cb-bubble {
    background: #fff;
    color: var(--ink, #152232);
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 10px rgba(12, 35, 64, .07);
}
.cb-row-user .cb-bubble {
    background: linear-gradient(180deg, var(--navy-800, #10305a), var(--navy-900, #0c2340));
    color: #fff;
    border-bottom-right-radius: 5px;
}
.cb-bubble strong { font-weight: 800; }
.cb-bubble a { color: var(--green-700, #0f7d3f); font-weight: 700; text-decoration: underline; }
.cb-row-user .cb-bubble a { color: #9fe3bd; }
.cb-bubble ul { margin: .45rem 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .32rem; }
.cb-bubble li { position: relative; padding-left: 1.1rem; font-size: .9rem; }
.cb-bubble li::before {
    content: ""; position: absolute; left: 0; top: .58em;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green-500, #1bb35c);
}

/* Typing indicator */
.cb-typing { display: flex; gap: 4px; padding: .8rem .95rem; }
.cb-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #9fb2c7;
    animation: cbBounce 1.3s infinite ease-in-out;
}
.cb-typing span:nth-child(2) { animation-delay: .16s; }
.cb-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes cbBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

/* Quick replies */
.cb-chips:empty { padding: 0; }
.cb-chips {
    display: flex; flex-wrap: wrap; gap: .4rem;
    padding: .15rem 1rem .8rem;
    background: var(--mist, #eff4f9);
    flex: none;
}
.cb-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .48rem .85rem;
    border-radius: 100px;
    background: #fff;
    box-shadow: inset 0 0 0 1.5px var(--line, #dbe4ee);
    color: var(--navy-900, #0c2340);
    font-size: .85rem; font-weight: 700;
    text-align: left;
    transition: background .18s, box-shadow .18s, color .18s, transform .18s;
    animation: cbIn .3s var(--ease, ease) both;
}
.cb-chip:hover {
    background: var(--green-050, #e7f6ee);
    box-shadow: inset 0 0 0 1.5px var(--green-500, #1bb35c);
    color: var(--green-700, #0f7d3f);
    transform: translateY(-1px);
}
.cb-chip svg { width: 15px; height: 15px; flex: none; }
.cb-chip-primary {
    background: linear-gradient(180deg, var(--green-500, #1bb35c), var(--green-600, #149a4e));
    color: #fff; box-shadow: 0 6px 16px rgba(20, 154, 78, .3);
}
.cb-chip-primary:hover { background: var(--green-600, #149a4e); color: #fff; box-shadow: 0 10px 22px rgba(20, 154, 78, .4); }
.cb-chip-call { background: var(--navy-900, #0c2340); color: #fff; box-shadow: none; }
.cb-chip-call:hover { background: var(--navy-800, #10305a); color: #fff; }

/* Composer */
.cb-composer {
    display: flex; align-items: flex-end; gap: .5rem;
    padding: .7rem .8rem;
    background: #fff;
    border-top: 1px solid var(--line, #dbe4ee);
    flex: none;
}
.cb-input {
    flex: 1;
    resize: none;
    border: 0;
    background: var(--mist, #eff4f9);
    border-radius: 14px;
    padding: .7rem .9rem;
    font: inherit;
    font-size: .93rem;
    line-height: 1.45;
    color: var(--ink, #152232);
    max-height: 108px;
    min-height: 44px;
    box-shadow: inset 0 0 0 1.5px transparent;
    transition: box-shadow .18s, background .18s;
}
.cb-input::placeholder { color: var(--muted, #7b8898); }
.cb-input:focus {
    outline: none;
    background: #fff;
    box-shadow: inset 0 0 0 1.5px var(--green-500, #1bb35c);
}
.cb-send {
    width: 44px; height: 44px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    background: linear-gradient(180deg, var(--green-500, #1bb35c), var(--green-600, #149a4e));
    color: #fff;
    box-shadow: 0 6px 16px rgba(20, 154, 78, .34);
    transition: transform .18s, opacity .18s, box-shadow .18s;
}
.cb-send svg { width: 19px; height: 19px; }
.cb-send:hover { transform: scale(1.06); }
.cb-send:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.cb-foot {
    padding: 0 .9rem .6rem;
    background: #fff;
    font-size: .7rem;
    color: var(--muted, #7b8898);
    text-align: center;
    flex: none;
}
.cb-foot a { color: var(--slate, #4c5c6e); text-decoration: underline; }

/* Inline validation note */
.cb-note {
    align-self: flex-start;
    max-width: 88%;
    margin-left: 2.2rem;
    font-size: .8rem;
    font-weight: 600;
    color: #c0392b;
    animation: cbIn .25s var(--ease, ease) both;
}

/* --------------------------------------------------------------------------
   EMBEDDED FORM VIEW (the hosted form, opened inside the chat)
   -------------------------------------------------------------------------- */
.cb-formview {
    position: absolute;
    inset: 0;
    top: 64px;
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .32s var(--ease, ease);
    z-index: 3;
}
.cb-panel.cb-showform .cb-formview { transform: none; }
.cb-formview-head {
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--line, #dbe4ee);
    flex: none;
}
.cb-formview-head b { font-size: .9rem; color: var(--ink, #152232); flex: 1; }
.cb-back {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .35rem .6rem; border-radius: 8px;
    font-size: .84rem; font-weight: 700; color: var(--slate, #4c5c6e);
}
.cb-back:hover { background: var(--mist, #eff4f9); color: var(--navy-900, #0c2340); }
.cb-back svg { width: 15px; height: 15px; transform: rotate(180deg); }
.cb-formview-body { flex: 1; overflow: hidden; }
.cb-formview-body iframe { width: 100%; height: 100%; border: 0; display: block; }

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .cb { right: 16px; bottom: 84px; }
    .cb-teaser { width: min(260px, calc(100vw - 40px)); }
}

@media (max-width: 640px) {
    .cb-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(100%);
    }
    .cb.is-open .cb-panel { transform: none; }
    .cb-row-bot { max-width: 92%; }
    .cb-row-user { max-width: 88%; }
    .cb-formview { top: 64px; }
    /* The header close button is enough — the floating one would cover
       the composer on a full-screen sheet. */
    .cb.is-open .cb-launcher { display: none; }
    /* Stop the page scrolling behind the full-screen sheet. */
    body.cb-locked { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .cb-panel, .cb-teaser, .cb-formview { transition: opacity .01s; }
    .cb-bubble, .cb-chip { animation: none; }
    .cb-status i, .cb-typing span, .cb-launcher::after { animation: none; }
    .cb-log { scroll-behavior: auto; }
}

/* Hide entirely when printing */
@media print { .cb { display: none; } }
