/* Card shadow + outline for the chat box (robust against theme overrides). */
[data-blc-chat] {
    box-shadow: 0 4px 16px rgba(17, 24, 39, 0.10) !important;
    border: 1px solid #ece8dc !important;
    border-radius: 16px !important;
    overflow: hidden;
}

#blc-messages {
    overflow-y: auto;
    scroll-behavior: smooth;
}

.blc-msg {
    max-width: 75%;
    margin-bottom: 0.25rem;
}

.blc-msg-admin {
    align-self: flex-start;
}

/* System notices (greeting, waiting-for-agent, conversation ended, etc.):
   centered, muted plain text — deliberately NOT a chat bubble. */
.blc-msg-system {
    align-self: center;
    max-width: 85%;
    margin: 0.5rem auto;
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #6b7280;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.blc-msg-visitor {
    align-self: flex-end;
}

.blc-msg-text {
    padding: 0.85rem 1.15rem;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.blc-msg-admin .blc-msg-text {
    background-color: #fffdf4;
    color: #111827;
    border: 1px solid #d9dce2;
}

.blc-msg-visitor .blc-msg-text {
    background-color: #111827;
    color: #ffffff;
}

.blc-msg-meta {
    font-size: 0.72rem;
    color: #6b7280;
    margin-top: 0.2rem;
    padding: 0 0.25rem;
}

.blc-msg-admin .blc-msg-meta {
    text-align: left;
}

.blc-msg-visitor .blc-msg-meta {
    text-align: right;
}

#blc-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    padding: 0.25rem 0.5rem;
}

#blc-input::placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* Upload Button */

.blc-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
}

.blc-upload-btn:hover {
    background: #f0ecdf;
    color: #111827;
}

.blc-upload-btn.blc-uploading {
    opacity: 0.5;
    pointer-events: none;
    animation: blc-pulse 1s infinite;
}

@keyframes blc-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.9; }
}

/* Image Messages */

.blc-msg-image {
    border-radius: 12px;
    overflow: hidden;
    max-width: 280px;
}

.blc-msg-image img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 340px;
    border-radius: 12px;
    cursor: pointer;
}

.blc-msg-image a {
    display: block;
    line-height: 0;
}

/* File Attachments */

.blc-msg-file {
    max-width: 280px;
}

.blc-file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.blc-file-link:hover {
    background: rgba(0, 0, 0, 0.08);
}

.blc-msg-visitor .blc-file-link {
    background: rgba(255, 255, 255, 0.15);
}

.blc-msg-visitor .blc-file-link:hover {
    background: rgba(255, 255, 255, 0.25);
}

.blc-file-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    opacity: 0.7;
}

.blc-file-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blc-file-download {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    opacity: 0.5;
}

.blc-file-link:hover .blc-file-download {
    opacity: 1;
}

/* Typing Indicator */

.blc-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.75rem 1.15rem;
    background-color: #f0ecdf;
    border-radius: 12px;
    width: fit-content;
}

.blc-typing-dot {
    width: 8px;
    height: 8px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: blc-typing-bounce 1.4s infinite ease-in-out both;
}

.blc-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.blc-typing-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.blc-typing-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes blc-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Status Dot */

#blc-status-dot {
    transition: background-color 0.5s ease;
}

#blc-status-text {
    transition: color 0.5s ease;
}

/* Service Buttons (Phone / Screen Share) */

.blc-service-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}

.blc-service-btn:hover {
    background: #f0ecdf;
    color: #111827;
}

/* End Chat: same size/shape as the upload icon, but a light-red filled circle
   with a red border and a red icon so it reads as the destructive action. */
#blc-endconv-btn {
    background-color: #fddcdd;
    border: 1px solid #f3b5b7;
    color: #d63638;
}

#blc-endconv-btn:hover {
    background-color: #fbc9cb;
    border-color: #eca3a5;
    color: #b32d2e;
}

#blc-phone-btn,
#blc-screen-btn {
    width: auto;
    height: auto;
    max-width: none;        /* override .is-layout-constrained > * */
    margin: 0;              /* override .is-layout-constrained > * margin-inline: auto */
    align-self: center;
    background-color: #ffffff;
    border: 1px solid #d9dce2;
    border-radius: 2.5rem;
    padding: 0.9rem;
    flex-shrink: 0;
}

#blc-phone-btn:hover,
#blc-screen-btn:hover {
    background-color: #f0ecdf;
    border-color: #f0ecdf;
}

/* -------------------------------------------------------------------------
   Service Modal
   ------------------------------------------------------------------------- */

#blc-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

#blc-modal-overlay.blc-modal-open {
    display: flex;
}

.blc-modal {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    text-align: center;
    font-family: inherit;
}

.blc-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.blc-modal-close:hover {
    color: #374151;
}

.blc-modal-icon {
    margin-bottom: 1rem;
}

.blc-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #000000;
    margin: 0 0 0.5rem 0;
}

.blc-modal-desc {
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.5;
    margin: 0 0 1rem 0;
}

.blc-modal-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.25rem;
}

.blc-modal-field {
    text-align: left;
    margin-bottom: 1rem;
}

.blc-modal-field-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.35rem;
}

.blc-modal-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d9dce2;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.blc-modal-input:focus {
    border-color: #111827;
    box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.15);
}

.blc-modal-btn {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background-color: #111827;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s;
}

.blc-modal-btn:hover {
    background-color: #000000;
}

