:root {
    --chat-bg: #f0f2f5;
    --sidebar-bg: #ffffff;
    --primary-blue: #0088cc;
    --message-sent: #dcf8c6;
    --message-received: #ffffff;
    --text-dark: #333333;
    --text-muted: #888888;
    --border-color: #e5e5e5;
    --shadow-soft: 0 2px 5px rgba(0,0,0,0.05);
    --input-height: 70px;
    --header-height: 70px;
}

body {
    background-color: #e9eff1;
    margin: 0;
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    background: white;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 100;
    position: relative;
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-list {
    display: flex;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-list a:hover {
    color: var(--primary-blue);
}

/* Chat Layout */
.chat-layout {
    display: flex;
    height: calc(100vh - 60px);
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

/* Sidebar */
.chat-sidebar {
    width: 350px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    background: #f7f7f7;
    border-bottom: 1px solid var(--border-color);
    font-weight: bold;
    color: var(--text-dark);
    font-size: 1.1rem;
}

.rooms-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.room-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f9f9f9;
}

.room-item:hover {
    background: #f5f5f5;
}

.room-item.active {
    background: #e3f2fd;
    border-right: 4px solid var(--primary-blue);
}

.room-avatar {
    width: 45px;
    height: 45px;
    background: #ddd;
    border-radius: 50%;
    margin-left: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
}

.room-info {
    flex: 1;
}

.room-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.room-last-msg {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #efe7dd; /* WhatsApp-like bg pattern base */
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    position: relative;
}

.chat-header-main {
    height: var(--header-height);
    background: #f0f2f5;
    padding: 0 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
}

.chat-header-title {
    font-weight: bold;
    color: var(--text-dark);
}

.chat-header-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.messages-container {
    flex: 1;
    padding: 20px 50px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease;
}

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

.message.sent {
    align-self: flex-end;
    background: var(--message-sent);
    border-top-left-radius: 0;
}

.message.received {
    align-self: flex-start;
    background: var(--message-received);
    border-top-right-radius: 0;
}

.message-sender {
    font-size: 0.75rem;
    font-weight: bold;
    color: #e5991e; /* Distinct color for names */
    margin-bottom: 4px;
}

.message.sent .message-sender {
    display: none; /* Hide sender name for own messages */
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-dark);
}

.message-time {
    font-size: 0.7rem;
    color: #999;
    text-align: left;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* Input Area */
.chat-input-area {
    min-height: var(--input-height);
    background: #f0f2f5;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    flex: 1;
    background: white;
    border-radius: 25px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
}

.btn-icon {
    background: none;
    border: none;
    color: #919191;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(0,0,0,0.05);
}

.btn-send {
    background: var(--primary-blue);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.btn-send:hover {
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
        height: calc(100vh - 110px); /* Adjust for mobile nav */
    }
    
    .chat-sidebar {
        width: 100%;
        height: 70px; /* Collapsed sidebar for mobile rooms */
        flex-direction: row;
        overflow-x: auto;
        border-bottom: 1px solid #ddd;
    }

    .sidebar-header {
        display: none;
    }

    .rooms-list {
        display: flex;
        padding: 0;
    }

    .room-item {
        border-bottom: none;
        border-right: none;
        border-left: 1px solid #eee;
        padding: 10px;
        min-width: 120px;
        justify-content: center;
    }
    
    .room-info {
        text-align: center;
    }
    
    .room-last-msg {
        display: none;
    }
    
    .room-avatar {
        margin: 0 0 5px 0;
    }
    
    .messages-container {
        padding: 15px;
    }
}
