@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ============================================================
   BriefSync Live Chat Widget
   All classes prefixed .cpb-livechat- to avoid conflicts
   ============================================================ */

/* ---- Reset / Base ---- */
.cpb-livechat-widget,
.cpb-livechat-widget *,
.cpb-livechat-widget *::before,
.cpb-livechat-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---- Chat Bubble ---- */
.cpb-livechat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1E78CD;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 14px rgba(30, 120, 205, .45);
    transition: transform .25s ease, box-shadow .25s ease;
    -webkit-tap-highlight-color: transparent;
}

.cpb-livechat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(30, 120, 205, .55);
}

.cpb-livechat-bubble svg,
.cpb-livechat-bubble img {
    width: 26px;
    height: 26px;
    fill: #fff;
    transition: opacity .2s ease;
    object-fit: contain;
}

.cpb-livechat-bubble .cpb-livechat-icon-close {
    display: none;
}

.cpb-livechat-bubble.cpb-livechat--open .cpb-livechat-icon-chat {
    display: none;
}

.cpb-livechat-bubble.cpb-livechat--open .cpb-livechat-icon-close {
    display: block;
}

/* Pulse animation on first load */
@keyframes cpb-livechat-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(30, 120, 205, .5); }
    70%  { box-shadow: 0 0 0 14px rgba(30, 120, 205, 0); }
    100% { box-shadow: 0 0 0 0 rgba(30, 120, 205, 0); }
}

.cpb-livechat-bubble.cpb-livechat--pulse {
    animation: cpb-livechat-pulse 2s ease 3;
}

/* ---- Unread Badge ---- */
.cpb-livechat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #E53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    padding: 0 5px;
    display: none;
    pointer-events: none;
}

.cpb-livechat-badge.cpb-livechat--visible {
    display: block;
}

/* ---- Chat Panel ---- */
.cpb-livechat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    opacity: 0;
    transform: translateY(16px) scale(.96);
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
}

.cpb-livechat-panel.cpb-livechat--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---- Header ---- */
.cpb-livechat-header {
    background: #0b1829;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.cpb-livechat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1E78CD;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cpb-livechat-header-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.cpb-livechat-header-info {
    flex: 1;
    min-width: 0;
}

.cpb-livechat-header-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cpb-livechat-header-status {
    font-size: 12px;
    font-weight: 400;
    opacity: .75;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cpb-livechat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4CAF50;
    display: inline-block;
}

.cpb-livechat-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: .7;
    transition: opacity .2s ease;
    flex-shrink: 0;
}

.cpb-livechat-header-close:hover {
    opacity: 1;
}

.cpb-livechat-header-close svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* ---- Pre-chat Form ---- */
.cpb-livechat-prechat {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    justify-content: center;
}

.cpb-livechat-prechat-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    text-align: center;
    margin-bottom: 4px;
}

.cpb-livechat-prechat-subtitle {
    font-size: 13px;
    color: #666;
    text-align: center;
    margin-bottom: 8px;
}

.cpb-livechat-prechat-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cpb-livechat-prechat-field label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.cpb-livechat-prechat-field input {
    height: 40px;
    border: 1px solid #dde1e6;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .2s ease;
}

.cpb-livechat-prechat-field input:focus {
    border-color: #1E78CD;
}

.cpb-livechat-prechat-submit {
    height: 42px;
    border: none;
    border-radius: 8px;
    background: #1E78CD;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s ease;
    margin-top: 4px;
}

.cpb-livechat-prechat-submit:hover {
    background: #1766b3;
}

.cpb-livechat-prechat-skip {
    background: none;
    border: none;
    color: #888;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    text-decoration: underline;
}

.cpb-livechat-prechat-skip:hover {
    color: #555;
}

/* ---- Messages Area ---- */
.cpb-livechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

.cpb-livechat-messages::-webkit-scrollbar {
    width: 5px;
}

.cpb-livechat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ---- System / Status Messages ---- */
.cpb-livechat-system {
    text-align: center;
    font-size: 12px;
    color: #888;
    padding: 6px 0;
}

/* ---- Message Row ---- */
.cpb-livechat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
}

.cpb-livechat-msg--visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cpb-livechat-msg--ai,
.cpb-livechat-msg--operator {
    align-self: flex-start;
}

.cpb-livechat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.cpb-livechat-msg--ai .cpb-livechat-msg-avatar {
    background: #e8edf2;
    color: #1E78CD;
}

.cpb-livechat-msg--operator .cpb-livechat-msg-avatar {
    background: #e8edf2;
    color: #0b1829;
}

.cpb-livechat-msg--visitor .cpb-livechat-msg-avatar {
    display: none;
}

.cpb-livechat-msg-avatar svg {
    width: 16px;
    height: 16px;
}

.cpb-livechat-msg-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cpb-livechat-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.cpb-livechat-msg--visitor .cpb-livechat-msg-bubble {
    background: #1E78CD;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.cpb-livechat-msg--ai .cpb-livechat-msg-bubble,
.cpb-livechat-msg--operator .cpb-livechat-msg-bubble {
    background: #f0f2f5;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.cpb-livechat-msg-time {
    font-size: 11px;
    color: #999;
    padding: 0 4px;
}

.cpb-livechat-msg--visitor .cpb-livechat-msg-time {
    text-align: right;
}

/* ---- Typing Indicator ---- */
.cpb-livechat-typing {
    display: none;
    align-self: flex-start;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
    padding: 0 0 4px;
}

.cpb-livechat-typing.cpb-livechat--visible {
    display: flex;
}

.cpb-livechat-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f0f2f5;
    padding: 10px 16px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.cpb-livechat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: cpb-livechat-bounce 1.4s ease-in-out infinite;
}

.cpb-livechat-typing-dot:nth-child(2) {
    animation-delay: .16s;
}

.cpb-livechat-typing-dot:nth-child(3) {
    animation-delay: .32s;
}

@keyframes cpb-livechat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* ---- Input Area ---- */
.cpb-livechat-input {
    border-top: 1px solid #e8eaed;
    padding: 10px 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
    background: #fff;
}

.cpb-livechat-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid #dde1e6;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    min-height: 40px;
    max-height: 100px;
    outline: none;
    transition: border-color .2s ease;
}

.cpb-livechat-input textarea:focus {
    border-color: #1E78CD;
}

.cpb-livechat-input textarea::placeholder {
    color: #aaa;
}

.cpb-livechat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #1E78CD;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s ease;
}

.cpb-livechat-send:hover {
    background: #1766b3;
}

.cpb-livechat-send:disabled {
    background: #b0c4de;
    cursor: default;
}

.cpb-livechat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.cpb-livechat-capture {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #f0f7ff;
    color: #1E78CD;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s ease;
}
.cpb-livechat-capture:hover {
    background: #dbeafe;
}
.cpb-livechat-capture svg {
    width: 20px;
    height: 20px;
    fill: #1E78CD;
}

/* ---- Mobile: below 480px ---- */
@media (max-width: 480px) {
    .cpb-livechat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: calc(100vh - 60px);
        border-radius: 0;
    }

    .cpb-livechat-panel.cpb-livechat--open {
        border-radius: 16px 16px 0 0;
    }

    .cpb-livechat-bubble {
        bottom: 16px;
        right: 16px;
    }
    /* Hide bubble when chat is open on mobile — header X handles close */
    .cpb-livechat-bubble.cpb-livechat--open {
        display: none;
    }
}
