.bp-chat-message-list {
    max-height: 24rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border-radius: 1rem;
    background: var(--bs-body-bg);
}

/* Chat triggers */

.bp-chat-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Chat preview cards */

.chat-preview {
    border: 1px solid rgba(var(--bs-primary-rgb, 13, 110, 253), 0.15);
    border-radius: 0.9rem;
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb, 13, 110, 253), 0.06), transparent 80%) var(--bs-body-bg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-preview__title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--bs-secondary-color);
}

.chat-preview__list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.chat-preview__item {
    border-radius: 0.85rem;
    padding: 0.75rem;
    background: rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.6);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

html[data-theme="darkly"] .chat-preview__item {
    background: rgba(var(--bs-body-bg-rgb, 15, 23, 42), 0.88);
    border-color: rgba(var(--bs-light-rgb), 0.12);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.35);
}

html[data-theme="darkly"] .chat-preview__item:hover {
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}

.chat-preview__item:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
}

.chat-preview__item--buyer {
    border-left: 4px solid rgba(var(--bs-primary-rgb, 13, 110, 253), 0.7);
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb, 13, 110, 253), 0.12), rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.85));
}

html[data-theme="darkly"] .chat-preview__item--buyer {
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), 0.1), rgba(var(--bs-body-bg-rgb, 15, 23, 42), 0.88));
}

.chat-preview__item--seller {
    border-left: 4px solid rgba(var(--bs-success-rgb, 25, 135, 84), 0.7);
    background: linear-gradient(135deg, rgba(var(--bs-success-rgb, 25, 135, 84), 0.12), rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.85));
}

html[data-theme="darkly"] .chat-preview__item--seller {
    background: linear-gradient(135deg, rgba(var(--bs-success-rgb), 0.1), rgba(var(--bs-body-bg-rgb, 15, 23, 42), 0.88));
}

.chat-preview__item--system {
    border-left: 4px solid rgba(var(--bs-secondary-rgb, 108, 117, 125), 0.6);
    background: linear-gradient(135deg, rgba(var(--bs-secondary-rgb, 108, 117, 125), 0.12), rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.85));
}

html[data-theme="darkly"] .chat-preview__item--system {
    background: linear-gradient(135deg, rgba(var(--bs-secondary-rgb), 0.1), rgba(var(--bs-body-bg-rgb, 15, 23, 42), 0.88));
}

.chat-preview__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.chat-preview__role {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--bs-body-color);
}

.chat-preview__item--buyer .chat-preview__role {
    color: rgba(6, 70, 142, 0.9);
}

.chat-preview__item--seller .chat-preview__role {
    color: rgba(15, 81, 50, 0.9);
}

.chat-preview__item--system .chat-preview__role {
    color: rgba(71, 85, 105, 0.9);
}

.chat-preview__time {
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
    letter-spacing: 0.04em;
}

.chat-preview__message {
    margin: 0;
    font-size: 0.9rem;
    color: var(--bs-body-color);
    line-height: 1.45;
    word-break: break-word;
}

@media (max-width: 576px) {
    .chat-preview {
        padding: 0.85rem;
    }

    .chat-preview__item {
        padding: 0.65rem;
    }
}

/* Bootstrap utility classes overrides (scoped to the chat modal only). */
html[data-theme="darkly"] .bp-chat-modal .bg-body-tertiary,
html[data-theme="darkly"] .bp-chat-modal .bg-body-secondary,
html[data-theme="darkly"] .bp-chat-modal .bg-light,
html[data-theme="darkly"] .bp-chat-modal .bg-white {
    background-color: rgba(var(--bs-body-bg-rgb, 15, 23, 42), 0.92) !important;
}

/* Chat modal v2 (drawer/bottom-sheet style). Keep data-chat-* hooks unchanged; CSS is scoped to .bp-chat-modal. */

.bp-chat-modal {
    --bp-chat-border: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.14);
    --bp-chat-shadow: 0 28px 70px rgba(0, 0, 0, 0.22);
    --bp-chat-surface: var(--bs-body-bg);
    --bp-chat-surface-2: rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.84);
    --bp-chat-thread: #f4f6fb;
    --bp-chat-self: rgba(37, 99, 235, 0.18);
    --bp-chat-other: rgba(255, 255, 255, 0.95);
    --bp-chat-system: rgba(var(--bs-secondary-rgb, 108, 117, 125), 0.22);
}

