/* Chat Layout */
.chat-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    height: calc(100vh - 70px);
    /* 100vh - sidebar/navbar if applicable, roughly */
    max-height: 800px;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    margin-top: 20px;
}

/* Sidebar (Conversations) */
.chat-sidebar {
    background: var(--surface-light);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    background: white;
}

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

.chat-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-light);
}

.chat-item:hover {
    background: white;
}

.chat-item.active {
    background: white;
    border-left: 4px solid var(--primary);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #e5e7eb;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.chat-meta {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Area */
.chat-main {
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f9fafb;
}

/* Message Bubbles */
.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.received {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
    color: var(--text-main);
}

.message.sent {
    align-self: flex-end;
    background: var(--primary);
    /* Cyan */
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    margin-top: 6px;
    opacity: 0.7;
    text-align: right;
    display: block;
}

/* Input Area */
.chat-input-area {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 12px;
    background: white;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid var(--border-light);
    border-radius: 30px;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--surface-light);
    transition: all 0.2s;
}

.chat-input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.1);
}

.btn-send {
    width: 45px;
    height: 45px;
    background: var(--primary);
    /* Cyan */
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.2s, transform 0.1s;
}

.btn-send:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - 120px);
    }

    .chat-sidebar {
        display: none;
        /* Logic to toggle needed for mobile */
    }

    .chat-sidebar.active {
        display: flex;
        position: absolute;
        width: 100%;
        height: 100%;
        z-index: 10;
    }
}