.bpcc-chat {
    --bpcc-primary: #2563eb;
    --bpcc-header-bg: #2563eb;
    --bpcc-header-text: #ffffff;
    --bpcc-window-bg: #ffffff;
    --bpcc-messages-bg: #f3f4f6;
    --bpcc-text: #111827;
    --bpcc-agent-bg: #ffffff;
    --bpcc-agent-text: #111827;
    --bpcc-client-bg: #2563eb;
    --bpcc-client-text: #ffffff;
    --bpcc-button-bg: #2563eb;
    --bpcc-button-text: #ffffff;
    --bpcc-button-bg-hover: #1d4ed8;
    --bpcc-button-text-hover: #ffffff;
    --bpcc-send-bg: #2563eb;
    --bpcc-send-text: #ffffff;
    --bpcc-send-bg-hover: #1d4ed8;
    --bpcc-send-text-hover: #ffffff;
    --bpcc-close-bg: #e74b2a;
    --bpcc-close-bg-hover: #c73518;
    --bpcc-close-text-hover: #ffffff;
    --bpcc-input-bg: #ffffff;
    --bpcc-input-text: #111827;
    --bpcc-input-border: #d1d5db;
    --bpcc-width: 360px;
    --bpcc-height: 480px;
    --bpcc-radius: 18px;
    --bpcc-panel-border-width: 1px;
    --bpcc-toggle-width: 0px;
    --bpcc-toggle-height: 44px;
    --bpcc-toggle-padding-y: 12px;
    --bpcc-toggle-padding-x: 18px;
    --bpcc-toggle-radius: 999px;
    --bpcc-toggle-gap: 8px;
    --bpcc-icon-size: 20px;
    --bpcc-mobile-button-size: 56px;
    --bpcc-mobile-icon-size: 24px;
    --bpcc-header-height: 0px;
    --bpcc-header-padding-y: 14px;
    --bpcc-header-padding-x: 16px;
    --bpcc-close-size: 26px;
    --bpcc-messages-padding: 14px;
    --bpcc-message-padding-y: 10px;
    --bpcc-message-padding-x: 12px;
    --bpcc-message-radius: 14px;
    --bpcc-message-gap: 8px;
    --bpcc-message-max-width: 82%;
    --bpcc-typing-padding-x: 14px;
    --bpcc-typing-height: 22px;
    --bpcc-form-padding: 12px;
    --bpcc-form-gap: 8px;
    --bpcc-input-width: 0px;
    --bpcc-input-height: 44px;
    --bpcc-input-padding: 10px;
    --bpcc-input-padding-left: 10px;
    --bpcc-input-radius: 12px;
    --bpcc-send-width: 0px;
    --bpcc-send-height: 0px;
    --bpcc-send-padding-y: 0px;
    --bpcc-send-padding-x: 14px;
    --bpcc-send-radius: 12px;
    color: var(--bpcc-text);
    z-index: 99999;
}

.bpcc-chat--floating { position: fixed; bottom: 24px; }
.bpcc-chat--right { right: 24px; }
.bpcc-chat--left { left: 24px; }

.bpcc-chat__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--bpcc-toggle-gap);
    border: 0;
    border-radius: var(--bpcc-toggle-radius);
    background: var(--bpcc-button-bg);
    color: var(--bpcc-button-text);
    padding: var(--bpcc-toggle-padding-y) var(--bpcc-toggle-padding-x);
    min-height: var(--bpcc-toggle-height);
    width: var(--bpcc-toggle-width);
    min-width: fit-content;
    font-family: var(--bpcc-toggle-font-family, inherit);
    font-size: var(--bpcc-toggle-font-size, 14px);
    font-weight: var(--bpcc-toggle-font-weight, 700);
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
    box-sizing: border-box;
}
.bpcc-chat__toggle[style*="--bpcc-toggle-width:0px"], .bpcc-chat[style*="--bpcc-toggle-width:0px"] .bpcc-chat__toggle { width: auto; }
.bpcc-chat__toggle:hover { background: var(--bpcc-button-bg-hover); color: var(--bpcc-button-text-hover); }

.bpcc-chat__toggle-icon { font-size: var(--bpcc-icon-size); line-height: 1; display:inline-flex; align-items:center; justify-content:center; }

.bpcc-chat__panel {
    display: none;
    width: min(var(--bpcc-width), calc(100vw - 32px));
    height: var(--bpcc-height);
    margin-bottom: 12px;
    border-radius: var(--bpcc-radius);
    overflow: hidden;
    background: var(--bpcc-window-bg);
    box-shadow: 0 18px 60px rgba(0,0,0,.22);
    border: var(--bpcc-panel-border-width) solid rgba(0,0,0,.08);
    box-sizing: border-box;
}

.bpcc-chat:not(.bpcc-chat--floating) .bpcc-chat__panel {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    width: min(var(--bpcc-width), 100%);
    max-width: 100%;
    height: var(--bpcc-height);
}