html[data-theme="darkly"] .bp-chat-modal {
    --bp-chat-border: rgba(255, 255, 255, 0.14);
    --bp-chat-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
    --bp-chat-surface: rgba(var(--bs-body-bg-rgb, 15, 23, 42), 0.98);
    --bp-chat-surface-2: rgba(15, 23, 42, 0.92);
    --bp-chat-thread: #0b1220;
    --bp-chat-self: rgba(37, 99, 235, 0.45);
    --bp-chat-other: rgba(30, 41, 59, 0.92);
    --bp-chat-system: rgba(148, 163, 184, 0.22);
}

/* Centered modal on desktop */
@media (min-width: 992px) {
    .bp-chat-modal .bp-chat-dialog {
        margin: 1.75rem auto;
        width: 34rem;
        max-width: calc(100% - 2.5rem);
        height: min(74vh, 52rem);
    }

    .bp-chat-modal .modal-content {
        height: 100%;
        border-radius: 1rem;
    }
}

.bp-chat-modal .bp-chat-surface {
    background: var(--bp-chat-surface);
    border: 1px solid var(--bp-chat-border);
    box-shadow: var(--bp-chat-shadow);
    overflow: hidden;
}

.bp-chat-modal .bp-chat-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--bp-chat-border);
    background: linear-gradient(180deg, rgba(var(--bs-primary-rgb, 13, 110, 253), 0.10), transparent 65%)
        var(--bp-chat-surface);
}

.bp-chat-header__title {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
}

.bp-chat-header__icon {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.14);
    border: 1px solid rgba(var(--bs-primary-rgb, 13, 110, 253), 0.22);
}

.bp-chat-header__text {
    letter-spacing: 0.01em;
}

.bp-chat-modal .bp-chat-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bp-chat-modal .modal-dialog-scrollable .bp-chat-body {
    overflow: hidden;
}

.bp-chat-modal .bp-chat-summary {
    color: inherit;
}

.bp-chat-modal .bp-chat-summary__panel {
    border-radius: 0.9rem;
    padding: 0.75rem 0.9rem;
    background: var(--bp-chat-surface-2);
    border: 1px solid var(--bp-chat-border);
    backdrop-filter: blur(8px);
}

.bp-chat-modal .bp-chat-summary__headline {
    gap: 0.75rem;
}

.bp-chat-modal .bp-chat-summary__type {
    font-size: 0.95rem;
    font-weight: 700;
}

.bp-chat-modal .bp-chat-status,
.bp-chat-modal .bp-chat-actions.alert {
    border-radius: 0.9rem;
    border-color: var(--bp-chat-border);
    background: var(--bp-chat-surface-2);
}

.bp-chat-modal .bp-chat-actions [data-chat-action-status] {
    flex: 1;
    min-width: 0;
}

.bp-chat-modal .bp-chat-actions .bp-chat-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.bp-chat-modal .bp-chat-actions .bp-chat-action-buttons .btn {
    min-width: 110px;
    justify-content: center;
}

@media (max-width: 575.98px) {
    .bp-chat-modal .bp-chat-actions .bp-chat-action-buttons {
        width: 100%;
    }

    .bp-chat-modal .bp-chat-actions .bp-chat-action-buttons .btn {
        flex: 1 1 100%;
        min-width: 0;
    }
}

.bp-chat-modal .bp-chat-message-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    padding: 1rem;
    border-radius: 1rem;
    overflow-y: auto;
    background: var(--bp-chat-thread) !important;
    background-color: var(--bp-chat-thread) !important;
    background-image: none !important;
    border: 1px solid var(--bp-chat-border);
    box-shadow: none;
    gap: 0.65rem;
}

