/*
 * Website chatbot.
 *
 * Two constraints drove the layout:
 *
 *  - The site scores 100/100 on Lighthouse accessibility and has to stay there.
 *    Every control is at least 24x24 CSS px, focus is always visible, and the
 *    panel is a labelled dialog.
 *  - The WhatsApp widget already occupies the bottom-right corner, so the
 *    launcher sits above it rather than on top of it.
 */

.rmb-chat-launcher {
    position: fixed;
    /* Side and height come from the admin screen. The page sets one of
       --rmb-chat-right / --rmb-chat-left to a length and the other to auto. */
    right: var(--rmb-chat-right, 20px);
    left: var(--rmb-chat-left, auto);
    bottom: var(--rmb-chat-bottom, 96px);
    z-index: 2147483000;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 18px;
    border: 0;
    border-radius: 28px;
    background: #f38866;
    color: #111;
    font-family: sans-serif;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
    cursor: pointer;
}

.rmb-chat-launcher:hover {
    background: #111;
    color: #fff;
}

.rmb-chat-launcher:focus-visible,
.rmb-chat-panel :focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

.rmb-chat-launcher[hidden] {
    display: none;
}

/* ---------------------------------------------------------------- the panel */

.rmb-chat-panel {
    position: fixed;
    right: var(--rmb-chat-right, 20px);
    left: var(--rmb-chat-left, auto);
    bottom: 20px;
    /* Above the WhatsApp button, which used to cover the panel's own buttons. */
    z-index: 2147483001;
    display: flex;
    flex-direction: column;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 40px);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
    font-family: sans-serif;
    overflow: hidden;
}

.rmb-chat-panel[hidden] {
    display: none;
}

.rmb-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: #111;
    color: #fff;
}

.rmb-chat-head h2 {
    margin: 0;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.rmb-chat-head p {
    margin: 2px 0 0;
    color: #cbd5e1;
    font-size: 12px;
    text-align: left;
    line-height: 1.4;
}

.rmb-chat-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rmb-chat-restart,
.rmb-chat-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.rmb-chat-restart:hover,
.rmb-chat-close:hover {
    background: rgba(255, 255, 255, .3);
}

.rmb-chat-restart span {
    display: block;
    font-size: 17px;
    line-height: 1;
}

/* Set apart from the quick replies: it ends a conversation rather than
   answering a question. */
.rmb-restart {
    border-color: #94a3b8;
    color: #475569;
}

.rmb-restart:hover {
    background: #475569;
    color: #fff;
}

/* --------------------------------------------------------------- the thread */

.rmb-chat-log {
    flex: 1 1 0;
    min-height: 72px;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
}

.rmb-msg {
    max-width: 88%;
    margin-bottom: 10px;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
}

.rmb-msg-bot {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    color: #1e293b;
}

.rmb-msg-user {
    margin-left: auto;
    background: #f38866;
    border-bottom-right-radius: 4px;
    color: #111;
    font-weight: 500;
}

.rmb-typing {
    display: inline-block;
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
}

/* Property cards: the part that does the selling. */
.rmb-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.rmb-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #1e293b;
    text-decoration: none;
}

.rmb-card:hover {
    border-color: #f38866;
    color: #1e293b;
}

.rmb-card img {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
}

.rmb-card-body strong {
    display: block;
    font-size: 13px;
    line-height: 1.3;
}

.rmb-card-body span {
    font-size: 12px;
    color: #64748b;
}

/* ------------------------------------------------------------ the responses */

/* Scrolls rather than being cut off, so the submit button can always be reached
   on a short screen. */
.rmb-chat-foot {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.rmb-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.rmb-replies:empty {
    margin-bottom: 0;
}

.rmb-reply {
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid #f38866;
    border-radius: 18px;
    background: #fff;
    color: #111;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.rmb-reply:hover {
    background: #f38866;
}

.rmb-ask {
    display: flex;
    gap: 8px;
}

.rmb-ask input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 14px;
}

.rmb-send {
    flex: 0 0 auto;
    min-width: 40px;
    min-height: 40px;
    border: 0;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

.rmb-send:hover {
    background: #f38866;
    color: #111;
}

/* ---------------------------------------------------------------- the form */

.rmb-form label {
    display: block;
    margin-bottom: 2px;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
}

.rmb-form select {
    background: #fff;
    color: #111;
}

.rmb-form input,
.rmb-form select {
    width: 100%;
    min-height: 40px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
}

.rmb-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
    color: #475569;
    font-size: 11px;
    line-height: 1.45;
}

.rmb-consent input {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin: 0;
}

.rmb-submit {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: #f38866;
    color: #111;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.rmb-submit:hover {
    background: #111;
    color: #fff;
}

.rmb-submit[disabled] {
    opacity: .6;
    cursor: default;
}

.rmb-error {
    margin: 0 0 8px;
    color: #dc2626;
    font-size: 12px;
    text-align: left;
}

/* Room for the longest contact form with the last message still in view. */
@media (min-width: 481px) {
    .rmb-chat-panel:has(.rmb-form) {
        height: 700px;
    }
}

@media (max-width: 480px) {
    /* Full width on a phone, so the chosen side stops mattering. */
    .rmb-chat-panel {
        right: 8px;
        left: 8px;
        bottom: 8px;
        width: auto;
        max-width: none;
        height: calc(100vh - 80px);
    }
}

/* The floating WhatsApp button, ours rather than the third party's. */
.rmb-wa-float {
    position: fixed;
    bottom: var(--rmb-wa-bottom, 20px);
    right: var(--rmb-wa-right, 20px);
    left: var(--rmb-wa-left, auto);
    z-index: 2147482999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
    text-decoration: none;
}

.rmb-launcher-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.rmb-wa-float img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.rmb-wa-float:hover,
.rmb-wa-float:focus {
    background: #1da851;
    color: #fff;
}

.rmb-wa-float:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* ------------------------------------------------------ selectable cards */

.rmb-card-pick {
    cursor: pointer;
    user-select: none;
}

.rmb-card-pick.is-picked {
    border-color: #f38866;
    background: #fff7f4;
}

.rmb-card-box {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin: 0;
    accent-color: #f38866;
}

.rmb-card-link {
    color: inherit;
    text-decoration: none;
}

.rmb-card-link:hover {
    text-decoration: underline;
}