.bpcc-chat:not(.bpcc-chat--floating) .bpcc-chat__toggle { display: none; }
.bpcc-chat--open .bpcc-chat__panel { display: flex; flex-direction: column; }
.bpcc-chat--open .bpcc-chat__toggle { display: none; }

.bpcc-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--bpcc-header-height);
    padding: var(--bpcc-header-padding-y) var(--bpcc-header-padding-x);
    background: var(--bpcc-header-bg);
    color: var(--bpcc-header-text);
    font-family: var(--bpcc-header-font-family, inherit);
    font-size: var(--bpcc-header-font-size, 15px);
    font-weight: var(--bpcc-header-font-weight, 700);
    box-sizing: border-box;
}

.bpcc-chat__close {
    border: 0;
    background: var(--bpcc-close-bg);
    color: var(--bpcc-header-text);
    font-family: var(--bpcc-close-font-family, inherit);
    font-size: var(--bpcc-close-font-size, var(--bpcc-close-size));
    font-weight: var(--bpcc-close-font-weight, 400);
    cursor: pointer;
    line-height: 1;
    width: var(--bpcc-close-size);
    height: var(--bpcc-close-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bpcc-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--bpcc-messages-padding);
    background: var(--bpcc-messages-bg);
    box-sizing: border-box;
}

.bpcc-message {
    width: fit-content;
    max-width: var(--bpcc-message-max-width);
    padding: var(--bpcc-message-padding-y) var(--bpcc-message-padding-x);
    margin: var(--bpcc-message-gap) 0;
    border-radius: var(--bpcc-message-radius);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: var(--bpcc-message-font-family, inherit);
    font-size: var(--bpcc-message-font-size, 14px);
    font-weight: var(--bpcc-message-font-weight, 400);
    line-height: 1.4;
    box-sizing: border-box;
}

.bpcc-message--agent {
    background: var(--bpcc-agent-bg);
    color: var(--bpcc-agent-text);
    border: 1px solid rgba(0,0,0,.08);
}

.bpcc-message--client {
    margin-left: auto;
    background: var(--bpcc-client-bg);
    color: var(--bpcc-client-text);
}

.bpcc-chat__typing {
    min-height: var(--bpcc-typing-height);
    padding: 0 var(--bpcc-typing-padding-x);
    font-family: var(--bpcc-typing-font-family, inherit);
    font-size: var(--bpcc-typing-font-size, 12px);
    font-weight: var(--bpcc-typing-font-weight, 400);
    color: var(--bpcc-text);
    background: var(--bpcc-messages-bg);
    opacity: .75;
    box-sizing: border-box;
}

.bpcc-chat__form {
    display: flex;
    gap: var(--bpcc-form-gap);
    padding: var(--bpcc-form-padding);
    background: var(--bpcc-window-bg);
    border-top: 1px solid rgba(0,0,0,.08);
    box-sizing: border-box;
}

.bpcc-chat__input {
    flex: 1 1 var(--bpcc-input-width);
    width: var(--bpcc-input-width);
    height: var(--bpcc-input-height);
    min-height: var(--bpcc-input-height);
    max-height: 220px;
    resize: vertical;
    border: 1px solid var(--bpcc-input-border);
    border-radius: var(--bpcc-input-radius);
    padding: var(--bpcc-input-padding-top-current, var(--bpcc-input-padding)) var(--bpcc-input-padding) var(--bpcc-input-padding-bottom-current, var(--bpcc-input-padding)) var(--bpcc-input-padding-left);
    line-height: 1.35;
    font-family: var(--bpcc-input-font-family, inherit);
    font-size: var(--bpcc-input-font-size, 14px);
    font-weight: var(--bpcc-input-font-weight, 400);
    background: var(--bpcc-input-bg);
    color: var(--bpcc-input-text);
    box-sizing: border-box;
}

.bpcc-chat__input.bpcc-chat__input--multiline {
    --bpcc-input-padding-top-current: var(--bpcc-input-padding);
    --bpcc-input-padding-bottom-current: var(--bpcc-input-padding);
}

.bpcc-chat--send-below .bpcc-chat__form {
    flex-direction: column;
    align-items: stretch;
}

.bpcc-chat--send-below .bpcc-chat__input {
    width: 100%;
    flex: 0 0 auto;
}

.bpcc-chat--send-below .bpcc-chat__send {
    align-self: stretch;
}

.bpcc-chat__send {
    border: 0;
    border-radius: var(--bpcc-send-radius);
    padding: var(--bpcc-send-padding-y) var(--bpcc-send-padding-x);
    width: var(--bpcc-send-width);
    height: var(--bpcc-send-height);
    min-width: fit-content;
    background: var(--bpcc-send-bg);
    color: var(--bpcc-send-text);
    font-size: var(--bpcc-send-font-size, 14px);
    font-weight: var(--bpcc-send-font-weight, 700);
    font-family: var(--bpcc-send-font-family, inherit);
    cursor: pointer;
    box-sizing: border-box;
}
.bpcc-chat[style*="--bpcc-send-width:0px"] .bpcc-chat--send-below .bpcc-chat__form {
    flex-direction: column;
    align-items: stretch;
}

