.usp-chat-container {
    display: flex;
    border: 1px solid #e0e0e0;
    height: 600px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.usp-chat-sidebar {
    width: 30%;
    max-width: 300px;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background-color: #f9f9f9;
}

.usp-chat-sidebar-header,
.usp-chat-main-header {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f6f7f7;
}

.usp-chat-sidebar-header h3,
.usp-chat-main-header h3 {
    margin: 0;
    font-size: 16px;
}

.usp-chat-list {
    flex-grow: 1;
    overflow-y: auto;
}

/* Custom Scrollbar */
.usp-chat-list::-webkit-scrollbar,
.usp-chat-messages-window::-webkit-scrollbar {
    width: 6px;
}
.usp-chat-list::-webkit-scrollbar-thumb,
.usp-chat-messages-window::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

.usp-chat-list-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px; /* Уменьшаем размер шрифта */
    font-weight: 500; /* Делаем шрифт чуть жирнее для читаемости */
    position: relative; /* Для позиционирования значка уведомлений */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.usp-chat-list-item.active, .usp-chat-list-item:hover {
    background-color: #e9e9eb;
}

.usp-chat-notification-badge {
    background-color: #0b93f6;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.usp-chat-list-item.active {
    font-weight: 600;
}

.usp-chat-list-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.usp-chat-contact-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ccc; /* Offline by default */
}

.usp-chat-contact-status--online {
    background-color: #28a745; /* Green for online */
}

.usp-chat-contact-status--away {
    background-color: #f0a020; /* Orange for away */
}

.usp-chat-list p {
    padding: 15px;
    color: #666;
}

.usp-chat-participants-sidebar {
    display: none;
    width: 30%;
    max-width: 300px;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    background-color: #f9f9f9;
}

.usp-chat-participants-list {
    flex-grow: 1;
    overflow-y: auto;
}

.usp-chat-participants-list > p {
    padding: 15px;
    color: #666;
}

.usp-chat-participant {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.usp-chat-participant-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #0b93f6;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.usp-chat-participant-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.usp-chat-participant-name-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.usp-chat-participant-name-line .usp-chat-contact-status {
    flex: 0 0 auto;
}

.usp-chat-participant-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: #1d2327;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usp-chat-participant-me {
    flex: 0 0 auto;
    color: #666;
    font-size: 11px;
    font-weight: 400;
}

.usp-chat-participant-role {
    margin-top: 2px;
    color: #0b93f6;
    font-size: 11px;
}

.usp-chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.usp-chat-messages-window {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}

.usp-chat-message-form-container {
    padding: 12px 15px;
    border-top: 1px solid #e0e0e0;
    background-color: #f6f7f7;
}

