* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* Login/Register Forms */
.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    margin-bottom: 30px;
    color: #333;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-primary {
    width: 100%;
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.register-link {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
    color: #666;
}

.register-link a {
    color: #667eea;
    text-decoration: none;
}

.register-link a:hover {
    text-decoration: underline;
}

/* Chat Interface */
.chat-wrapper {
    display: flex;
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: #fff;
    border-right: 1px solid #e4e6eb;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    background: #fff;
    color: #050505;
    border-bottom: 1px solid #e4e6eb;
}

.sidebar-header h3 {
    margin-bottom: 10px;
    font-size: 24px;
    font-weight: 700;
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
    color: #65676b;
}

.btn-logout {
    background: #f0f2f5;
    color: #050505;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: #e4e6eb;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.user-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-item:hover {
    background: #f2f3f5;
}

.user-item.active {
    background: #e7f3ff;
}

.user-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #bcc0c4;
    position: relative;
    flex-shrink: 0;
}

.user-status.online {
    background: #31a24c;
    box-shadow: 0 0 0 2px #fff;
}

.user-status.offline {
    background: #bcc0c4;
}

.user-name {
    flex: 1;
    font-weight: 500;
    font-size: 15px;
    color: #050505;
}

.unread-count {
    background: #f44336;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.chat-header {
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    color: #333;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.message {
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    flex-direction: row-reverse;
}

.message-content {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 18px;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
    font-size: 14px;
}

.message.received .message-content {
    background: #f0f0f0;
    color: #050505;
    border-bottom-left-radius: 4px;
}

.message.sent .message-content {
    background: #0084ff;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message.sent .message-time {
    color: white;
}

.message.received .message-time {
    color: #65676b;
}

.typing-indicator {
    padding: 10px 20px;
    font-size: 13px;
    color: #65676b;
    font-style: italic;
    flex-shrink: 0;
}

.message-input {
    display: flex;
    align-items: flex-end;
    padding: 12px 20px;
    gap: 8px;
    border-top: 1px solid #e4e6eb;
    background: #fff;
    flex-shrink: 0;
}

.message-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 14px;
    background: #f0f2f5;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1.4;
    min-height: 36px;
    max-height: 120px;
}

.message-input input:focus {
    outline: none;
    background: #fff;
    border-color: #0084ff;
    box-shadow: 0 0 0 2px rgba(0, 132, 255, 0.1);
}

.btn-send {
    background: #0084ff;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    flex-shrink: 0;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover {
    background: #0073e6;
    transform: scale(1.02);
}

.btn-send:active {
    transform: scale(0.98);
}

.btn-send:disabled {
    background: #e4e6eb;
    color: #bcc0c4;
    cursor: not-allowed;
    transform: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-wrapper {
        flex-direction: column;
        height: 100vh;
    }
    
    .sidebar {
        width: 100%;
        max-height: 40vh;
    }
    
    .message-content {
        max-width: 85%;
    }
}

/* Message bubble grouping */
.message + .message.sent {
    margin-top: 2px;
}

.message + .message.received {
    margin-top: 2px;
}

/* Empty state */
.messages:empty::after {
    content: 'Chưa có tin nhắn nào';
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #bcc0c4;
    font-size: 14px;
}
