/* The message bar (js/messagebar.js): chat windows docked at the bottom right, desktop only.
   Cards in the site's colours (dark #1b1e24 / light white), Groupup red for you, Quicksand. */

.mb-dock {
    --mb-bg: #ffffff;
    --mb-raise: #f3f4f6;
    --mb-line: rgba(0, 0, 0, 0.08);
    --mb-text: #1f2329;
    --mb-weak: #6b7280;
    --mb-theirs: #eef0f3;
    --mb-accent: #eb6864;
    --mb-accent-ink: #ffffff;
    position: fixed;
    right: 16px;
    bottom: 0;
    z-index: 35; /* over pages, under modals (40) and the call overlay (60) */
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none; /* only the bar and windows take clicks */
    font-family: "Quicksand", sans-serif;
    color: var(--mb-text);
}

.theme-dark .mb-dock {
    --mb-bg: #1b1e24;
    --mb-raise: #23272f;
    --mb-line: rgba(255, 255, 255, 0.07);
    --mb-text: #e6e8ec;
    --mb-weak: #9aa1ad;
    --mb-theirs: #2a2f38;
}

.mb-list,
.mb-win {
    pointer-events: auto;
    background: var(--mb-bg);
    border: 1px solid var(--mb-line);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -2px 24px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

/* --- the bar and the conversation list ----------------------------------------------------- */
.mb-list { width: 300px; }

.mb-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 0;
    background: linear-gradient(90deg, rgba(235, 104, 100, 0.16), rgba(235, 104, 100, 0.04));
    color: inherit;
    font: inherit;
    font-weight: 700;
}

/* The bar: the part that opens the list, then the gear and the chevron. */
.mb-bar { padding: 0 6px 0 0; gap: 2px; }
.mb-bar-open {
    flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 14px;
    border: 0; background: none; color: inherit; font: inherit; font-weight: 700; cursor: pointer;
}
.mb-bar-open > .material-symbols-outlined:first-child { color: var(--mb-accent); }
.mb-bar-btn {
    flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: 0.7;
}
.mb-bar-btn .material-symbols-outlined { font-size: 20px; }
.mb-bar-btn:hover, .mb-bar-btn.is-on { opacity: 1; background: var(--mb-raise); }
.mb-bar-btn.is-on { color: var(--mb-accent); }
.mb-list-main { display: flex; flex-direction: column; flex: 1 0 auto; }
.mb-foot { margin-top: auto; border-top: 1px solid var(--mb-line); border-radius: 0 0 10px 10px; }

/* Under each thread: one fixed-height line for "Seen" or "… is typing" (never moves the thread). */
.mb-status {
    height: 18px; margin: 0; padding: 0 12px; display: flex; align-items: center; justify-content: flex-end; gap: 4px;
    font-size: 11px; line-height: 18px; color: var(--mb-weak); white-space: nowrap; overflow: hidden;
}
.mb-status.is-typing { justify-content: flex-start; color: var(--mb-accent); }
.mb-bar-title { flex: 1; min-width: 0; text-align: left; font-size: 15px; }
.mb-chevron { opacity: 0.6; }
.mb-bar:hover .mb-chevron { opacity: 1; }

.mb-list-body {
    display: flex;
    flex-direction: column;
    height: min(440px, calc(100vh - 140px));
    overflow-y: auto;
    padding: 6px;
    border-top: 1px solid var(--mb-line);
    scrollbar-width: thin;
}

.mb-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--mb-weak);
}

.mb-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s;
}

.mb-row:hover { background: var(--mb-raise); }

.mb-row-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mb-row-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}

.mb-row-top strong {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
}

.mb-row-top small { flex: none; font-size: 11px; color: var(--mb-weak); }

.mb-row-preview {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12.5px;
    color: var(--mb-weak);
}

.mb-row.is-unread .mb-row-preview { color: var(--mb-text); font-weight: 700; }
.mb-muted { font-size: 16px; color: var(--mb-weak); }

.mb-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: auto;
    padding: 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--mb-accent);
}

.mb-all .material-symbols-outlined { font-size: 16px; }
.mb-all:hover { background: rgba(235, 104, 100, 0.1); color: var(--mb-accent); }

/* --- shared bits ------------------------------------------------------------------------------ */
.mb-avatar {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--mb-raise);
}

.mb-avatar.is-small { width: 32px; height: 32px; }
.mb-avatar.is-tiny { width: 24px; height: 24px; }
.mb-avatar.is-large { width: 64px; height: 64px; box-shadow: 0 0 0 3px var(--mb-accent); }

.mb-badge {
    flex: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--mb-accent);
    color: var(--mb-accent-ink);
    font-size: 11px;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
}

/* --- a conversation window ------------------------------------------------------------------ */
.mb-win {
    width: 328px;
    display: flex;
    flex-direction: column;
}

.mb-win.is-min { width: 240px; }

.mb-win.is-pulse { animation: mb-pulse 1.2s ease-out; }

@keyframes mb-pulse {
    0% { box-shadow: 0 0 0 0 rgba(235, 104, 100, 0.7), 0 -2px 24px rgba(0, 0, 0, 0.28); transform: translateY(0); }
    20% { transform: translateY(-6px); }
    40% { transform: translateY(0); }
    100% { box-shadow: 0 0 0 14px rgba(235, 104, 100, 0), 0 -2px 24px rgba(0, 0, 0, 0.28); }
}

.mb-head {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 50px;
    padding: 0 6px 0 10px;
    border-bottom: 1px solid var(--mb-line);
    cursor: pointer;
}

.mb-win.is-min .mb-head { border-bottom: 0; height: 46px; }

.mb-who {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
}