.bpcc-chat--send-below .bpcc-chat__input {
    width: 100%;
    flex: 0 0 auto;
}

.bpcc-chat--send-below .bpcc-chat__send {
    align-self: stretch;
}

.bpcc-chat__send { width: auto; }
.bpcc-chat[style*="--bpcc-send-height:0px"] .bpcc-chat--send-below .bpcc-chat__form {
    flex-direction: column;
    align-items: stretch;
}

.bpcc-chat--send-below .bpcc-chat__input {
    width: 100%;
    flex: 0 0 auto;
}

.bpcc-chat--send-below .bpcc-chat__send {
    align-self: stretch;
}

.bpcc-chat__send { height: auto; }

.bpcc-chat__toggle--mobile-preview { width: var(--bpcc-mobile-button-size); height: var(--bpcc-mobile-button-size); min-width: 0; min-height: 0; padding: 0; border-radius: 999px; }
.bpcc-chat__toggle--mobile-preview .bpcc-chat__toggle-icon { font-size: var(--bpcc-mobile-icon-size); }

@media (max-width: 480px) {
    .bpcc-chat--floating { left: 16px; right: 16px; bottom: 16px; }
    .bpcc-chat__panel { width: 100%; height: min(var(--bpcc-height), 70vh); }
    .bpcc-chat__toggle { width: var(--bpcc-mobile-button-size); height: var(--bpcc-mobile-button-size); min-width: 0; min-height: 0; justify-content: center; padding: 0; border-radius: 999px; }
    .bpcc-chat__toggle-text { display: none; }
    .bpcc-chat__toggle-icon { font-size: var(--bpcc-mobile-icon-size); }
}

.bpcc-chat__operator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.bpcc-chat__operator-avatar,
.bpcc-message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    object-fit: cover;
    flex: 0 0 auto;
    background: rgba(255,255,255,.35);
}
.bpcc-chat__operator span { display: flex; flex-direction: column; min-width: 0; }
.bpcc-chat__operator small { font-size: 11px; line-height: 1.2; opacity: .85; font-weight: 400; }
.bpcc-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: var(--bpcc-message-gap) 0;
}
.bpcc-message-row--client { justify-content: flex-end; }
.bpcc-message-row--client .bpcc-message { margin-left: auto; }
.bpcc-message-row .bpcc-message { margin: 0; }
.bpcc-message-stack { max-width: var(--bpcc-message-max-width); display: flex; flex-direction: column; gap: 3px; }
.bpcc-message-stack .bpcc-message { max-width: 100%; }
.bpcc-message-name {
    font-family: var(--bpcc-message-font-family, inherit);
    font-size: 11px;
    opacity: .7;
    color: var(--bpcc-text);
    line-height: 1.2;
}

.bpcc-chat__close:hover { background: var(--bpcc-close-bg-hover); color: var(--bpcc-close-text-hover); opacity: .95; }
.bpcc-chat__send:hover { background: var(--bpcc-send-bg-hover); color: var(--bpcc-send-text-hover); }


