.mbca-chat {
    --mbca-accent: #155eef;
    --mbca-accent-dark: #004eeb;
    --mbca-border: #d0d5dd;
    --mbca-muted: #667085;
    --mbca-surface: #ffffff;
    --mbca-soft: #f2f4f7;
    width: min(100%, 720px);
    margin: 1.5rem auto;
    overflow: hidden;
    border: 1px solid var(--mbca-border);
    border-radius: 18px;
    background: var(--mbca-surface);
    box-shadow: 0 16px 40px rgba(16, 24, 40, 0.12);
    color: #101828;
    font-family: inherit;
}

.mbca-chat__payment-frame {
    display: block;
    grid-column: 1 / -1;
    width: 100%;
    height: 760px;
    min-height: 760px;
    border: 1px solid var(--mbca-border);
    border-radius: 8px;
    background: #fff;
}

.mbca-chat * {
    box-sizing: border-box;
}

.mbca-chat__header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--mbca-border);
    background: #f8fafc;
}

.mbca-chat__header h2,
.mbca-chat__header p {
    margin: 0;
}

.mbca-chat__header h2 {
    color: #101828;
    font-size: 1.05rem;
    line-height: 1.35;
}

.mbca-chat__header p {
    margin-top: 0.12rem;
    color: var(--mbca-muted);
    font-size: 0.82rem;
}

.mbca-chat__status {
    width: 0.65rem;
    height: 0.65rem;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #17b26a;
    box-shadow: 0 0 0 4px #dcfae6;
}

.mbca-chat--busy .mbca-chat__status {
    background: #f79009;
    box-shadow: 0 0 0 4px #fef0c7;
}

.mbca-chat__messages {
    display: flex;
    min-height: 300px;
    max-height: 520px;
    flex-direction: column;
    gap: 0.8rem;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--mbca-surface);
    scroll-behavior: smooth;
}

.mbca-chat__message {
    width: fit-content;
    max-width: 82%;
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.mbca-chat__message--assistant {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background: var(--mbca-soft);
    color: #1d2939;
}

.mbca-chat__message--user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: var(--mbca-accent);
    color: #ffffff;
}

.mbca-chat__message--diagnostic {
    align-self: flex-start;
    border: 1px solid #b2ddff;
    background: #eff8ff;
    color: #175cd3;
    font-size: 0.82rem;
}

.mbca-chat__message--diagnostic-connected {
    border-color: #abefc6;
    background: #ecfdf3;
    color: #067647;
}

.mbca-chat__message--diagnostic-failed {
    border-color: #fecdca;
    background: #fef3f2;
    color: #b42318;
}

.mbca-chat__message--debug {
    align-self: stretch;
    width: auto;
    max-width: 100%;
    border: 1px dashed #98a2b3;
    border-radius: 8px;
    background: #f9fafb;
    color: #475467;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.76rem;
    line-height: 1.4;
}

.mbca-chat__error {
    margin: 0 1.25rem 0.8rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid #fecdca;
    border-radius: 10px;
    background: #fef3f2;
    color: #b42318;
    font-size: 0.88rem;
}

.mbca-chat__booking {
    margin: 0 1.25rem 1rem;
    padding: 1rem;
    border: 1px solid #84adff;
    border-radius: 14px;
    background: #f5f8ff;
}

.mbca-chat__booking h3,
.mbca-chat__booking p {
    margin: 0 0 0.75rem;
}

.mbca-chat__booking-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.mbca-chat__booking-form label {
    color: #344054;
    font-size: 0.82rem;
    font-weight: 600;
}

.mbca-chat__booking-form input {
    width: 100%;
    margin-top: 0.3rem;
    border: 1px solid var(--mbca-border);
    border-radius: 9px;
    padding: 0.65rem;
    background: #fff;
    color: #101828;
    font: inherit;
}

