:root {
    --primary-color: #00a884;
    --secondary-color: #f0f2f5;
    --chat-bg: #efeae2;
    --message-out: #d9fdd3;
    --message-in: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
}

* { box-sizing: border_box; margin: 0; padding: 0; font-family: 'Segoe UI', Helvetica, Arial, sans-serif; }

body { height: 100vh; display: flex; background-color: #d1d7db; overflow: hidden; }

/* Setup Layout */
.app-container {
    display: flex;
    width: 100%;
    max-width: 1600px;
    height: 100%;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Sidebar */
.sidebar {
    width: 30%;
    border-right: 1px solid #e9edef;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.sidebar-header {
    height: 60px;
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e9edef;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.2s;
}

.contact-item:hover { background: #f5f6f6; }
.contact-item.active { background: #f0f2f5; }

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #dfe5e7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    margin-right: 15px;
}

.info { overflow: hidden; }
.name { font-weight: 500; font-size: 1rem; color: var(--text-primary); margin-bottom: 4px; }
.last-msg { font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
    background-size: 400px;
}

.chat-header {
    height: 60px;
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e9edef;
    z-index: 10;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 65%;
    padding: 8px;
    border-radius: 8px;
    position: relative;
    font-size: 0.9rem;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}

.message.inbound {
    align-self: flex-start;
    background: var(--message-in);
    border-top-left-radius: 0;
}

.message.outbound {
    align-self: flex-end;
    background: var(--message-out);
    border-top-right-radius: 0;
}

.message img, .message video {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 5px;
}

.time {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
}

/* Input Area */
.input-area {
    min-height: 62px;
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-wrapper {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    padding: 9px 12px;
}

#message-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 0.95rem;
}

.btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    padding: 8px;
}

.btn-send {
    color: var(--text-secondary);
}

.btn:hover { color: var(--primary-color); }

/* Responsive */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: 40%; }
    .chat-area { height: 60%; }
}