.usp-chat-message-form {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.usp-chat-message-input {
    width: 100%;
    resize: none;
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: 20px;
    margin-right: 10px;
    background-color: #eef1f4;
    font-size: 14px;
    line-height: 1.4;
    transition: background-color 0.2s, border-color 0.2s;
    font-family: inherit; /* Наследуем шрифт */
}

.usp-chat-message-input:focus {
    outline: none;
    background-color: #fff;
    border-color: #0b93f6;
}

.usp-chat-message-form button {
    margin-top: 10px;
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background-color: #0b93f6;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    font-weight: 600;
}

.usp-chat-message-form button:disabled,
.usp-chat-message-input:disabled {
    background-color: #f0f0f0;
    cursor: not-allowed;
}

.usp-chat-message-form button:hover:not(:disabled) {
    background-color: #0078d4;
}

.usp-chat-message {
    max-width: 85%;
    padding: 10px 14px;
    min-width: 300px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    font-size: 14px;
}

/* Сообщение собеседника (по умолчанию) */
.usp-chat-message--received {
    background-color: #e5e5ea;
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Сообщение текущего пользователя */
.usp-chat-message--sent {
    background-color: #0b93f6;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.usp-chat-message-sender {
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 0.9em;
}

.usp-chat-message--sent .usp-chat-message-sender {
    display: none; /* Скрываем свое имя */
}

/* Скрываем имя отправителя, если сообщения сгруппированы */
.usp-chat-message--grouped .usp-chat-message-sender {
    display: none;
}

.usp-chat-message--system {
    align-self: center;
    max-width: 100%;
    min-width: 0;
    padding: 2px 0;
    background: transparent;
    box-shadow: none;
    text-align: center;
}

.usp-chat-message--system .usp-chat-message-system-content {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f0f0f1;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
}

.usp-chat-message--system .usp-chat-message-time {
    text-align: center;
    color: #aaa;
}

.usp-chat-message-time {
    font-size: 11px;
    margin-top: 4px;
    text-align: right;
    color: #8c8c8c;
}

.usp-chat-message--sent .usp-chat-message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Тематический чат: вместо списка чатов — участники */
.usp-chat-container--topic .usp-chat-sidebar {
    display: none;
}

.usp-chat-container--topic .usp-chat-participants-sidebar {
    display: flex;
}

.usp-chat-container--topic .usp-chat-main {
    width: auto;
    min-width: 0;
    flex-grow: 1;
}

@media (max-width: 720px) {
    .usp-chat-container--topic {
        flex-direction: column;
        height: auto;
        min-height: 600px;
    }

    .usp-chat-container--topic .usp-chat-participants-sidebar {
        width: 100%;
        max-width: none;
        max-height: 220px;
        border-right: 0;
        border-bottom: 1px solid #e0e0e0;
    }

    .usp-chat-container--topic .usp-chat-main {
        min-height: 480px;
    }
}
/* Вложения и модерация чата */
.usp-chat-message-form {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.usp-chat-message-input {
    flex: 1 1 auto;
    min-width: 0;
    margin-right: 0;
}

.usp-chat-message-form .usp-chat-attach-button {
    flex: 0 0 auto;
    margin-top: 0;
    padding: 8px 12px;
    background-color: #e9edf2;
    color: #1d2327;
}

.usp-chat-message-form .usp-chat-attach-button:hover:not(:disabled) {
    background-color: #dde3ea;
}

.usp-chat-message-form .usp-chat-send-button {
    flex: 0 0 auto;
    margin-top: 0;
    margin-left: 0;
}

.usp-chat-pending-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.usp-chat-attachment {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 220px;
    border: 1px solid #dcdcde;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.usp-chat-attachment img {
    display: block;
    max-width: 200px;
    max-height: 140px;
    object-fit: cover;
}

.usp-chat-attachment--image {
    width: fit-content;
    max-width: min(300px, 100%);
}

.usp-chat-attachment--image img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.usp-chat-attachment--pending.usp-chat-attachment--image {
    max-width: min(150px, 100%);
}

.usp-chat-attachment--pending.usp-chat-attachment--image img {
    max-height: 150px;
}

.usp-chat-attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: #1d2327;
    font-size: 12px;
    text-decoration: none;
    word-break: break-word;
}

.usp-chat-attachment-file-icon {
    display: inline-flex;
    flex: 0 0 auto;
}

.usp-chat-attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usp-chat-message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.usp-chat-message-attachments + .usp-chat-message-content {
    margin-top: 8px;
}

.usp-chat-message--sent .usp-chat-attachment {
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.12);
}

.usp-chat-message--sent .usp-chat-attachment-file {
    color: #fff;
}

.usp-chat-attachment-delete,
.usp-chat-pending-attachment-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(29, 35, 39, 0.72);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.usp-chat-message-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(29, 35, 39, 0.45);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.usp-chat-message {
    position: relative;
}

.usp-chat-message:hover .usp-chat-message-delete,
.usp-chat-message-delete:focus-visible {
    opacity: 1;
}

.usp-chat-message--sent .usp-chat-message-delete {
    background: rgba(0, 0, 0, 0.28);
}

.usp-chat-attachment-status {
    min-height: 16px;
    margin-top: 6px;
    color: #555;
    font-size: 12px;
}

.usp-chat-attachment-status.is-error {
    color: #b32d2e;
}

.usp-chat-participant {
    position: relative;
}

.usp-chat-participant.is-blocked {
    opacity: 0.6;
}

.usp-chat-participant-blocked-label {
    flex: 0 0 auto;
    color: #b32d2e;
    font-size: 11px;
}

.usp-chat-participant-block {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 2px 7px;
    border: 1px solid #dcdcde;
    border-radius: 999px;
    background: #fff;
    color: #b32d2e;
    font-size: 13px;
    line-height: 1.3;
    cursor: pointer;
}

.usp-chat-participant-block.is-blocked {
    border-color: #68a46b;
    color: #2f6b4f;
}

@media (max-width: 720px) {
    .usp-chat-message-delete {
        opacity: 1;
    }
}

/* Реакции на сообщения */
.usp-chat-reactions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

.usp-chat-reaction-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.usp-chat-reaction-chip,
.usp-chat-reaction-add,
.usp-chat-reaction-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dcdcde;
    background: #fff;
    color: #1d2327;
    cursor: pointer;
}

.usp-chat-reaction-chip {
    gap: 4px;
    min-height: 26px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 13px;
    line-height: 1;
}

.usp-chat-reaction-chip.is-active {
    border-color: #0b93f6;
    background: #e7f2ff;
}

