/* ================================================================ */
/* CHAT — ЧАТ */
/* ================================================================ */

.chat-view {
    display: none;
    flex-direction: column;
    height: 70vh;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 12px;
    margin-bottom: 12px;
}

.chat-view.active {
    display: flex;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-messages .msg {
    padding: 6px 12px;
    border-radius: 12px;
    max-width: 80%;
    font-size: 0.85rem;
    word-wrap: break-word;
    position: relative;
}

.chat-messages .msg.self {
    background: var(--link-color);
    color: #fff;
    align-self: flex-end;
}

.chat-messages .msg.other {
    background: var(--input-bg);
    color: var(--text-color);
    align-self: flex-start;
}

.chat-input {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.chat-input input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    font-size: 0.85rem;
    outline: none;
}

.chat-input input:focus {
    border-color: var(--link-color);
}

.chat-input button {
    padding: 8px 16px;
    background: var(--link-color);
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
}

.chat-input button:hover {
    opacity: 0.85;
}

.back-btn {
    background: none;
    border: none;
    color: var(--link-color);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 0;
    font-weight: 600;
}

.chat-list-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 9px;
    padding: 9px 6px;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.chat-list-item:hover,
.chat-list-item:focus-visible {
    background: var(--input-bg);
    outline: none;
}

.chat-list-item.unread {
    background: color-mix(in srgb, var(--link-color) 8%, transparent);
}

.chat-list-item .avatar-wrap {
    display: flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--avatar-bg);
    flex: 0 0 34px;
}

.chat-list-item .avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-list-info {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 2px;
}

.chat-list-name {
    overflow: hidden;
    font-size: 0.8rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-list-last {
    overflow: hidden;
    color: var(--muted-text);
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-list-unread {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--link-color);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
