/* S'assurer que hidden fonctionne */
.hidden {
    display: none !important;
}

/* Auth screen toujours visible par défaut */
.auth-screen {
    display: flex !important;
}

/* Chat app caché par défaut */
.chat-app.hidden {
    display: none !important;
}

/* Quand chat-app n'a pas hidden, il doit être flex */
.chat-app:not(.hidden) {
    display: flex !important;
}
:root {
    --primary: #128C7E;
    --primary-dark: #075E54;
    --secondary: #25D366;
    --bg: #E5DDD5;
    --sidebar-bg: #FFFFFF;
    --chat-bg: #F0F2F5;
    --message-out: #DCF8C6;
    --message-in: #FFFFFF;
    --text: #111B21;
    --text-secondary: #667781;
    --border: #E9EDEF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #dadbd3;
    height: 100vh;
    overflow: hidden;
}

/* Auth Screen */
.auth-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.auth-container {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary);
}

.auth-logo i {
    font-size: 60px;
    margin-bottom: 10px;
}

.auth-logo h1 {
    font-size: 28px;
    color: var(--text);
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--chat-bg);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form.hidden {
    display: none;
}

.auth-form input {
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-form button {
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover {
    background: var(--primary-dark);
}

/* Chat App */
.chat-app {
    display: flex;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.chat-app.hidden {
    display: none;
}

/* Sidebar */
.sidebar {
    width: 35%;
    min-width: 300px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px 20px;
    background: var(--sidebar-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.header-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.header-actions button:hover {
    background: var(--chat-bg);
}

.search-box {
    padding: 10px 15px;
    background: var(--chat-bg);
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box i {
    color: var(--text-secondary);
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    padding: 8px;
    font-size: 14px;
    outline: none;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.contact-item:hover {
    background: var(--chat-bg);
}

.contact-item.active {
    background: var(--chat-bg);
}

.contact-item .avatar {
    position: relative;
    flex-shrink: 0;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-indicator.online {
    background: var(--secondary);
}

.status-indicator.offline {
    background: var(--text-secondary);
}

.contact-info {
    flex: 1;
    margin-left: 15px;
    overflow: hidden;
}

.contact-name {
    font-weight: 600;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.contact-preview {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--primary);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
}

.empty-chat i {
    font-size: 80px;
    margin-bottom: 20px;
    color: #d1d7db;
}

.empty-chat h2 {
    color: var(--text);
    margin-bottom: 10px;
}

.active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 15px 20px;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.contact-details h3 {
    font-size: 16px;
    color: var(--text);
}

.contact-details .status {
    font-size: 13px;
    color: var(--text-secondary);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.05"><rect fill="%23ffffff" width="100" height="100"/></svg>');
}

.message {
    max-width: 65%;
    margin-bottom: 15px;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    background: var(--message-out);
    margin-left: auto;
    border-top-right-radius: 0;
}

.message.received {
    background: var(--message-in);
    margin-right: auto;
    border-top-left-radius: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-content {
    font-size: 14.5px;
    line-height: 1.4;
    color: var(--text);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}

.message-time i {
    font-size: 14px;
}

.message-time i.read {
    color: #53bdeb;
}

.chat-input {
    padding: 15px 20px;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: 15px;
    border-top: 1px solid var(--border);
}

.chat-input button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.3s;
}

.chat-input button:hover {
    color: var(--text);
}

.chat-input input {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 20px;
    background: var(--chat-bg);
    font-size: 15px;
    outline: none;
}

.send-btn {
    color: var(--primary) !important;
}

.send-btn:hover {
    color: var(--primary-dark) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        transform: translateX(0);
        transition: transform 0.3s;
    }
    
    .sidebar.hidden-mobile {
        transform: translateX(-100%);
    }
    
    .chat-area {
        width: 100%;
    }
    
    .back-btn {
        display: block !important;
        margin-right: 10px;
    }
}

.back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}:root {
    --primary: #128C7E;
    --primary-dark: #075E54;
    --secondary: #25D366;
    --bg: #E5DDD5;
    --sidebar-bg: #FFFFFF;
    --chat-bg: #F0F2F5;
    --message-out: #DCF8C6;
    --message-in: #FFFFFF;
    --text: #111B21;
    --text-secondary: #667781;
    --border: #E9EDEF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #dadbd3;
    height: 100vh;
    overflow: hidden;
}

/* Auth Screen */
.auth-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.auth-container {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary);
}

.auth-logo i {
    font-size: 60px;
    margin-bottom: 10px;
}

.auth-logo h1 {
    font-size: 28px;
    color: var(--text);
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--chat-bg);
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form.hidden {
    display: none;
}

.auth-form input {
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-form button {
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover {
    background: var(--primary-dark);
}

/* Chat App */
.chat-app {
    display: flex;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.chat-app.hidden {
    display: none;
}

/* Sidebar */
.sidebar {
    width: 35%;
    min-width: 300px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px 20px;
    background: var(--sidebar-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.header-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.header-actions button:hover {
    background: var(--chat-bg);
}

.search-box {
    padding: 10px 15px;
    background: var(--chat-bg);
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box i {
    color: var(--text-secondary);
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    padding: 8px;
    font-size: 14px;
    outline: none;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.contact-item:hover {
    background: var(--chat-bg);
}

.contact-item.active {
    background: var(--chat-bg);
}

.contact-item .avatar {
    position: relative;
    flex-shrink: 0;
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-indicator.online {
    background: var(--secondary);
}

.status-indicator.offline {
    background: var(--text-secondary);
}

.contact-info {
    flex: 1;
    margin-left: 15px;
    overflow: hidden;
}

.contact-name {
    font-weight: 600;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.contact-preview {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--primary);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
}

.empty-chat i {
    font-size: 80px;
    margin-bottom: 20px;
    color: #d1d7db;
}

.empty-chat h2 {
    color: var(--text);
    margin-bottom: 10px;
}

.active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 15px 20px;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.contact-details h3 {
    font-size: 16px;
    color: var(--text);
}

.contact-details .status {
    font-size: 13px;
    color: var(--text-secondary);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.05"><rect fill="%23ffffff" width="100" height="100"/></svg>');
}

.message {
    max-width: 65%;
    margin-bottom: 15px;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    background: var(--message-out);
    margin-left: auto;
    border-top-right-radius: 0;
}

.message.received {
    background: var(--message-in);
    margin-right: auto;
    border-top-left-radius: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-content {
    font-size: 14.5px;
    line-height: 1.4;
    color: var(--text);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}

.message-time i {
    font-size: 14px;
}

.message-time i.read {
    color: #53bdeb;
}

.chat-input {
    padding: 15px 20px;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    gap: 15px;
    border-top: 1px solid var(--border);
}

.chat-input button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.3s;
}

.chat-input button:hover {
    color: var(--text);
}

.chat-input input {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 20px;
    background: var(--chat-bg);
    font-size: 15px;
    outline: none;
}

.send-btn {
    color: var(--primary) !important;
}

.send-btn:hover {
    color: var(--primary-dark) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        transform: translateX(0);
        transition: transform 0.3s;
    }
    
    .sidebar.hidden-mobile {
        transform: translateX(-100%);
    }
    
    .chat-area {
        width: 100%;
    }
    
    .back-btn {
        display: block !important;
        margin-right: 10px;
    }
}

.back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}
/* Bouton nouvelle conversation */
.new-chat-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    position: fixed;
    bottom: 30px;
    left: 30px;
    box-shadow: 0 4px 12px rgba(18, 140, 126, 0.4);
    transition: transform 0.2s;
    z-index: 100;
}

.new-chat-btn:hover {
    transform: scale(1.1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: 15px;
    overflow: hidden;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.users-list {
    margin-top: 15px;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.user-item:hover {
    background: var(--chat-bg);
}

.user-item .avatar {
    margin-right: 15px;
}

.user-item .user-name {
    flex: 1;
    font-weight: 600;
}

.user-item .add-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
}

.user-item .add-btn:hover {
    background: var(--primary-dark);
}

.user-item .add-btn.added {
    background: var(--secondary);
}

/* Sidebar header avec bouton */
.sidebar-header {
    padding: 15px 20px;
    background: var(--sidebar-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.header-actions button:hover {
    background: var(--chat-bg);
    color: var(--primary);
}