:root {
    --chat-primary: #143d66;
    --chat-accent: #f47b20;
    --chat-border: #e4e9ef;
    --chat-muted: #718096;
    --chat-surface: #ffffff;
    --chat-sidebar: #f6f8fb;
}

.chat-page-shell {
    max-width: 1380px;
    height: calc(100vh - 150px);
    min-height: 320px;
    margin: 24px auto;
    padding: 0 20px;
}

.chat-page-shell--admin {
    height: calc(100vh - 145px);
    min-height: 320px;
    margin: 0;
    padding: 0;
}

.chat-app {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    border-radius: 18px;
    background: var(--chat-surface);
    box-shadow: 0 18px 55px rgba(17, 38, 63, .12);
    color: #17324d;
}

.chat-sidebar {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    border-right: 1px solid var(--chat-border);
    background: var(--chat-sidebar);
}

.chat-sidebar__header,
.chat-thread__header {
    display: flex;
    align-items: center;
    min-height: 76px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--chat-border);
    background: #fff;
}

.chat-sidebar__header {
    justify-content: space-between;
}

.chat-sidebar h2,
.chat-thread__header h3 {
    margin: 0;
    color: #17324d;
    font-size: 18px;
    font-weight: 700;
}

.chat-sidebar p,
.chat-thread__header p {
    margin: 3px 0 0;
    color: var(--chat-muted);
    font-size: 12px;
}

.chat-expand,
.chat-close,
.chat-back {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: #eef3f7;
    color: var(--chat-primary);
}

.chat-search {
    position: relative;
    display: block;
    margin: 14px;
}

.chat-search i {
    position: absolute;
    top: 50%;
    left: 13px;
    color: #9aa7b5;
    transform: translateY(-50%);
}

.chat-search input {
    width: 100%;
    height: 42px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    outline: 0;
    background: #fff;
}

.chat-search input:focus,
.chat-composer textarea:focus {
    border-color: #769bbd;
    box-shadow: 0 0 0 3px rgba(20, 61, 102, .09);
}

.chat-conversation-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 10px 12px;
}

.chat-conversation {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    width: 100%;
    gap: 11px;
    align-items: center;
    margin-bottom: 7px;
    padding: 11px;
    border: 1px solid transparent;
    border-radius: 13px;
    background: transparent;
    color: inherit;
    text-align: left;
}

.chat-conversation:hover,
.chat-conversation.is-active {
    border-color: var(--chat-border);
    background: #fff;
    box-shadow: 0 7px 20px rgba(29, 55, 82, .07);
}

.chat-avatar {
    display: inline-flex;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--chat-primary), #28899b);
    color: #fff;
    font-weight: 700;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-conversation__body {
    min-width: 0;
}

.chat-conversation__body strong,
.chat-conversation__body span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-conversation__body strong {
    font-size: 14px;
}

.chat-conversation__body span {
    margin-top: 4px;
    color: var(--chat-muted);
    font-size: 12px;
}

.chat-unread {
    min-width: 20px;
    padding: 3px 6px;
    border-radius: 20px;
    background: var(--chat-accent);
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.chat-thread {
    position: relative;
    min-width: 0;
    min-height: 0;
    background: #fff;
}

.chat-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 30px;
    color: var(--chat-muted);
    text-align: center;
}

.chat-empty i {
    margin-bottom: 16px;
    color: #b6c3cf;
    font-size: 52px;
}

.chat-empty h3 {
    margin: 0 0 7px;
    color: #294660;
}

.chat-thread__content {
    display: flex;
    height: 100%;
    min-height: 0;
    flex-direction: column;
}

.chat-thread__header {
    gap: 12px;
}

.chat-thread__header > div {
    min-width: 0;
    flex: 1;
}

.chat-close {
    margin-left: auto;
}

.chat-back {
    display: none;
}

.chat-messages {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 22px;
    background: linear-gradient(180deg, #fbfcfd, #f4f7fa);
}

.chat-message {
    display: flex;
}

.chat-message.is-mine {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: min(72%, 620px);
    padding: 11px 14px;
    border: 1px solid var(--chat-border);
    border-radius: 5px 17px 17px;
    background: #fff;
    box-shadow: 0 5px 15px rgba(25, 50, 76, .05);
}

.chat-message.is-mine .chat-bubble {
    border: 0;
    border-radius: 17px 5px 17px 17px;
    background: linear-gradient(135deg, var(--chat-primary), #257a8c);
    color: #fff;
}

.chat-message.is-mine .chat-bubble p,
.chat-message.is-mine .chat-bubble time,
.chat-message.is-mine .chat-product-card {
    color: #fff !important;
}

.chat-message:not(.is-mine) .chat-bubble p,
.chat-message:not(.is-mine) .chat-bubble time,
.chat-message:not(.is-mine) .chat-product-card {
    color: #172b3f !important;
}

.chat-bubble p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color:white
}

.chat-bubble time {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    opacity: .68;
}

.chat-bubble__image {
    display: block;
    max-width: 280px;
    max-height: 260px;
    margin-bottom: 8px;
    border-radius: 10px;
    object-fit: cover;
}

.chat-product-card {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 9px;
    padding: 8px;
    border-radius: 9px;
    background: rgba(125, 143, 160, .13);
    color: inherit;
}

.chat-product-card img {
    width: 42px;
    height: 42px;
    border-radius: 7px;
    object-fit: cover;
}

.chat-composer {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 13px 16px;
    border-top: 1px solid var(--chat-border);
    background: #fff;
}

.chat-composer__field {
    min-width: 0;
    flex: 1;
}

.chat-composer textarea {
    display: block;
    width: 100%;
    max-height: 120px;
    padding: 10px 12px;
    resize: none;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    outline: 0;
    line-height: 1.45;
    overflow-y: auto;
}

.chat-composer small {
    display: block;
    overflow: hidden;
    margin-top: 3px;
    color: var(--chat-muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attach,
.chat-send {
    display: inline-flex;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.chat-attach {
    background: #eef2f6;
    color: var(--chat-primary);
}

.chat-attach input {
    display: none;
}

.chat-send {
    background: var(--chat-accent);
    color: #fff;
}

.chat-loading,
.chat-list-empty,
.chat-error {
    padding: 28px 16px;
    color: var(--chat-muted);
    text-align: center;
}

.chat-error {
    color: #b42318;
}

.chat-app--compact {
    grid-template-columns: 275px minmax(0, 1fr);
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.chat-app--compact .chat-sidebar__header,
.chat-app--compact .chat-thread__header {
    min-height: 64px;
}

@media (max-width: 767px) {
    .chat-page-shell,
    .chat-page-shell--admin {
        width: 100%;
        height: calc(100dvh - 60px);
        min-height: 0;
        margin: 0;
        padding: 0;
    }

    .chat-app,
    .chat-app--compact {
        position: relative;
        display: block;
        border: 0;
        border-radius: 0;
    }

    .chat-sidebar,
    .chat-thread {
        position: absolute;
        inset: 0;
    }

    .chat-thread {
        z-index: 2;
        display: none;
    }

    .chat-app.has-active-thread .chat-sidebar {
        display: none;
    }

    .chat-app.has-active-thread .chat-thread {
        display: block;
    }

    .chat-back {
        display: inline-flex;
    }

    .chat-bubble {
        max-width: 88%;
    }

    .chat-messages {
        padding: 15px 12px;
    }
}