.usp-chat-reaction-count {
    font-size: 11px;
    font-weight: 700;
}

.usp-chat-reaction-add {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    opacity: 0.65;
}

.usp-chat-reaction-add:hover,
.usp-chat-reaction-chip:hover {
    opacity: 1;
}

.usp-chat-reaction-picker {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    z-index: 5;
    display: flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid #dcdcde;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(29, 35, 39, 0.16);
}

.usp-chat-reaction-picker[hidden] {
    display: none;
}

.usp-chat-message--sent .usp-chat-reaction-picker {
    right: 0;
    left: auto;
}

.usp-chat-reaction-option {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    line-height: 1;
}

.usp-chat-reaction-option:hover {
    background: #f0f0f1;
}

.usp-chat-message--sent .usp-chat-reaction-chip,
.usp-chat-message--sent .usp-chat-reaction-add {
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.usp-chat-message--sent .usp-chat-reaction-chip.is-active {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.32);
}

.usp-chat-message--system .usp-chat-reactions {
    justify-content: center;
}

.usp-chat-message--system .usp-chat-reaction-chip,
.usp-chat-message--system .usp-chat-reaction-add {
    background: #fff;
    color: #1d2327;
}

/* Позиционирование даты, вложений и реакций в сообщении */
.usp-chat-message-time {
    float: right;
    margin: 0 0 4px 8px;
    line-height: 1.3;
    text-align: right;
}

.usp-chat-message--system .usp-chat-message-time {
    float: right;
    margin: 0 0 4px 8px;
    text-align: right;
}

.usp-chat-message-attachments {
    clear: right;
}

.usp-chat-message-footer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    clear: both;
    margin-top: 8px;
}

.usp-chat-message-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.usp-chat-message-actions .usp-chat-message-delete {
    position: static;
    opacity: 0.65;
}

.usp-chat-message-actions .usp-chat-message-delete:hover {
    opacity: 1;
}

.usp-chat-reaction-picker {
    right: 0;
    left: auto;
}

/* Реакции без бордера и фона */
.usp-chat-reaction-chip,
.usp-chat-reaction-chip.is-active,
.usp-chat-message--sent .usp-chat-reaction-chip,
.usp-chat-message--sent .usp-chat-reaction-chip.is-active {
    padding: 2px 0;
    border: none;
    background: transparent;
}

/* Реакции: белый фон без бордера */
.usp-chat-reaction-chip,
.usp-chat-reaction-chip.is-active,
.usp-chat-message--sent .usp-chat-reaction-chip,
.usp-chat-message--sent .usp-chat-reaction-chip.is-active {
    padding: 2px 6px;
    border: none;
    background: #fff;
    color: #1d2327;
}

/* Ответы на сообщения */
.usp-chat-reply-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.65;
}

.usp-chat-reply-button:hover {
    opacity: 1;
}

.usp-chat-reply-quote {
    clear: right;
    margin: 2px 0 6px;
    padding: 6px 9px;
    border-left: 3px solid #0b93f6;
    border-radius: 8px;
    background: rgba(11, 147, 246, 0.08);
    font-size: 12px;
    line-height: 1.35;
}

.usp-chat-reply-quote-author {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.8;
}

.usp-chat-reply-quote-text {
    display: -webkit-box;
    overflow: hidden;
    word-break: break-word;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.usp-chat-message--sent .usp-chat-reply-quote {
    border-left-color: #fff;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.usp-chat-reply-preview {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 10px;
    border-left: 3px solid #0b93f6;
    border-radius: 8px;
    background: #eef4fb;
}

.usp-chat-reply-preview[hidden] {
    display: none;
}

.usp-chat-reply-preview-content {
    flex: 1 1 auto;
    min-width: 0;
}

.usp-chat-reply-preview-author {
    color: #1d2327;
    font-size: 11px;
    font-weight: 700;
}

.usp-chat-reply-preview-text {
    overflow: hidden;
    color: #5f6b73;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usp-chat-reply-cancel {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    color: #5f6b73;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.usp-chat-reply-cancel:hover {
    color: #1d2327;
}

/* Системные сообщения: дата по центру, корзина справа от текста */
.usp-chat-message--system .usp-chat-message-time {
    display: block;
    float: none;
    margin: 0 0 4px;
    text-align: center;
}

.usp-chat-message--system .usp-chat-message-system-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.usp-chat-message--system .usp-chat-message-system-row .usp-chat-message-delete {
    position: static;
    flex: 0 0 auto;
    opacity: 0.65;
}

.usp-chat-message--system .usp-chat-message-system-row .usp-chat-message-delete:hover {
    opacity: 1;
}
