html,
body {
    height: 100%;
}

.chat-layout {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: #f8f9fa;
}

.chat-sidebar {
    width: 320px;
    flex: 0 0 320px;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-header .user-info {
    min-width: 0;
}

.sidebar-header .user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-search {
    padding: 8px 12px;
    border-bottom: 1px solid #dee2e6;
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-top: none;
    z-index: 20;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
}

.search-result-item:hover {
    background: #f1f3f5;
}

.search-result-item .name {
    font-weight: 600;
}

.search-result-item .email {
    font-size: 0.82rem;
    color: #6c757d;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
}

.conversation-item:hover {
    background: #f1f3f5;
}

.conversation-item.active {
    background: #e7f1ff;
}

.conversation-body {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-last {
    font-size: 0.85rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #0d6efd;
    color: #fff;
    border-radius: 10px;
    padding: 2px 7px;
    font-size: 0.75rem;
    flex: 0 0 auto;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    padding: 20px;
    text-align: center;
}

.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-header {
    padding: 10px 16px;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header .name {
    font-weight: 600;
}

.chat-header .typing {
    font-size: 0.8rem;
    color: #6c757d;
    min-height: 1.2em;
}

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

.message-row {
    display: flex;
}

.message-row.own {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 72%;
    padding: 8px 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #dee2e6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-row.own .message-bubble {
    background: #0d6efd;
    color: #fff;
    border: none;
}

.message-meta {
    font-size: 0.72rem;
    color: #6c757d;
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 2px;
}

.message-row.own .message-meta {
    color: rgba(255, 255, 255, 0.85);
}

.tick.read {
    color: #0d6efd;
}

.message-row.own .tick.read {
    color: #cfe2ff;
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #dee2e6;
    background: #fff;
}

@media (max-width: 767.98px) {
    .chat-sidebar {
        width: 100%;
        flex-basis: 100%;
    }

    .chat-layout.show-chat .chat-sidebar {
        display: none;
    }

    .chat-layout.show-chat .chat-area {
        display: flex;
    }

    .chat-layout:not(.show-chat) .chat-area {
        display: none;
    }
}
