#bp-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ── toggle button ──────────────────────────────────────────── */
.bp-chat-toggle {
    box-sizing: border-box;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2147483000;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background: #007744;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 119, 68, .4);
    transition: transform .15s ease, background .15s ease;
    font-size: 24px;
}
.bp-chat-toggle:hover { background: #005c35; transform: scale(1.05); }

.bp-chat-toggle .bp-chat-close-icon { display: none; }
#bp-chat-widget.bp-open .bp-chat-toggle .bp-chat-close-icon { display: block; font-size: 28px; }
#bp-chat-widget.bp-open .bp-chat-toggle .bp-chat-toggle-icon { display: none; }

.bp-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #dc3545;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-sizing: border-box;
}

/* ── panel ─────────────────────────────────────────────────── */
.bp-chat-panel {
    position: fixed;
    bottom: 92px;
    left: auto;
    right: 20px;
    z-index: 2147483000;
    width: min(360px, calc(100vw - 40px));
    min-width: 0;
    box-sizing: border-box;
    height: 480px;
    max-height: calc(100vh - 140px);
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 119, 68, .2);
}
#bp-chat-widget.bp-open .bp-chat-panel { display: flex; }

body.bp-chat-scroll-lock {
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
}

.bp-chat-header {
    background: linear-gradient(135deg, #007744, #005c35);
    color: #fff;
    padding: 9px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}
.bp-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.bp-chat-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.bp-chat-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.bp-chat-subtitle { font-size: 12px; opacity: .85; margin-top: 2px; }
.bp-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

/* ── messages ──────────────────────────────────────────────── */
.bp-chat-messages {
    flex: 1 1 auto;
    padding: 14px;
    overflow-y: auto;
    background: rgba(245, 247, 246, .85);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.bp-chat-message {
    max-width: 82%;
    min-width: 0;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}
.bp-chat-message.bp-visitor {
    align-self: flex-end;
    background: #007744;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.bp-chat-message.bp-admin {
    align-self: flex-start;
    background: #fff;
    color: #222;
    border: 1px solid #e2e8e5;
    border-bottom-left-radius: 4px;
}
.bp-chat-time {
    font-size: 10px;
    opacity: .6;
    margin-top: 4px;
    text-align: right;
}

/* ── input ─────────────────────────────────────────────────── */
.bp-chat-input {
    flex: 0 0 auto;
    padding: 10px;
    border-top: 1px solid #e2e8e5;
    background: rgba(255, 255, 255, .85);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.bp-chat-text:focus { border-color: #007744; }
.bp-chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.bp-chat-phone {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccd6d0;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}
.bp-chat-name {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccd6d0;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}
.bp-chat-name:focus { border-color: #007744; }
.bp-chat-phone:focus { border-color: #007744; }
.bp-chat-text {
    flex: 1 1 auto;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid #ccd6d0;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 96px;
}
.bp-chat-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #007744;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bp-chat-send:disabled { background: #a3c6b3; cursor: default; }

@media (max-width: 480px) {
    html, body { overflow-x: clip; }
    @supports not (overflow: clip) {
        html, body { overflow-x: hidden; }
    }
    .bp-chat-toggle {
        right: 12px;
        bottom: 12px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
    .bp-chat-text,
    .bp-chat-phone,
    .bp-chat-name {
        font-size: 16px;
    }
    #bp-chat-widget.bp-open .bp-chat-toggle { display: none; }
    .bp-chat-panel {
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        min-width: 0;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border: none;
    }
    .bp-chat-header {
        padding-top: calc(9px + env(safe-area-inset-top));
    }
    .bp-chat-input {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}