.blc-modal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.blc-modal-cancel {
    display: inline-block;
    margin-top: 0.75rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.blc-modal-cancel:hover {
    color: #374151;
}

.blc-modal-error {
    display: none;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 8px;
    font-size: 0.85rem;
}

.blc-auth-error {
    display: none;
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 8px;
    font-size: 0.8rem;
}

/* -------------------------------------------------------------------------
   Chat History Modal
   ------------------------------------------------------------------------- */

.blc-history-modal-body {
    width: 100%;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 0.5rem;
    text-align: left;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.blc-history-item {
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
    border-bottom: 1px solid #f3f4f6;
}

.blc-history-item:last-child {
    border-bottom: none;
}

.blc-history-item:hover {
    background-color: #f0ecdf;
}

.blc-history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.blc-history-date {
    font-size: 0.78rem;
    font-weight: 600;
    color: #111827;
}

.blc-history-count {
    font-size: 0.72rem;
    color: #9ca3af;
}

.blc-history-preview {
    font-size: 0.82rem;
    color: #6b7280;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.blc-history-empty,
.blc-history-loading {
    font-size: 0.85rem;
    color: #9ca3af;
    text-align: center;
    padding: 1rem 0;
    margin: 0;
}

.blc-history-back {
    width: 100%;
    padding: 0.65rem 1.25rem;
    background-color: #111827;
    color: #ffffff;
    border: none;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s;
}

.blc-history-back:hover {
    background-color: #000000;
}

/* Screen Share Invite Banner */

#blc-screenshare-invite {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: #111827;
    color: #ffffff;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.blc-ss-icon {
    flex-shrink: 0;
    opacity: 0.9;
}

.blc-ss-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 120px;
}

.blc-ss-text strong {
    font-size: 0.9rem;
    font-weight: 600;
}

.blc-ss-text span {
    font-size: 0.78rem;
    opacity: 0.8;
}

.blc-ss-join {
    display: inline-block;
    padding: 0.5rem 1.1rem;
    background: #ffffff;
    color: #111827;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}

.blc-ss-join:hover {
    background: #f0ecdf;
    color: #111827;
}

/* Cookie Consent Lightbox */

#blc-cookie-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12;
    border-radius: inherit;
}

.blc-cookie-dialog {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    padding: 2rem 1.75rem;
    max-width: 300px;
    width: 88%;
    text-align: center;
}

.blc-cookie-icon {
    width: 52px;
    height: 52px;
    background: #e8f0fe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.1rem;
    color: #111827;
}

.blc-cookie-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.5rem 0;
}

.blc-cookie-body {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.55;
    margin: 0 0 1.5rem 0;
}

.blc-cookie-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.blc-cookie-accept {
    padding: 0.65rem 1.25rem;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.blc-cookie-accept:hover {
    background: #000000;
}

/* -------------------------------------------------------------------------
   New Conversation Overlay (inline lightbox within the chat card)
   ------------------------------------------------------------------------- */

#blc-newconv-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

.blc-newconv-dialog {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    padding: 2rem 1.75rem;
    max-width: 300px;
    width: 88%;
    text-align: center;
}

.blc-newconv-icon {
    width: 52px;
    height: 52px;
    background: #e8f0fe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.1rem;
    color: #111827;
}

.blc-newconv-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.5rem 0;
}

.blc-newconv-body {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.55;
    margin: 0 0 1.5rem 0;
}

.blc-newconv-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.blc-newconv-confirm {
    padding: 0.65rem 1.25rem;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.blc-newconv-confirm:hover:not(:disabled) {
    background: #000000;
}

.blc-newconv-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.blc-newconv-cancel {
    padding: 0.4rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s;
}

.blc-newconv-cancel:hover {
    color: #374151;
}

/* -------------------------------------------------------------------------
   End Conversation Overlay
   ------------------------------------------------------------------------- */

#blc-endconv-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

.blc-endconv-dialog {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    padding: 2rem 1.75rem;
    max-width: 300px;
    width: 88%;
    text-align: center;
}

.blc-endconv-icon {
    width: 52px;
    height: 52px;
    background: #fce8e8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.1rem;
}

.blc-endconv-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 0.5rem 0;
}

.blc-endconv-body {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.55;
    margin: 0 0 1.5rem 0;
}

.blc-endconv-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.blc-endconv-confirm {
    padding: 0.65rem 1.25rem;
    background: #d63638;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.blc-endconv-confirm:hover:not(:disabled) {
    background: #b32d2e;
}

.blc-endconv-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.blc-endconv-cancel {
    padding: 0.4rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s;
}

.blc-endconv-cancel:hover {
    color: #374151;
}

/* ── Mobile: keep the chat action bar inside the chat card ────────────────────
   The input pill and the phone/screen buttons sit in one flex row. Without
   min-width:0 the text input can't shrink below its placeholder, so the row
   overflows the card's rounded edges on narrow screens. (Desktop has room, so
   this is scoped to phones/tablets and doesn't change it.) */
@media (max-width: 781px) {
    #blc-input { min-width: 0; }
    .blc-chat-input-bar { min-width: 0; }
    [data-blc-chat] { overflow: hidden; }
}

/* Phones: stack the action-icon row above the (now full-width) input pill so
   there's room to type. The .blc-chat-actions-row is created by JS at ≤600px. */
@media (max-width: 600px) {
    .blc-chat-input-wrap {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .blc-chat-input-wrap > .blc-chat-input-bar,
    .blc-chat-actions-row {
        flex: 0 0 auto !important;
        width: 100%;
        box-sizing: border-box;
    }
    .blc-chat-actions-row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
}