.bp-chat-modal .bp-chat-message {
    position: relative;
    max-width: 78%;
    padding: 0.65rem 0.8rem;
    border-radius: 1rem;
    background: var(--bp-chat-other);
    border: 1px solid var(--bp-chat-border);
    box-shadow: none;
    transition: background-color 0.15s ease;
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message {
    border-color: rgba(148, 163, 184, 0.35);
}

.bp-chat-modal .bp-chat-message:hover {
    transform: none;
    box-shadow: none;
    background: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.08);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message:hover {
    background: rgba(255, 255, 255, 0.10);
}

.bp-chat-modal .bp-chat-message__meta {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
    background: #ffffff;
    color: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(15, 23, 42, 0.2);
    opacity: 1;
}

.bp-chat-modal .bp-chat-message__content {
    display: block;
}

.bp-chat-modal .bp-chat-message__meta {
    color: rgba(15, 23, 42, 0.75);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message__meta {
    background: #0f172a;
    color: rgba(248, 250, 252, 0.95);
    border-color: rgba(148, 163, 184, 0.35);
    font-weight: 700;
}

.bp-chat-modal .bp-chat-message__content {
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

.bp-chat-modal .bp-chat-message__content {
    color: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.92);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message__content {
    color: rgba(241, 245, 249, 0.98);
}

.bp-chat-modal .bp-chat-message--self .bp-chat-message__content {
    color: rgba(15, 23, 42, 0.92);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message--self .bp-chat-message__content {
    color: #ffffff;
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message--self .bp-chat-message__meta {
    color: rgba(255, 255, 255, 0.9);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message__content {
    color: rgba(255, 255, 255, 0.92);
}

.bp-chat-modal .bp-chat-message--self {
    margin-left: auto;
    background: var(--bp-chat-self);
}

.bp-chat-modal .bp-chat-message--system {
    align-self: center;
    max-width: 100%;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: var(--bp-chat-system);
}

.bp-chat-modal .bp-chat-message--other::after,
.bp-chat-modal .bp-chat-message--self::after {
    content: "";
    position: absolute;
    bottom: 0.7rem;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
}

.bp-chat-modal .bp-chat-message--other::after {
    left: -6px;
    border-right: 7px solid var(--bp-chat-other);
}

.bp-chat-modal .bp-chat-message--self::after {
    right: -6px;
    border-left: 7px solid var(--bp-chat-self);
}

.bp-chat-modal .bp-chat-footer {
    border-top: 1px solid var(--bp-chat-border);
    background: var(--bp-chat-surface);
    padding: 0.85rem 1rem;
}

.bp-chat-modal .bp-chat-form {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
    align-items: end;
}

.bp-chat-modal .bp-chat-input {
    resize: none;
    border-radius: 1rem;
    background: var(--bp-chat-surface-2);
    border: 1px solid var(--bp-chat-border);
}

.bp-chat-modal .bp-chat-send {
    border-radius: 1rem;
    height: 2.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* Thread + bubbles (solid background) */
.bp-chat-modal .bp-chat-message-list {
    background: var(--bp-chat-thread);
    background-image: none;
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message-list {
    background: var(--bp-chat-thread);
    background-image: none;
}

.bp-chat-modal .bp-chat-message {
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.bp-chat-modal .bp-chat-message--self {
    background: var(--bp-chat-self);
    border-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.4);
}

.bp-chat-modal .bp-chat-message--other {
    background: var(--bp-chat-other);
    border-color: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.12);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message--self {
    background: var(--bp-chat-self);
    border-color: rgba(37, 99, 235, 0.65);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-message--other {
    background: var(--bp-chat-other);
    border-color: rgba(148, 163, 184, 0.35);
}

.bp-chat-modal .bp-chat-summary__meta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.12);
    color: var(--bs-body-color);
    width: fit-content;
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-summary__meta {
    background: rgba(var(--bs-primary-rgb, 55, 90, 127), 0.32);
    color: rgba(var(--bs-light-rgb), 0.9);
}

.bp-chat-modal .bp-chat-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb, 13, 110, 253), 0.2);
    border-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.45);
}

.bp-chat-modal .bp-chat-send {
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb, 13, 110, 253), 0.95), rgba(var(--bs-primary-rgb, 13, 110, 253), 0.75));
    border-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.6);
    box-shadow: 0 10px 18px rgba(13, 110, 253, 0.2);
}

html[data-theme="darkly"] .bp-chat-modal .bp-chat-send {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}
