/* Floating live chat widget */
.cb-chat {
    position: fixed;
    z-index: 1080;
    inset-inline-end: 1rem;
    bottom: 1rem;
    font-family: var(--cb-font, "Manrope", sans-serif);
}
.cb-chat-fab {
    width: 3.4rem;
    height: 3.4rem;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #1a5f7a, #0d3b4d);
    color: #fff;
    font-size: 1.25rem;
    box-shadow: 0 10px 28px rgba(13, 59, 77, 0.35);
    position: relative;
    cursor: pointer;
    z-index: 2;
}
.cb-chat-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(47, 143, 209, 0.55);
    animation: cbChatPulse 2s ease-out infinite;
    pointer-events: none;
}
@keyframes cbChatPulse {
    0% { transform: scale(0.92); opacity: 0.9; }
    100% { transform: scale(1.25); opacity: 0; }
}
.cb-chat-panel {
    position: absolute;
    inset-inline-end: 0;
    bottom: 4.2rem;
    width: min(360px, calc(100vw - 1.5rem));
    height: min(520px, calc(100vh - 6rem));
    max-height: calc(100vh - 5.5rem);
    background: #fff;
    border: 1px solid rgba(20, 33, 61, 0.12);
    border-radius: 1rem;
    box-shadow: 0 18px 50px rgba(20, 33, 61, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
}
.cb-chat-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, #14213d, #1a5f7a);
    color: #fff;
    flex-shrink: 0;
}
.cb-chat-title { font-weight: 800; font-size: 0.95rem; }
.cb-chat-sub { font-size: 0.72rem; opacity: 0.85; }
.cb-chat-close {
    border: 0;
    background: rgba(255,255,255,0.12);
    color: #fff;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
}
.cb-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.85rem;
    background: #f4f7fa;
    -webkit-overflow-scrolling: touch;
}
.cb-chat-thread-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f4f7fa;
}
.cb-chat-thread {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    -webkit-overflow-scrolling: touch;
}
.cb-chat-footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid rgba(20, 33, 61, 0.08);
}
.cb-bot-bubble,
.cb-msg {
    max-width: 88%;
    padding: 0.55rem 0.7rem;
    border-radius: 0.85rem;
    font-size: 0.84rem;
    line-height: 1.4;
    background: #fff;
    border: 1px solid rgba(20, 33, 61, 0.08);
    box-shadow: 0 2px 8px rgba(20, 33, 61, 0.04);
    word-break: break-word;
}
.cb-msg-meta {
    display: block;
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 0.25rem;
}
.cb-msg.is-visitor {
    align-self: flex-end;
    background: #14213d;
    color: #fff;
    border-color: #14213d;
}
.cb-msg.is-visitor .cb-msg-meta { color: rgba(255,255,255,0.75); }
.cb-msg.is-staff {
    align-self: flex-start;
    background: #e8f5ee;
    border-color: #b7e4cb;
}
.cb-msg.is-staff-named .cb-msg-meta {
    font-weight: 700;
    color: #0d3b4d;
}
.cb-msg.is-bot {
    align-self: flex-start;
    background: #fff;
    white-space: pre-wrap;
}
.cb-chat-choices {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.75rem;
}
.cb-choice {
    border: 1.5px solid #1a5f7a;
    background: #fff;
    color: #14213d;
    border-radius: 0.7rem;
    padding: 0.55rem 0.7rem;
    font-weight: 700;
    font-size: 0.84rem;
    text-align: start;
    cursor: pointer;
}
.cb-choice:hover {
    background: #eef6fb;
}
.cb-chat-form { margin-top: 0.75rem; }
.cb-chat-attach-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem 0;
    background: #fff;
}
.cb-attach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid rgba(20, 33, 61, 0.15);
    border-radius: 0.5rem;
    background: #f8fafc;
    color: #1a5f7a;
    cursor: pointer;
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
}
.cb-attach-btn:hover { background: #eef6fb; }
.cb-attach-preview {
    font-size: 0.7rem;
    color: #64748b;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cb-chat-compose {
    display: flex;
    gap: 0.4rem;
    padding: 0.55rem;
    background: #fff;
}
.cb-chat-compose .form-control {
    min-width: 0;
}
.cb-msg-img-wrap { display: block; margin-top: 0.4rem; }
.cb-msg-img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 0.5rem;
    display: block;
}
.cb-msg.is-balance .cb-msg-balance {
    white-space: pre-wrap;
    font-size: 0.8rem;
}
.cb-msg.is-visitor.is-balance {
    background: #0d3b4d;
}
.cb-chat-persist-note {
    font-size: 0.65rem;
    color: #64748b;
    padding: 0.25rem 0.7rem 0.55rem;
    background: #fff;
}
body.cb-chat-open {
    overflow: hidden;
}
@media (max-width: 480px) {
    .cb-chat { inset-inline-end: 0.65rem; bottom: 0.65rem; }
    .cb-chat-panel {
        height: min(72vh, 560px);
        max-height: calc(100vh - 5rem);
        width: min(100vw - 1.2rem, 360px);
    }
}
