/* Pi Chatbot — the scrollable message list: bubbles (user/bot/error), the shared avatar
   column, inline links, and the collapsible Sources list. */

#pi-chatbot-panel .pi-cb-messages {
    flex: 1;
    overflow-y: auto;
    /* Blocks scroll chaining to the background page when hitting the bottom/top of the
       message frame on touch devices — without this line, scrolling continues onto the
       page behind the panel, giving a "slipped out of your hand" feeling. */
    overscroll-behavior: contain;
    padding: 18px 16px 24px 16px;
    scroll-padding-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: transparent;
    color: var(--cb-text);
    -webkit-user-select: text;
    user-select: text;
}

#pi-chatbot-panel .pi-cb-msg-wrap {
    display: flex;
    gap: 10px;
    max-width: 85%;
}
#pi-chatbot-panel .pi-cb-msg-wrap--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
#pi-chatbot-panel .pi-cb-avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    background: var(--cb-accent-soft);
    border: 1px solid var(--cb-accent-ring);
    color: var(--cb-accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Vertical column sharing a SINGLE avatar for both the progress card and the answer
   bubble of 1 bot turn — instead of each tier being its own avatar row (fixed per
   feedback: "they need to be linked together, just 1 svg icon, don't split into 3 chat
   messages"). */
#pi-chatbot-panel .pi-cb-msg-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
#pi-chatbot-panel .pi-cb-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.48;
    white-space: pre-wrap;
    word-break: break-word;
}
/* URLs the model writes inline inside its answer (e.g. "Xem thêm: https://...")
   are turned into real links by appendLinkifiedText() in chatbot-ui.js — always
   underlined (not just on hover) so a link sitting inside a paragraph of plain
   text reads as clickable at a glance, unlike the Sources list where the
   bullet + details/summary structure already signals interactivity. */
#pi-chatbot-panel .pi-cb-msg a {
    color: var(--cb-accent);
    text-decoration: underline;
    text-decoration-color: var(--cb-accent);
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-weight: 600;
}
#pi-chatbot-panel .pi-cb-msg a:hover {
    color: var(--cb-accent-hover);
    text-decoration-thickness: 2px;
}
#pi-chatbot-panel .pi-cb-msg a.pi-cb-link-phone {
    color: var(--cb-accent);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: -1px;
    font-size: 12.5px;
    line-height: 1.2;
    padding: 1px 7px;
    background: color-mix(in srgb, var(--cb-accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--cb-accent) 28%, transparent);
    border-radius: 5px;
    margin: 0 2px;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#pi-chatbot-panel .pi-cb-msg a.pi-cb-link-phone:hover {
    background: color-mix(in srgb, var(--cb-accent) 25%, transparent);
    border-color: var(--cb-accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--cb-accent) 25%, transparent);
    text-decoration: none;
}
#pi-chatbot-panel .pi-cb-msg a.pi-cb-link-email {
    color: var(--cb-accent);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: -1px;
    font-size: 12.5px;
    line-height: 1.2;
    padding: 1px 7px;
    background: color-mix(in srgb, var(--cb-accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--cb-accent) 25%, transparent);
    border-radius: 5px;
    margin: 0 2px;
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#pi-chatbot-panel .pi-cb-msg a.pi-cb-link-email:hover {
    background: color-mix(in srgb, var(--cb-accent) 22%, transparent);
    border-color: var(--cb-accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--cb-accent) 20%, transparent);
    text-decoration: none;
}
#pi-chatbot-panel .pi-cb-msg a.pi-cb-link-zalo {
    color: #0068ff;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: -1px;
    font-size: 12.5px;
    line-height: 1.2;
    padding: 1px 7px;
    background: color-mix(in srgb, #0068ff 12%, transparent);
    border: 1px solid color-mix(in srgb, #0068ff 28%, transparent);
    border-radius: 5px;
    margin: 0 2px;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#pi-chatbot-panel .pi-cb-msg a.pi-cb-link-zalo:hover {
    background: color-mix(in srgb, #0068ff 25%, transparent);
    border-color: #0068ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px color-mix(in srgb, #0068ff 30%, transparent);
    text-decoration: none;
}
#pi-chatbot-panel .pi-cb-msg.pi-cb-msg--center,
#pi-chatbot-panel .pi-cb-msg-center,
#pi-chatbot-panel .pi-cb-text-center {
    text-align: center;
}
#pi-chatbot-panel .pi-cb-msg-wrap--bot .pi-cb-msg {
    background: color-mix(in srgb, var(--cb-text) 4%, transparent);
    border: 1px solid var(--cb-border);
    color: var(--cb-text);
    border-top-left-radius: 2px;
}
#pi-chatbot-panel .pi-cb-msg-wrap--user .pi-cb-msg {
    background: linear-gradient(135deg, var(--cb-accent), var(--cb-accent-hover));
    color: var(--cb-accent-text);
    border-top-right-radius: 2px;
    box-shadow: 0 4px 12px var(--cb-accent-glow);
}
#pi-chatbot-panel .pi-cb-msg-wrap--error .pi-cb-msg {
    background: var(--cb-error-bg);
    color: var(--cb-error-text);
    border-top-left-radius: 2px;
}
#pi-chatbot-panel .pi-cb-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--cb-border);
    font-size: 12px;
    color: var(--cb-text-muted);
}
#pi-chatbot-panel .pi-cb-sources summary {
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    transition: color 0.2s;
}
#pi-chatbot-panel .pi-cb-sources summary:hover {
    color: var(--cb-text);
}
#pi-chatbot-panel .pi-cb-sources-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#pi-chatbot-panel .pi-cb-source-item {
    position: relative;
    padding-left: 12px;
}
#pi-chatbot-panel .pi-cb-source-item::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--cb-accent-ring);
}
#pi-chatbot-panel .pi-cb-source-item a {
    color: var(--cb-accent);
    text-decoration: none;
    line-height: 1.4;
    display: inline-block;
}
#pi-chatbot-panel .pi-cb-source-item a:hover { text-decoration: underline; }

