* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Login */
.login-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    width: 400px;
    max-width: 90%;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
    font-size: 1.8rem;
}

.login-box input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: 0.3s;
}

.login-box input:focus {
    border-color: #667eea;
    outline: none;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.login-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.login-box p {
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.login-box a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

/* Chat Container */
.chat-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 95vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 15px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

#logoutBtn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: 0.3s;
}

#logoutBtn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* User Section (Gauche) */
.user-section {
    width: 280px;
    min-width: 200px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.user-profile .avatar {
    font-size: 2.5rem;
    color: #667eea;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info span:first-child {
    font-weight: 600;
    font-size: 1.1rem;
}

.user-actions {
    margin: 15px 0;
}

#addContactBtn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
}

#addContactBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.pending-requests {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
}

.pending-request {
    background: #fff3cd;
    padding: 10px 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.pending-request .req-actions button {
    padding: 5px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
}

.pending-request .accept {
    background: #28a745;
    color: white;
}

.pending-request .reject {
    background: #dc3545;
    color: white;
    margin-left: 5px;
}

/* Contacts Section (Milieu) */
.contacts-section {
    width: 300px;
    min-width: 220px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.search-box {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    background: white;
}

.search-box i {
    color: #999;
    margin-right: 10px;
}

.search-box input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
}

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

.contact-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: 0.2s;
    border-left: 3px solid transparent;
}

.contact-item:hover {
    background: #e9ecef;
}

.contact-item.active {
    background: #e9ecef;
    border-left-color: #667eea;
}

.contact-item .contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.contact-item .contact-details {
    flex: 1;
}

.contact-item .contact-name {
    font-weight: 500;
    font-size: 1rem;
}

.contact-item .contact-status {
    font-size: 0.75rem;
    color: #999;
}

.contact-item .contact-status.online {
    color: #28a745;
}

.contact-item .contact-status.offline {
    color: #999;
}

/* Chat Section (Droite) */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.chat-header-contact {
    padding: 15px 20px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
}

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

.chat-header-contact .contact-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.chat-header-contact .contact-status {
    font-size: 0.8rem;
    color: #999;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ccc;
}

.empty-chat i {
    font-size: 3rem;
    margin-bottom: 10px;
}

.message {
    max-width: 70%;
    margin-bottom: 10px;
    padding: 10px 15px;
    border-radius: 15px;
    word-wrap: break-word;
    animation: fadeIn 0.3s;
}

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

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

.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.received {
    align-self: flex-start;
    background: white;
    border: 1px solid #e0e0e0;
}

.message .message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

.message .message-sender {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 3px;
    color: #667eea;
}

.message.received .message-sender {
    color: #764ba2;
}

.chat-input {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input textarea {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    max-height: 100px;
    transition: 0.3s;
}

.chat-input textarea:focus {
    outline: none;
    border-color: #667eea;
}

#sendMessageBtn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.3s;
    flex-shrink: 0;
}

#sendMessageBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-body {
        flex-direction: column;
    }

    .user-section {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        max-height: 200px;
        padding: 15px;
    }

    .contacts-section {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        max-height: 200px;
    }

    .chat-section {
        flex: 1;
        min-height: 300px;
    }

    .pending-requests {
        max-height: 80px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}