:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #64748b;
    --border: #e5e7eb;
    --sidebar-width: 260px;
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* --- Layout Authentification (Inchangé) --- */
.auth-container { display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; }
.auth-card { background: var(--bg-card); padding: 40px; border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 420px; }
.auth-card h2 { margin-bottom: 24px; font-size: 24px; text-align: center; font-weight: 700; }

/* --- Layout Application (Sidebar + Content) --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    transition: transform 0.3s ease;
    z-index: 100;
}
.logo-area { font-size: 18px; font-weight: 700; padding-bottom: 24px; border-bottom: 1px solid var(--border); margin-bottom: 24px; display: flex; align-items: center; gap: 10px; }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 12px; font-weight: 600; }
.sidebar a { display: flex; align-items: center; padding: 12px 16px; color: #4b5563; text-decoration: none; border-radius: 8px; font-weight: 500; margin-bottom: 6px; transition: all 0.2s; }
.sidebar a:hover, .sidebar a.active { background: var(--primary-light); color: var(--primary); }

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-navbar {
    background: var(--bg-card);
    height: 70px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
}
.menu-toggle-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }

.content-body { padding: 40px; max-width: 1000px; width: 100%; }

/* --- NOUVEAU : Composants Profil Responsifs --- */
.profile-header-card {
    display: flex;
    align-items: center;
    gap: 24px;
    background: var(--bg-card);
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.avatar-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}
.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-light);
}

.profile-title-info h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}
.profile-title-info p {
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
}

/* Grille d'informations inspirée de Capture.PNG */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 10px;
}
.info-item {
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.info-item-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.info-item-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
}

/* --- Formulaires et éléments standards --- */
.card { background: var(--bg-card); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 24px; }
.card h3 { margin-bottom: 20px; font-size: 18px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
input, select, textarea { width: 100%; padding: 12px 16px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; outline: none; background: #fff; transition: all 0.2s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

button.btn { background: var(--primary); color: white; border: none; padding: 12px 24px; border-radius: 8px; font-weight: 600; cursor: pointer; width: 100%; transition: background 0.2s; }
button.btn:hover { background: var(--primary-hover); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.alert-danger { background: #fee2e2; color: #b91c1c; }
.alert-success { background: #dcfce7; color: #15803d; }

/* --- Responsive Mobile et Tablette --- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .top-navbar { padding: 0 20px; }
    .menu-toggle-btn { display: block; }
    .content-body { padding: 20px 16px; }
}

@media (max-width: 576px) {
    .profile-header-card {
        flex-direction: column;
        text-align: center;
        padding: 24px 16px;
    }
    .info-grid {
        grid-template-columns: 1fr; /* Une seule colonne propre sur mobile */
    }
}

/* --- Badges de Statut Dynamiques --- */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-online { background-color: #10b981; box-shadow: 0 0 8px #10b981; }
.status-offline { background-color: #9ca3af; }

/* --- Interface de Tchat (Split View Pro) --- */
.chat-container {
    display: flex;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    height: calc(100vh - 160px);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* Membres disponibles à gauche */
.chat-sidebar {
    width: 320px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.chat-search {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.user-list {
    flex: 1;
    overflow-y: auto;
}
.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}
.user-item:hover, .user-item.active {
    background: var(--primary-light);
}

/* Zone de conversation active à droite */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}
.chat-header {
    background: var(--bg-card);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Bulles de Messages */
.message {
    max-width: 65%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}
.message-received {
    background: var(--bg-card);
    align-self: flex-start;
    border: 1px solid var(--border);
}
.message-sent {
    background: var(--primary);
    color: white;
    align-self: flex-end;
}
.message-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}
.message-sent .message-time { color: #c7d2fe; }

/* Conteneur des Documents joints */
.attachment-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.03);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 6px;
    border: 1px solid rgba(0,0,0,0.05);
}
.message-sent .attachment-box {
    background: rgba(255,255,255,0.15);
}
.attachment-box a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    font-size: 13px;
}

/* Zone de saisie et d'envoi bas de page */
.chat-input-area {
    background: var(--bg-card);
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}
.chat-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Cacher le champ de fichier natif pour faire un joli bouton trombone */
.file-upload-btn {
    cursor: pointer;
    padding: 10px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 18px;
    transition: background 0.2s;
}
.file-upload-btn:hover { background: #e2e8f0; }

/* --- Adaptation Mobile pour le Tchat --- */
@media (max-width: 768px) {
    .chat-container { height: calc(100vh - 140px); }
    .chat-sidebar { width: 100%; }
    /* Si une discussion est ouverte sur mobile, on masque la liste des membres */
    .chat-container.in-conversation .chat-sidebar { display: none; }
    .chat-container:not(.in-conversation) .chat-main { display: none; }
    .message { max-width: 85%; }
}