/* BOJIAN 实时聊天 widget（官网全站右下角）。
   视觉与站点 token 对齐：品牌红 --color-rfq (#E00010)、海军蓝 --color-navy、绿=在线。
   z-index 约定：launcher 90 / panel 95（低于 cookie 弹层 180、图片预览 1200）；
   移动端 launcher 堆在询盘车 dock 圆钮（bottom:18px）上方。 */

.bojian-chat *,
.bojian-chat *::before,
.bojian-chat *::after {
    box-sizing: border-box;
}

.bojian-chat {
    position: fixed;
    z-index: 95;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #16325C;
}

/* ------------------------------------------------ launcher */

.bojian-chat-launcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    background: #E00010;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(6, 43, 98, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bojian-chat-launcher:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(6, 43, 98, 0.24);
}

.bojian-chat-launcher-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.bojian-chat-launcher-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #fff;
    border: 2px solid #E00010;
    color: #E00010;
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* ------------------------------------------------ panel */

.bojian-chat-panel {
    position: fixed;
    right: 18px;
    bottom: 92px;
    z-index: 95;
    display: flex;
    flex-direction: column;
    width: min(360px, calc(100vw - 24px));
    height: min(560px, calc(100vh - 120px));
    max-height: 560px;
    background: #fff;
    border: 1px solid #D9E2EC;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(6, 43, 98, 0.22);
}

.bojian-chat-panel[hidden],
.bojian-chat-launcher[hidden],
.bojian-chat-launcher-badge[hidden],
.bojian-chat-status[hidden],
.bojian-chat-contact[hidden],
.bojian-chat-contact-error[hidden] {
    display: none !important;
}

/* header */

.bojian-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #D9E2EC;
}

.bojian-chat-brand {
    min-width: 0;
    flex: 1;
}

.bojian-chat-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #062B62;
    letter-spacing: 0.02em;
}

.bojian-chat-brand-sub {
    font-size: 12px;
    color: #64748B;
}

.bojian-chat-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #64748B;
}

.bojian-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9AA5B1;
}

.bojian-chat-status.is-online {
    color: #067647;
}

.bojian-chat-status.is-online .bojian-chat-status-dot {
    background: #16a34a;
}

.bojian-chat-close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748B;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.bojian-chat-close:hover {
    background: #F1F5F9;
    color: #16325C;
}

/* messages */

.bojian-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    background: #F7F9FC;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bojian-chat-welcome-wrap {
    align-self: flex-start;
    max-width: 82%;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bojian-chat-welcome-brand {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #64748B;
    margin-left: 4px;
}

.bojian-chat-welcome {
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #D9E2EC;
    border-radius: 10px;
    border-top-left-radius: 4px;
    font-size: 13px;
    color: #16325C;
}

.bojian-chat-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0 6px;
}

.bojian-chat-quick button {
    border: 1px solid #E00010;
    background: #fff;
    color: #E00010;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease;
}

.bojian-chat-quick button:hover {
    background: #FFF0ED;
}

.bojian-chat-bubble {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
}

.bojian-chat-bubble-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 11px;
    color: #94A3B8;
}

.bojian-chat-row {
    display: flex;
    flex-direction: column;
}

.bojian-chat-row.is-agent {
    align-items: flex-start;
}

.bojian-chat-row.is-agent .bojian-chat-bubble {
    background: #fff;
    border: 1px solid #D9E2EC;
    color: #16325C;
    border-bottom-left-radius: 4px;
}

.bojian-chat-row.is-visitor {
    align-items: flex-end;
}

.bojian-chat-row.is-visitor .bojian-chat-bubble {
    background: #E00010;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bojian-chat-row.is-visitor .bojian-chat-bubble-meta {
    justify-content: flex-end;
    color: rgba(255, 255, 255, 0.75);
}

.bojian-chat-row.is-failed .bojian-chat-bubble {
    background: #fef3f2;
    border: 1px dashed #B42318;
    color: #B42318;
}

.bojian-chat-retry {
    border: none;
    background: transparent;
    color: #B42318;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.bojian-chat-notice {
    align-self: center;
    max-width: 92%;
    padding: 6px 12px;
    border-radius: 999px;
    background: #EEF2F7;
    color: #64748B;
    font-size: 12px;
    text-align: center;
}

/* composer */

.bojian-chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #D9E2EC;
    background: #fff;
}

.bojian-chat-input {
    flex: 1;
    min-height: 38px;
    max-height: 110px;
    resize: none;
    border: 1px solid #D9E2EC;
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    font-size: 13.5px;
    color: #16325C;
    outline: none;
}

.bojian-chat-input:focus {
    border-color: #E00010;
    box-shadow: 0 0 0 3px rgba(224, 0, 16, 0.1);
}

.bojian-chat-send {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    background: #E00010;
    color: #fff;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
}

.bojian-chat-send:hover {
    background: #c5000e;
}

.bojian-chat-send:disabled {
    opacity: 0.55;
    cursor: default;
}

/* contact form */

.bojian-chat-contact-toggle {
    border: none;
    background: transparent;
    color: #E00010;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0 8px;
    text-decoration: underline;
    align-self: center;
}

.bojian-chat-contact {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #D9E2EC;
    border-radius: 10px;
}

.bojian-chat-contact input {
    border: 1px solid #D9E2EC;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    color: #16325C;
    outline: none;
}

.bojian-chat-contact input:focus {
    border-color: #E00010;
}

.bojian-chat-contact-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.bojian-chat-contact .bojian-chat-save {
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: #062B62;
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.bojian-chat-contact .bojian-chat-cancel {
    height: 32px;
    padding: 0 12px;
    border: 1px solid #D9E2EC;
    border-radius: 8px;
    background: #fff;
    color: #64748B;
    font-size: 12.5px;
    cursor: pointer;
}

.bojian-chat-contact-error {
    font-size: 12px;
    color: #B42318;
    margin: 0;
}

/* loading */

.bojian-chat-loading {
    padding: 12px;
    text-align: center;
    color: #94A3B8;
    font-size: 12.5px;
}

/* ------------------------------------------------ mobile */

@media (max-width: 768px) {
    .bojian-chat-launcher {
        right: 16px;
        bottom: 78px; /* 堆在询盘车 dock 圆钮（bottom:18px, 48px 高）上方 */
        padding: 14px;
    }

    .bojian-chat-launcher-label {
        display: none;
    }

    .bojian-chat-panel {
        right: 12px;
        bottom: 138px;
        width: calc(100vw - 24px);
        height: min(520px, calc(100vh - 160px));
    }
}

/* ------------------------------------------------ RTL */

[dir="rtl"] .bojian-chat-launcher {
    right: auto;
    left: 18px;
}

[dir="rtl"] .bojian-chat-panel {
    right: auto;
    left: 18px;
}

[dir="rtl"] .bojian-chat-row.is-agent {
    align-items: flex-end;
}

[dir="rtl"] .bojian-chat-row.is-visitor {
    align-items: flex-start;
}

[dir="rtl"] .bojian-chat-row.is-agent .bojian-chat-bubble {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .bojian-chat-row.is-visitor .bojian-chat-bubble {
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

@media (max-width: 768px) {
    [dir="rtl"] .bojian-chat-launcher {
        left: 16px;
        right: auto;
    }

    [dir="rtl"] .bojian-chat-panel {
        left: 12px;
        right: auto;
    }
}