.mbca-chat__booking-form button,
.mbca-chat__auth-link {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9px;
    padding: 0.65rem 0.9rem;
    background: var(--mbca-accent);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.mbca-chat__booking-form button {
    grid-column: 1 / -1;
}

.mbca-chat-availability {
    margin: 0 1.25rem 1rem;
    padding: 1.25rem;
    border: 1px solid var(--mbca-border);
    border-radius: 16px;
    color: #101828;
    background: #fff;
}

.mbca-chat-availability h3 { margin: 0 0 1rem; font-size: 1.2rem; }
.mbca-chat-availability p { margin: 1rem 0 0; color: var(--mbca-muted); }
.mbca-chat__appointments-table-wrap { max-height: min(55vh, 500px); overflow: auto; border: 1px solid var(--mbca-border); border-radius: 10px; }
.mbca-chat__appointments-table { width: 100%; border-collapse: collapse; text-align: left; }
.mbca-chat__appointments-table th, .mbca-chat__appointments-table td { padding: 0.75rem; border-bottom: 1px solid var(--mbca-border); vertical-align: middle; }
.mbca-chat__appointments-table th { position: sticky; top: 0; background: #f8fafc; color: #344054; font-size: 0.8rem; }
.mbca-chat__appointments-table tr:last-child td { border-bottom: 0; }
.mbca-chat__appointments-table button { border: 0; border-radius: 8px; padding: 0.5rem 0.75rem; background: var(--mbca-accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }

.mbca-chat__payment {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0 1.25rem 1rem;
    padding: 1rem;
    border: 1px solid #84adff;
    border-radius: 14px;
    background: #f5f8ff;
}

.mbca-chat__payment h3, .mbca-chat__payment p, .mbca-chat__payment button { grid-column: 1 / -1; margin: 0; }
.mbca-chat__payment label { color: #344054; font-size: 0.82rem; font-weight: 600; }
.mbca-chat__payment input { width: 100%; margin-top: 0.3rem; border: 1px solid var(--mbca-border); border-radius: 9px; padding: 0.65rem; font: inherit; }
.mbca-chat__payment button { min-height: 42px; border: 0; border-radius: 9px; background: var(--mbca-accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }

.mbca-chat__auth-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mbca-chat__auth-link--google {
    background: #fff;
    color: #344054;
    border: 1px solid var(--mbca-border);
}

.mbca-chat__auth-link--microsoft {
    background: #2f2f2f;
}

.mbca-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--mbca-border);
    background: #ffffff;
}

.mbca-chat__input {
    min-height: 46px;
    max-height: 140px;
    flex: 1;
    resize: vertical;
    border: 1px solid var(--mbca-border);
    border-radius: 12px;
    padding: 0.7rem 0.8rem;
    background: #ffffff;
    color: #101828;
    font: inherit;
    line-height: 1.4;
}

.mbca-chat__input:focus {
    border-color: var(--mbca-accent);
    outline: 3px solid rgba(21, 94, 239, 0.14);
}

.mbca-chat__send {
    min-height: 46px;
    border: 0;
    border-radius: 12px;
    padding: 0.7rem 1.1rem;
    background: var(--mbca-accent);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.mbca-chat__send:hover:not(:disabled) {
    background: var(--mbca-accent-dark);
}

.mbca-chat__send:focus-visible {
    outline: 3px solid rgba(21, 94, 239, 0.25);
    outline-offset: 2px;
}

.mbca-chat__send:disabled,
.mbca-chat__input:disabled {
    cursor: wait;
    opacity: 0.68;
}

.mbca-chat__notice {
    margin: 0;
    padding: 0 1.25rem 1rem;
    color: var(--mbca-muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

@media (max-width: 540px) {
    .mbca-chat {
        border-radius: 12px;
    }

    .mbca-chat__messages {
        min-height: 360px;
        padding: 1rem;
    }

    .mbca-chat__message {
        max-width: 90%;
    }

    .mbca-chat__form {
        align-items: stretch;
        flex-direction: column;
        padding: 0.9rem 1rem;
    }

    .mbca-chat__booking-form {
        grid-template-columns: 1fr;
    }

    .mbca-chat__payment-frame {
        height: 680px;
        min-height: 680px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mbca-chat__messages {
        scroll-behavior: auto;
    }
}