/* 👍/👎 under a bot answer — quiet by default (this isn't the main content of
   the bubble), only using color to signal the vote actually landed. */
#pi-chatbot-panel .pi-cb-feedback {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}
#pi-chatbot-panel .pi-cb-feedback-btn {
    background: transparent;
    border: 1px solid var(--cb-border);
    border-radius: 8px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cb-text-muted, currentColor);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
#pi-chatbot-panel .pi-cb-feedback-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}
#pi-chatbot-panel .pi-cb-feedback-btn:hover:not(:disabled):not([aria-disabled="true"]) {
    opacity: 1;
    color: var(--cb-accent);
    border-color: var(--cb-accent-ring);
    background: color-mix(in srgb, var(--cb-accent) 8%, transparent);
}
#pi-chatbot-panel .pi-cb-feedback-btn:disabled,
#pi-chatbot-panel .pi-cb-feedback-btn[aria-disabled="true"] {
    cursor: default;
    pointer-events: none;
}
#pi-chatbot-panel .pi-cb-feedback-btn--picked {
    opacity: 1;
    color: var(--cb-accent);
    border-color: var(--cb-accent);
    background: color-mix(in srgb, var(--cb-accent) 12%, transparent);
}

/* Lead-capture form — appended after a 'price' intent answer (see appendLeadForm()
   in chatbot-ui.js). Same token palette as everything else in the widget, boxed
   in its own soft panel so it reads as a distinct action, not more prose. */
#pi-chatbot-panel .pi-cb-lead {
    margin-top: 10px;
    padding: 10px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--cb-accent) 6%, transparent);
    border: 1px solid var(--cb-accent-ring);
}
#pi-chatbot-panel .pi-cb-lead-title {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--cb-text);
    margin-bottom: 8px;
}
#pi-chatbot-panel .pi-cb-lead-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
#pi-chatbot-panel .pi-cb-lead-input {
    flex: 1 1 120px;
    min-width: 0;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--cb-border);
    background: var(--cb-bg, transparent);
    color: var(--cb-text);
    font-size: 13px;
}
#pi-chatbot-panel .pi-cb-lead-input:focus {
    outline: none;
    border-color: var(--cb-accent);
}
#pi-chatbot-panel .pi-cb-lead-msg {
    font-size: 12px;
    color: var(--cb-text-muted);
    margin-top: 6px;
    min-height: 1.2em;
}
#pi-chatbot-panel .pi-cb-lead-submit {
    margin-top: 8px;
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, var(--cb-accent), var(--cb-accent-hover));
    color: var(--cb-accent-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
#pi-chatbot-panel .pi-cb-lead-submit:disabled {
    opacity: 0.6;
    cursor: default;
}
#pi-chatbot-panel .pi-cb-lead-done {
    font-size: 13px;
    color: var(--cb-accent);
    font-weight: 500;
}