/* Attachments */
.bpcc-chat__form { flex-wrap: wrap; align-items: stretch; }
.bpcc-chat__attach {
    width: var(--bpcc-send-height);
    min-width: 38px;
    height: var(--bpcc-send-height);
    border: 1px solid var(--bpcc-input-border);
    border-radius: var(--bpcc-input-radius);
    background: var(--bpcc-input-bg);
    color: var(--bpcc-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
    flex: 0 0 auto;
}
.bpcc-chat__attach input { display: none; }
.bpcc-chat__file { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; border: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; opacity: 0 !important; pointer-events: none !important; }
.bpcc-chat__attach:hover { background: rgba(0,0,0,.04); }
.bpcc-chat__files { flex: 0 0 100%; font-size: 12px; color: var(--bpcc-text); opacity: .8; overflow-wrap: anywhere; }
.bpcc-attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.bpcc-attachment { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; overflow-wrap: anywhere; }
.bpcc-attachment--image { display: block; }
.bpcc-attachment--image img { display: block; max-width: min(220px, 100%); max-height: 160px; border-radius: 8px; object-fit: contain; margin-bottom: 4px; }
.bpcc-attachment--image span, .bpcc-attachment--zip span { font-size: 12px; opacity: .85; }
.bpcc-chat--send-below .bpcc-chat__attach { align-self: flex-start; }

/* Attachment composer layout + link/attachment styling */
.bpcc-chat__form {
    flex-direction: column;
    align-items: stretch;
}
.bpcc-chat__composer {
    display: flex;
    gap: var(--bpcc-form-gap);
    align-items: stretch;
    width: 100%;
    min-width: 0;
}
.bpcc-chat__actions {
    display: flex;
    gap: var(--bpcc-form-gap);
    align-items: stretch;
    flex: 0 0 auto;
}
.bpcc-chat--send-below .bpcc-chat__composer {
    flex-direction: column;
}
.bpcc-chat--send-below .bpcc-chat__actions {
    justify-content: flex-end;
}
.bpcc-chat--send-below .bpcc-chat__send {
    flex: 1 1 auto;
}
.bpcc-chat__attach {
    width: var(--bpcc-attach-button-width) !important;
    min-width: var(--bpcc-attach-button-width) !important;
    height: var(--bpcc-attach-button-height) !important;
    min-height: var(--bpcc-attach-button-height) !important;
    border: 1px solid var(--bpcc-attach-button-border) !important;
    border-radius: var(--bpcc-attach-button-radius) !important;
    background: var(--bpcc-attach-button-bg) !important;
    color: var(--bpcc-attach-button-text) !important;
    padding: 0;
    line-height: 1;
}
.bpcc-chat__attach i { font-size: var(--bpcc-attach-button-icon-size); }
.bpcc-chat__attach:hover {
    background: var(--bpcc-attach-button-bg-hover) !important;
    color: var(--bpcc-attach-button-text-hover) !important;
}
.bpcc-chat__files {
    order: -1;
    display: flex;
    flex-wrap: wrap;
    gap: var(--bpcc-attach-preview-gap);
    width: 100%;
    margin: 0;
    opacity: 1 !important;
}
.bpcc-chat__file-name,
.bpcc-admin-chat__file-name {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: var(--bpcc-attach-name-padding-y) var(--bpcc-attach-name-padding-x);
    border: 1px solid var(--bpcc-attach-name-border);
    border-radius: var(--bpcc-attach-name-radius);
    background: var(--bpcc-attach-name-bg);
    color: var(--bpcc-attach-name-text);
    font-family: var(--bpcc-attach-name-font-family, inherit);
    font-size: var(--bpcc-attach-name-font-size, 12px);
    font-weight: var(--bpcc-attach-name-font-weight, 400);
    line-height: 1.25;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
}
.bpcc-message a:not(.bpcc-attachment) {
    color: var(--bpcc-message-link-color);
    font-family: var(--bpcc-link-font-family, inherit);
    font-size: var(--bpcc-link-font-size, inherit);
    font-weight: var(--bpcc-link-font-weight, 500);
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.bpcc-message a:not(.bpcc-attachment):hover {
    color: var(--bpcc-message-link-hover-color);
}

/* FIX: stable message composer and attachment button placement */
.bpcc-chat__form {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: var(--bpcc-form-gap) !important;
    flex: 0 0 auto !important;
    min-height: 0 !important;
    max-height: 45% !important;
    overflow: hidden !important;
}

.bpcc-chat__files {
    display: none;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-height: 72px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    order: 0 !important;
    opacity: 1 !important;
}

.bpcc-chat__files:not(:empty) {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: var(--bpcc-attach-preview-gap) !important;
}

.bpcc-chat__composer {
    order: 1 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: var(--bpcc-form-gap) !important;
    align-items: stretch !important;
    width: 100% !important;
    min-width: 0 !important;
}

.bpcc-chat__input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: none !important;
    resize: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.bpcc-chat__actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: flex-end !important;
    gap: var(--bpcc-form-gap) !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
}

.bpcc-chat__attach {
    order: 1 !important;
    flex: 0 0 var(--bpcc-attach-button-width) !important;
}

.bpcc-chat__send {
    order: 2 !important;
    flex: 0 0 auto !important;
}

.bpcc-chat--send-below .bpcc-chat__composer {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
}

.bpcc-chat--send-below .bpcc-chat__actions {
    width: 100% !important;
    justify-content: flex-end !important;
    margin-left: auto !important;
}

.bpcc-chat--send-below .bpcc-chat__send {
    align-self: stretch !important;
    width: auto !important;
}

.bpcc-chat__file-name {
    max-width: 100% !important;
    white-space: normal !important;
    gap: 5px !important;
}
.bpcc-chat__file-name i {
    margin-right: 5px !important;
    flex: 0 0 auto !important;
}


/* FIX: align attachment and send buttons to the right */
.bpcc-chat__actions {
    justify-content: flex-end !important;
    margin-left: auto !important;
}
.bpcc-chat--send-below .bpcc-chat__actions {
    align-self: flex-end !important;
    justify-content: flex-end !important;
    margin-left: auto !important;
}

/* FIX: client chat line spacing only.
   Messages are already converted to <br> in PHP, so pre-wrap caused doubled line breaks. */
.bpcc-chat .bpcc-message {
    white-space: normal !important;
}
.bpcc-chat .bpcc-message p {
    margin-top: 0 !important;
    margin-bottom: .45em !important;
}
.bpcc-chat .bpcc-message p:last-child {
    margin-bottom: 0 !important;
}
.bpcc-chat .bpcc-message br {
    line-height: inherit !important;
}

/* v1.0.46: harden frontend CSS so theme styles cannot override chat colors/fonts. */
.bpcc-chat,
.bpcc-chat * {
    box-sizing: border-box;
}
.bpcc-chat .bpcc-chat__panel {
    background: var(--bpcc-window-bg) !important;
    color: var(--bpcc-text) !important;
    font-family: var(--bpcc-message-font-family, inherit);
}
.bpcc-chat .bpcc-chat__header {
    background: var(--bpcc-header-bg) !important;
    color: var(--bpcc-header-text) !important;
    font-family: var(--bpcc-header-font-family, inherit) !important;
    font-size: var(--bpcc-header-font-size, 15px) !important;
    font-weight: var(--bpcc-header-font-weight, 700) !important;
}
.bpcc-chat .bpcc-chat__operator,
.bpcc-chat .bpcc-chat__operator strong,
.bpcc-chat .bpcc-chat__operator small {
    color: var(--bpcc-header-text) !important;
    font-family: var(--bpcc-header-font-family, inherit) !important;
}
.bpcc-chat .bpcc-chat__close {
    appearance: none !important;
    -webkit-appearance: none !important;
    border: 0 !important;
    background: var(--bpcc-close-bg) !important;
    color: var(--bpcc-header-text) !important;
    font-family: var(--bpcc-close-font-family, inherit) !important;
    font-size: var(--bpcc-close-font-size, var(--bpcc-close-size)) !important;
    font-weight: var(--bpcc-close-font-weight, 400) !important;
    width: var(--bpcc-close-size) !important;
    height: var(--bpcc-close-size) !important;
    min-width: var(--bpcc-close-size) !important;
    min-height: var(--bpcc-close-size) !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}
.bpcc-chat .bpcc-chat__close:hover,
.bpcc-chat .bpcc-chat__close:focus {
    background: var(--bpcc-close-bg-hover) !important;
    color: var(--bpcc-close-text-hover) !important;
}
.bpcc-chat .bpcc-chat__messages {
    background: var(--bpcc-messages-bg) !important;
    color: var(--bpcc-text) !important;
}
.bpcc-chat .bpcc-message {
    font-family: var(--bpcc-message-font-family, inherit) !important;
    font-size: var(--bpcc-message-font-size, 14px) !important;
    font-weight: var(--bpcc-message-font-weight, 400) !important;
}
.bpcc-chat .bpcc-message--agent {
    background: var(--bpcc-agent-bg) !important;
    color: var(--bpcc-agent-text) !important;
}
.bpcc-chat .bpcc-message--client {
    background: var(--bpcc-client-bg) !important;
    color: var(--bpcc-client-text) !important;
}
.bpcc-chat .bpcc-message-name {
    color: var(--bpcc-text) !important;
    font-family: var(--bpcc-message-font-family, inherit) !important;
}
.bpcc-chat .bpcc-chat__typing {
    background: var(--bpcc-messages-bg) !important;
    color: var(--bpcc-text) !important;
    font-family: var(--bpcc-typing-font-family, inherit) !important;
    font-size: var(--bpcc-typing-font-size, 12px) !important;
    font-weight: var(--bpcc-typing-font-weight, 400) !important;
}
.bpcc-chat .bpcc-chat__form,
.bpcc-chat .bpcc-chat__composer {
    background: var(--bpcc-window-bg) !important;
}
.bpcc-chat .bpcc-chat__input {
    appearance: none !important;
    -webkit-appearance: none !important;
    background: var(--bpcc-input-bg) !important;
    color: var(--bpcc-input-text) !important;
    border-color: var(--bpcc-input-border) !important;
    font-family: var(--bpcc-input-font-family, inherit) !important;
    font-size: var(--bpcc-input-font-size, 14px) !important;
    font-weight: var(--bpcc-input-font-weight, 400) !important;
    box-shadow: none !important;
}
.bpcc-chat .bpcc-chat__input::placeholder {
    color: var(--bpcc-input-text) !important;
    opacity: .65 !important;
    font-family: var(--bpcc-input-font-family, inherit) !important;
}
.bpcc-chat .bpcc-chat__send {
    appearance: none !important;
    -webkit-appearance: none !important;
    background: var(--bpcc-send-bg) !important;
    color: var(--bpcc-send-text) !important;
    border: 0 !important;
    font-family: var(--bpcc-send-font-family, inherit) !important;
    font-size: var(--bpcc-send-font-size, 14px) !important;
    font-weight: var(--bpcc-send-font-weight, 700) !important;
    box-shadow: none !important;
}
.bpcc-chat .bpcc-chat__send:hover,
.bpcc-chat .bpcc-chat__send:focus {
    background: var(--bpcc-send-bg-hover) !important;
    color: var(--bpcc-send-text-hover) !important;
}
.bpcc-chat .bpcc-chat__attach {
    background: var(--bpcc-attach-button-bg) !important;
    color: var(--bpcc-attach-button-text) !important;
    border-color: var(--bpcc-attach-button-border) !important;
}
.bpcc-chat .bpcc-chat__attach:hover,
.bpcc-chat .bpcc-chat__attach:focus {
    background: var(--bpcc-attach-button-bg-hover) !important;
    color: var(--bpcc-attach-button-text-hover) !important;
}
.bpcc-chat .bpcc-chat__file-name {
    background: var(--bpcc-attach-name-bg) !important;
    color: var(--bpcc-attach-name-text) !important;
    border-color: var(--bpcc-attach-name-border) !important;
    font-family: var(--bpcc-attach-name-font-family, inherit) !important;
    font-size: var(--bpcc-attach-name-font-size, 12px) !important;
    font-weight: var(--bpcc-attach-name-font-weight, 400) !important;
}
.bpcc-chat .bpcc-message a:not(.bpcc-attachment) {
    color: var(--bpcc-message-link-color) !important;
    font-family: var(--bpcc-link-font-family, inherit) !important;
    font-size: var(--bpcc-link-font-size, inherit) !important;
    font-weight: var(--bpcc-link-font-weight, 500) !important;
}
.bpcc-chat .bpcc-message a:not(.bpcc-attachment):hover {
    color: var(--bpcc-message-link-hover-color) !important;
}


/* Wskaźnik pisania w oknie klienta: trzy kropki na dole konwersacji. */
.bpcc-chat__typing {
    display: flex !important;
    align-items: center !important;
}
.bpcc-typing-dots {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    min-height: 18px !important;
    padding: 3px 8px !important;
    border-radius: 999px !important;
    background: rgba(0,0,0,.06) !important;
}
.bpcc-typing-dots i {
    width: 5px !important;
    height: 5px !important;
    border-radius: 50% !important;
    background: currentColor !important;
    opacity: .45 !important;
    animation: bpccTypingDots 1.05s infinite ease-in-out !important;
}
.bpcc-typing-dots i:nth-child(2) { animation-delay: .16s !important; }
.bpcc-typing-dots i:nth-child(3) { animation-delay: .32s !important; }
@keyframes bpccTypingDots {
    0%, 80%, 100% { transform: translateY(0); opacity: .35; }
    40% { transform: translateY(-3px); opacity: .95; }
}


/* BPCC 1.0.62: pierwsza wiadomość automatyczna używa dokładnie tego samego układu co odpowiedź operatora. */
.bpcc-chat .bpcc-message-row--static {
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
    justify-content: flex-start !important;
}
.bpcc-chat .bpcc-message-row--static .bpcc-message-stack {
    max-width: var(--bpcc-message-max-width) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
}
.bpcc-chat .bpcc-message-row--static .bpcc-message--agent {
    max-width: 100% !important;
}
.bpcc-chat .bpcc-message-row--static .bpcc-message-meta--static {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
}

/* Header przed rozpoczęciem rozmowy: pokazujemy tylko tytuł czatu, bez operatora. */
.bpcc-chat__operator--title-only {
    gap: 0 !important;
}
.bpcc-chat__operator--title-only .bpcc-chat__operator-avatar,
.bpcc-chat__operator--title-only small {
    display: none !important;
}
.bpcc-chat__operator--title-only span {
    display: flex !important;
    align-items: center !important;
}


/* BPCC 1.0.69: mobile composer fix after adding attachments.
   Keep attachment and send buttons aligned in one row on narrow screens. */
@media (max-width: 480px) {
    .bpcc-chat .bpcc-chat__form {
        max-height: none !important;
        overflow: visible !important;
    }
    .bpcc-chat .bpcc-chat__files {
        max-height: none !important;
        overflow: visible !important;
    }
    .bpcc-chat .bpcc-chat__composer,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__composer {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        width: 100% !important;
        min-width: 0 !important;
        gap: var(--bpcc-form-gap) !important;
    }
    .bpcc-chat .bpcc-chat__input {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
    .bpcc-chat .bpcc-chat__actions,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__actions {
        display: grid !important;
        grid-template-columns: var(--bpcc-attach-button-width) minmax(0, 1fr) !important;
        align-items: stretch !important;
        justify-content: stretch !important;
        align-self: stretch !important;
        width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
        gap: var(--bpcc-form-gap) !important;
    }
    .bpcc-chat .bpcc-chat__attach {
        width: var(--bpcc-attach-button-width) !important;
        min-width: var(--bpcc-attach-button-width) !important;
        height: var(--bpcc-attach-button-height) !important;
        min-height: var(--bpcc-attach-button-height) !important;
        align-self: stretch !important;
        justify-self: stretch !important;
        margin: 0 !important;
    }
    .bpcc-chat .bpcc-chat__send,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__send {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        align-self: stretch !important;
        justify-self: stretch !important;
        flex: none !important;
        margin: 0 !important;
    }
    .bpcc-chat .bpcc-chat__file-name {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* BPCC 1.0.70: separate photo button and image gallery lightbox. */
.bpcc-chat .bpcc-chat__image-button {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: var(--bpcc-image-button-width, 44px) !important;
    min-width: var(--bpcc-image-button-width, 44px) !important;
    height: var(--bpcc-image-button-height, 44px) !important;
    min-height: var(--bpcc-image-button-height, 44px) !important;
    border: 1px solid var(--bpcc-image-button-border, #000000) !important;
    border-radius: var(--bpcc-image-button-radius, 0px) !important;
    background: var(--bpcc-image-button-bg, #000000) !important;
    color: var(--bpcc-image-button-text, #ffffff) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    flex: 0 0 var(--bpcc-image-button-width, 44px) !important;
    padding: 0 !important;
    line-height: 1 !important;
    margin: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    text-indent: 0 !important;
    font-size: 0 !important;
}
.bpcc-chat .bpcc-chat__image-button i {
    font-size: var(--bpcc-image-button-icon-size, 16px) !important;
    line-height: 1 !important;
    color: inherit !important;
}
.bpcc-chat .bpcc-chat__image-button:hover,
.bpcc-chat .bpcc-chat__image-button:focus {
    background: var(--bpcc-image-button-bg-hover, #222222) !important;
    color: var(--bpcc-image-button-text-hover, #ffffff) !important;
}
.bpcc-chat .bpcc-chat__file-name--image {
    border-color: var(--bpcc-image-button-border, #000000) !important;
}
.bpcc-chat .bpcc-attachment--image {
    cursor: zoom-in !important;
    display: inline-flex !important;
    flex-direction: column !important;
    width: min(180px, 100%) !important;
    max-width: 100% !important;
}
.bpcc-chat .bpcc-attachment--image img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    max-height: none !important;
    object-fit: cover !important;
    border-radius: 8px !important;
}
.bpcc-lightbox {
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(9, 12, 18, .88) !important;
    padding: 24px !important;
    box-sizing: border-box !important;
}
.bpcc-lightbox--open { display: flex !important; }
.bpcc-lightbox figure {
    margin: 0 !important;
    max-width: min(94vw, 1100px) !important;
    max-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
}
.bpcc-lightbox img {
    display: block !important;
    max-width: 100% !important;
    max-height: calc(92vh - 52px) !important;
    object-fit: contain !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0,0,0,.45) !important;
}
.bpcc-lightbox figcaption {
    color: #fff !important;
    font: 500 13px/1.3 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    opacity: .9 !important;
    text-align: center !important;
}
.bpcc-lightbox__close,
.bpcc-lightbox__nav {
    position: absolute !important;
    border: 0 !important;
    background: rgba(0,0,0,.72) !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 22px rgba(0,0,0,.32) !important;
}
.bpcc-lightbox__close {
    top: 18px !important;
    right: 18px !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
    font-size: 34px !important;
    line-height: 1 !important;
}
.bpcc-lightbox__nav {
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 52px !important;
    height: 70px !important;
    border-radius: 12px !important;
    font-size: 46px !important;
    line-height: 1 !important;
}
.bpcc-lightbox__nav--prev { left: 18px !important; }
.bpcc-lightbox__nav--next { right: 18px !important; }
.bpcc-lightbox__close:hover,
.bpcc-lightbox__nav:hover { background: rgba(231,75,42,.95) !important; }


.bpcc-chat .bpcc-chat__actions,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__actions {
    display: grid !important;
    grid-template-columns: var(--bpcc-attach-button-width, 44px) var(--bpcc-image-button-width, 44px) minmax(0, auto) !important;
    align-items: stretch !important;
}
.bpcc-chat .bpcc-chat__attach,
.bpcc-chat .bpcc-chat__image-button {
    justify-self: stretch !important;
    align-self: stretch !important;
}
@media (max-width: 480px) {
    .bpcc-chat .bpcc-chat__actions,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__actions {
        display: grid !important;
        grid-template-columns: var(--bpcc-attach-button-width, 44px) var(--bpcc-image-button-width, 44px) minmax(0, 1fr) !important;
        align-items: stretch !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    .bpcc-chat .bpcc-chat__attach,
    .bpcc-chat .bpcc-chat__image-button {
        align-self: stretch !important;
        justify-self: stretch !important;
    }
    .bpcc-chat .bpcc-chat__send,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__send {
        width: 100% !important;
        min-width: 0 !important;
        justify-self: stretch !important;
        align-self: stretch !important;
    }
    .bpcc-lightbox { padding: 12px !important; }
    .bpcc-lightbox__nav { width: 42px !important; height: 56px !important; font-size: 36px !important; }
    .bpcc-lightbox__nav--prev { left: 8px !important; }
    .bpcc-lightbox__nav--next { right: 8px !important; }
    .bpcc-lightbox__close { top: 8px !important; right: 8px !important; width: 40px !important; height: 40px !important; }
}


/* BPCC 1.0.73: keep attachment/photo buttons equal and prevent composer from breaking after selecting files/images. */
.bpcc-chat .bpcc-chat__form {
    flex: 0 0 auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.bpcc-chat .bpcc-chat__files {
    display: none !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 84px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.bpcc-chat .bpcc-chat__files:not(:empty) {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: var(--bpcc-attach-preview-gap) !important;
}

.bpcc-chat .bpcc-chat__composer,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__composer {
    order: 1 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: stretch !important;
    gap: var(--bpcc-form-gap) !important;
    width: 100% !important;
    min-width: 0 !important;
}

.bpcc-chat .bpcc-chat__input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    align-self: stretch !important;
}

.bpcc-chat .bpcc-chat__actions,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__actions {
    display: grid !important;
    grid-template-columns: var(--bpcc-attach-button-width, 44px) var(--bpcc-attach-button-width, 44px) minmax(0, auto) !important;
    grid-auto-rows: minmax(var(--bpcc-attach-button-height, 44px), auto) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    align-self: stretch !important;
    gap: var(--bpcc-form-gap) !important;
    min-width: 0 !important;
    margin-left: 0 !important;
}

.bpcc-chat .bpcc-chat__attach,
.bpcc-chat .bpcc-chat__image-button {
    width: var(--bpcc-attach-button-width, 44px) !important;
    min-width: var(--bpcc-attach-button-width, 44px) !important;
    height: var(--bpcc-attach-button-height, 44px) !important;
    min-height: var(--bpcc-attach-button-height, 44px) !important;
    flex: 0 0 var(--bpcc-attach-button-width, 44px) !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    margin: 0 !important;
}

.bpcc-chat .bpcc-chat__send,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__send {
    align-self: stretch !important;
    justify-self: stretch !important;
    min-width: 0 !important;
    margin: 0 !important;
}

@media (max-width: 480px) {
    .bpcc-chat .bpcc-chat__composer,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__composer {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
    }

    .bpcc-chat .bpcc-chat__actions,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__actions {
        display: grid !important;
        grid-template-columns: var(--bpcc-attach-button-width, 44px) var(--bpcc-attach-button-width, 44px) minmax(0, 1fr) !important;
        width: 100% !important;
    }

    .bpcc-chat .bpcc-chat__send,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__send {
        width: 100% !important;
        height: auto !important;
    }
}


/* BPCC 1.0.74: fixed full-width message field and stable button row.
   The textarea is always full width; attachment/photo/send buttons stay below it. */
.bpcc-chat .bpcc-chat__form {
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    max-height: none !important;
    overflow: visible !important;
}

.bpcc-chat .bpcc-chat__files {
    display: none !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 76px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    order: 0 !important;
}

.bpcc-chat .bpcc-chat__files:not(:empty) {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: var(--bpcc-attach-preview-gap, 6px) !important;
}

.bpcc-chat .bpcc-chat__composer,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__composer {
    order: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    grid-template-columns: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    gap: var(--bpcc-form-gap, 8px) !important;
}

.bpcc-chat .bpcc-chat__input,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__input {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    align-self: stretch !important;
    box-sizing: border-box !important;
}

.bpcc-chat .bpcc-chat__actions,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__actions {
    display: grid !important;
    grid-template-columns: var(--bpcc-attach-button-width, 44px) var(--bpcc-attach-button-width, 44px) minmax(0, auto) !important;
    grid-auto-rows: minmax(var(--bpcc-attach-button-height, 44px), auto) !important;
    align-items: stretch !important;
    justify-content: end !important;
    align-self: stretch !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    gap: var(--bpcc-form-gap, 8px) !important;
}

.bpcc-chat .bpcc-chat__attach,
.bpcc-chat .bpcc-chat__image-button {
    width: var(--bpcc-attach-button-width, 44px) !important;
    min-width: var(--bpcc-attach-button-width, 44px) !important;
    max-width: var(--bpcc-attach-button-width, 44px) !important;
    height: var(--bpcc-attach-button-height, 44px) !important;
    min-height: var(--bpcc-attach-button-height, 44px) !important;
    max-height: var(--bpcc-attach-button-height, 44px) !important;
    flex: 0 0 var(--bpcc-attach-button-width, 44px) !important;
    align-self: stretch !important;
    justify-self: stretch !important;
    margin: 0 !important;
}

.bpcc-chat .bpcc-chat__send,
.bpcc-chat.bpcc-chat--send-below .bpcc-chat__send {
    align-self: stretch !important;
    justify-self: stretch !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: var(--bpcc-attach-button-height, 44px) !important;
    margin: 0 !important;
}

@media (max-width: 480px) {
    .bpcc-chat .bpcc-chat__actions,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__actions {
        grid-template-columns: var(--bpcc-attach-button-width, 44px) var(--bpcc-attach-button-width, 44px) minmax(0, 1fr) !important;
        justify-content: stretch !important;
    }
    .bpcc-chat .bpcc-chat__send,
    .bpcc-chat.bpcc-chat--send-below .bpcc-chat__send {
        width: 100% !important;
    }
}
/* BPCC 1.0.85 Google identity button in composer */
.bpcc-google-area{display:inline-flex;align-items:center;gap:5px;max-width:175px;flex-wrap:wrap}
.bpcc-google-button{display:inline-flex;align-items:center;min-height:30px}
.bpcc-google-identity{font-size:11px;max-width:125px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bpcc-google-logout{font-size:11px;cursor:pointer}