.mb-who-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.mb-who-text strong {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
    color: inherit;
    transition: color 0.15s;
}

/* The @handle (open windows only) is the way to their profile. */
.mb-handle {
    align-self: flex-start;
    font-size: 11px;
    color: var(--mb-weak);
}

.mb-handle:hover { color: var(--mb-accent); text-decoration: underline; }
.mb-win.is-min .mb-handle { display: none; }

.mb-head-btns {
    display: flex;
    align-items: center;
    flex: none;
}

.mb-head-btns button,
.mb-head-btns a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--mb-accent);
    cursor: pointer;
    transition: background-color 0.15s;
}

.mb-head-btns .material-symbols-outlined { font-size: 19px; }
.mb-head-btns button:hover,
.mb-head-btns a:hover { background: rgba(235, 104, 100, 0.14); }

.mb-body {
    position: relative;
    display: flex;
    flex-direction: column;
    height: min(400px, calc(100vh - 160px));
}

.mb-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 10px 4px;
    scrollbar-width: thin;
}

.mb-start {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 10px;
    text-align: center;
    font-size: 13px;
    color: var(--mb-weak);
}

.mb-start strong { font-size: 15px; color: var(--mb-text); }

.mb-msg {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-top: 8px;
    padding-left: 30px; /* room for their photo */
}

.mb-msg > .mb-avatar, .mb-msg > .mb-msg-avatar { margin-left: -30px; }
.mb-msg.is-grouped { margin-top: 2px; }
.mb-msg.is-mine { justify-content: flex-end; padding-left: 0; }

.mb-bubble {
    max-width: 78%;
    padding: 7px 11px;
    border-radius: 16px;
    background: var(--mb-theirs);
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.mb-text { white-space: pre-wrap; } /* line breaks in what they wrote, not the template's */

.mb-msg:not(.is-mine) .mb-bubble { border-bottom-left-radius: 5px; }
.mb-msg.is-mine .mb-bubble {
    border-bottom-right-radius: 5px;
    background: var(--mb-accent);
    color: var(--mb-accent-ink);
}

.mb-bubble.is-deleted { font-style: italic; opacity: 0.6; }
.mb-bubble.is-call .material-symbols-outlined { font-size: 16px; vertical-align: -3px; }

.mb-jump {
    position: absolute;
    right: 12px;
    bottom: 82px; /* above the status line and the message box */
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: var(--mb-bg);
    color: var(--mb-accent);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.mb-error {
    padding: 2px 12px;
    font-size: 12px;
    color: #e5484d;
}

.mb-compose {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 8px 10px;
    border-top: 1px solid var(--mb-line);
}

.mb-compose textarea {
    flex: 1;
    min-height: 36px;
    max-height: 110px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 18px;
    background: var(--mb-raise);
    color: inherit;
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
}

.mb-compose textarea:focus { border-color: rgba(235, 104, 100, 0.6); }
.mb-compose textarea::placeholder { color: var(--mb-weak); }

.mb-compose button {
    flex: none;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--mb-accent);
    color: var(--mb-accent-ink);
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}

.mb-compose button:hover:not(:disabled) { transform: scale(1.08); }
.mb-compose button:disabled { opacity: 0.35; cursor: default; }
.mb-compose button .material-symbols-outlined { font-size: 19px; }

/* Desktop only: phones and tablets use the Messages page. */
@media (max-width: 1023px) {
    .mb-dock { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .mb-win.is-pulse { animation: none; }
}

/* The header (name included) opens and minimizes the window; it never links away. */
.mb-head:hover { background: rgba(127, 127, 127, 0.06); }

/* Your own messages: edit and delete appear beside the bubble on hover. */
.mb-msg-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    align-self: center;
    opacity: 0;
    transition: opacity 0.12s;
}

.mb-msg:hover .mb-msg-tools,
.mb-msg-tools:focus-within { opacity: 1; }

.mb-msg-tools button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: var(--mb-raise);
    color: var(--mb-weak);
    cursor: pointer;
}

.mb-msg-tools .material-symbols-outlined { font-size: 16px; }
.mb-msg-tools button:hover { color: var(--mb-accent); }
.mb-msg-tools button[title="Delete"]:hover { color: #e5484d; }

.mb-edited {
    display: block;
    margin-top: 1px;
    font-size: 10.5px;
    opacity: 0.65;
    text-align: right;
}

.mb-edit {
    width: 82%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mb-edit textarea {
    width: 100%;
    padding: 7px 11px;
    border: 1px solid rgba(235, 104, 100, 0.6);
    border-radius: 14px;
    background: var(--mb-raise);
    color: inherit;
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
    resize: none;
    outline: none;
}

.mb-edit-btns {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.mb-edit-btns button {
    padding: 2px 10px;
    border: 0;
    border-radius: 999px;
    background: var(--mb-raise);
    color: inherit;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.mb-edit-btns .is-save { background: var(--mb-accent); color: var(--mb-accent-ink); }
.mb-edit-btns .is-save:disabled { opacity: 0.4; }

/* Who's online (the shared dot and switch styles are in messages.css). */
.mb-dock { --presence-ring: var(--mb-bg); }
.mb-online { padding: 4px 6px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--mb-line); flex: none; }
.mb-online-label { display: block; padding: 0 2px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--mb-weak); }
.mb-online .online-strip { height: 66px; }
.mb-online-person {
    position: absolute; top: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 52px; padding: 4px 2px;
    border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: 11px; cursor: pointer;
}
.mb-online-person:hover { background: var(--mb-raise); }
.mb-online-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-conversations > .mb-row { height: 57px; }
.mb-conversations .mb-row-top strong, .mb-conversations .mb-row-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
