@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --text-dark: var(--text);
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 5px 20px rgba(0, 0, 0, 0.06);
  --danger: #ef4444;
  --success: #10b981;
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Poppins', sans-serif; }
html { height: 100%; }
body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  line-height: 1.35;
}

a { color: inherit; }
button, input, select { font: inherit; }

.divider {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

/* Login */
.login-wrapper {
  display: flex;
  width: min(920px, 92vw);
  min-height: 520px;
  background: var(--surface);
  margin: auto;
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-left {
  flex: 1;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px;
  text-align: center;
}
.login-left h1 { font-size: 2.1rem; letter-spacing: 0.3px; }
.login-left p { opacity: 0.9; margin-top: 8px; }

.login-right {
  flex: 1;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.form-group h2, .form-group h3 { margin-bottom: 10px; }
.form-group input {
  width: 100%;
  padding: 12px 14px;
  margin: 6px 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  outline: none;
  transition: 0.2s;
}
.form-group input:focus {
  background: var(--surface);
  border-color: rgba(79, 70, 229, 0.5);
  box-shadow: var(--ring);
}
.btn-login, .btn-register { width:100%; padding:10px; border-radius:8px; border:none; cursor:pointer; }
.btn-login { background: var(--primary); color:white; }
.btn-register { background: white; border:1px solid #ddd; margin-top:5px; }

/* Chat */
.app-container { display:flex; width:95%; max-width:1200px; height:90vh; background:var(--surface); margin:auto; border-radius:20px; box-shadow:var(--shadow-soft); overflow:hidden; }
.sidebar { width:320px; border-right:1px solid var(--border); display:flex; flex-direction:column; background: var(--surface); }
.sidebar-header { padding:20px; border-bottom:1px solid var(--border); }
.user-list { flex:1; overflow-y:auto; list-style:none; }
.user-list li a { display:flex; align-items:center; padding:14px 16px; text-decoration:none; color:var(--text); gap: 10px; }
.user-list li:hover, .user-list li.active { background:var(--surface-2); }
.user-list li a:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 12px; margin: 6px; }
.avatar { width:40px; height:40px; background:#e0e7ff; color:var(--primary); border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:bold; margin-right:10px; }
.avatar img,
.big-avatar img{
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.chat-window { flex:1; display:flex; flex-direction:column; }
.chat-header { padding:15px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap: 10px; }
.block-btn{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.block-btn:hover { background: rgba(0,0,0,0.04); transform: scale(1.04); }
.block-btn.active { background: #fee2e2; border-color: #fecaca; }
.block-banner{
  margin: 12px 20px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  font-size: 0.92rem;
}
.messages-area { flex:1; padding:20px; overflow-y:auto; background:var(--surface-2); display:flex; flex-direction:column; gap:10px; }
.message { max-width:70%; padding:10px 15px; border-radius:15px; font-size:0.9rem; }
.message.me { align-self:flex-end; background:var(--primary); color:white; border-bottom-right-radius:0; }
.message.other { align-self:flex-start; background:var(--surface); border:1px solid var(--border); border-bottom-left-radius:0; }
.message { position: relative; }
.message-content { padding-right: 24px; }
.message-delete{
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.95);
}
.message.me:hover .message-delete { display: inline-flex; }
.message-delete:hover { background: rgba(255,255,255,0.32); }
.message.other .message-delete { display: none !important; }
.input-area { padding:20px; border-top:1px solid #eee; display:flex; gap:10px; }
.input-area input { flex:1; padding:10px 20px; border-radius:20px; border:1px solid #ddd; outline:none; }
.input-area button { width:40px; height:40px; border-radius:50%; border:none; background:var(--primary); color:white; cursor:pointer; }
.no-chat { margin:auto; text-align:center; color:#999; }

/* Admin */
.admin-body { background:#111827; color:#e5e7eb; overflow-y:auto; }
.admin-container { width:90%; max-width:1000px; margin:50px auto; background:#1f2937; padding:30px; border-radius:15px; }
.admin-header { display:flex; justify-content:space-between; margin-bottom:20px; border-bottom:1px solid #374151; padding-bottom:15px; }
.table-wrapper { overflow-x: auto; }
table { width:100%; border-collapse:collapse; }
th, td { padding:15px; text-align:left; border-bottom:1px solid #374151; }
select { background:#374151; color:white; border:1px solid #4b5563; padding:5px; border-radius:5px; }
.admin-inline-form { display:flex; align-items:center; gap:8px; }
.admin-input {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #4b5563;
  padding: 7px 10px;
  border-radius: 8px;
  outline: none;
}
.admin-input:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18); }
.btn-ban { background:#ef4444; color:white; border:none; padding:5px 10px; border-radius:5px; cursor:pointer; }
.btn-unban { background:#10b981; color:white; border:none; padding:5px 10px; border-radius:5px; cursor:pointer; }
.back-link { color:#9ca3af; text-decoration:none; }
.btn-admin-link { display:inline-block; margin-top:5px; background:#1f2937; color:white; padding:5px 10px; border-radius:5px; text-decoration:none; font-size:0.8rem; }

/* Settings */
.settings-body { overflow-y:auto; justify-content:flex-start; padding-top:50px; }
.settings-wrapper { width:100%; max-width:500px; margin:auto; }
.settings-top-nav { margin-bottom: 14px; padding: 0 6px; }
.settings-top-nav .back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
}
.settings-top-nav .back-link:hover { background: rgba(0,0,0,0.04); color: var(--text); }

.profile-card, .danger-card { background:white; padding:30px; border-radius:20px; margin-bottom:20px; box-shadow:0 5px 15px rgba(0,0,0,0.05); }
.big-avatar { width:80px; height:80px; background:var(--primary); color:white; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:2rem; margin:0 auto 10px; overflow:hidden; }
.big-avatar.has-image { background: transparent; color: transparent; }
.profile-header { text-align:center; margin-bottom:20px; }
.settings-form { display:flex; flex-direction:column; gap:10px; }
.settings-form input { padding:10px; border:1px solid #ddd; border-radius:8px; width:100%; }
.btn-save { padding:10px; background:var(--primary); color:white; border:none; border-radius:8px; cursor:pointer; }
.btn-save.secondary { background:white; color:#333; border:1px solid #ddd; }
.danger-card { background:#fff5f5; border:1px solid #fed7d7; }
.danger-input { display:flex; gap:10px; margin-top:10px; }
.danger-input input { flex:1; border-color:#feb2b2; }
.btn-delete { background:#e53e3e; color:white; border:none; padding:0 20px; border-radius:8px; cursor:pointer; }
.alert { padding:10px; background:#fee2e2; color:#991b1b; border-radius:8px; margin-bottom:15px; }
.toast { padding:10px; border-radius:8px; margin-bottom:10px; text-align:center; }
.toast.success { background:#d1fae5; color:#065f46; } .toast.error { background:#fee2e2; color:#991b1b; }

.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.input-group .icon { width: 22px; text-align: center; opacity: 0.75; }
.input-group input {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  outline: none;
}
.input-group:focus-within { background: var(--surface); box-shadow: var(--ring); border-color: rgba(79, 70, 229, 0.45); }

.danger-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.danger-icon { font-size: 1.2rem; }

/* --- CHAT INPUTS & MEDIA (VERSION PROPRE) --- */

.input-area {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column; /* Pour gérer la preview si besoin */
}

.input-area form {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
}

/* Bouton Trombone */
.attach-btn {
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: 0.2s;
}
.attach-btn:hover {
    background-color: #f3f4f6;
    color: var(--primary);
}

/* Champ texte */
.input-area input[type="text"] {
    flex: 1;
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    outline: none;
    transition: 0.2s;
}
.input-area input[type="text"]:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Bouton Envoyer */
.send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0; /* Empêche le bouton d'être écrasé */
}
.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Barre de prévisualisation (quand on a choisi un fichier) */
.file-preview-bar {
    background: #eef2ff;
    color: var(--primary);
    padding: 8px 15px;
    font-size: 0.85rem;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #c7d2fe;
}
.file-preview-bar button {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-weight: bold;
    padding: 0 5px;
}
.file-preview-bar button:hover { color: red; }

/* Images dans le chat */
.chat-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-top: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Liens Fichiers */
.file-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    background: rgba(0,0,0,0.05);
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 5px;
    border: 1px solid rgba(0,0,0,0.05);
}
.file-link:hover { background: rgba(0,0,0,0.08); }

.message.me .file-link {
    background: rgba(255,255,255,0.2);
    color: white;
    border-color: rgba(255,255,255,0.3);
}
/* =========================================
   VERSION MOBILE (RESPONSIVE)
   ========================================= */

/* Par défaut, le bouton "Retour" est caché sur PC */
.mobile-back-btn { display: none; }

/* Quand l'écran fait moins de 768px (Tablettes et Mobiles) */
@media screen and (max-width: 768px) {

    body {
        background: white; /* Plus joli sur mobile */
        height: 100%; /* Évite les bugs de hauteur sur mobile */
    }

    /* Le conteneur prend tout l'écran, sans marges ni arrondis */
    .app-container {
        width: 100%;
        height: 100vh; /* Prend toute la hauteur viewport */
        height: 100dvh; /* Pour les navigateurs mobiles modernes */
        max-width: none;
        border-radius: 0;
        box-shadow: none;
        margin: 0;
    }

    /* Login */
    .login-wrapper {
        width: 100%;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
    }

    /* --- GESTION DE L'AFFICHAGE (LISTE vs CHAT) --- */
    
    /* Classe utilitaire pour cacher des éléments sur mobile */
    .hidden-on-mobile {
        display: none !important;
    }

    /* La sidebar prend tout l'écran */
    .sidebar {
        width: 100%;
        border-right: none;
    }

    /* La fenêtre de chat prend tout l'écran */
    .chat-window {
        width: 100%;
    }

    /* --- HEADER CHAT MOBILE --- */
    .chat-header {
        padding: 10px;
        background: var(--primary); /* En-tête coloré sur mobile type WhatsApp */
        color: white;
    }
    .chat-header .details span { color: #e0e7ff; } /* Texte "En ligne" plus clair */
    
    /* Bouton retour visible uniquement sur mobile */
    .mobile-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 10px;
        text-decoration: none;
        color: white;
        font-size: 1.5rem;
        padding: 5px;
    }

    /* Ajustement des bulles de messages sur petit écran */
    .message {
        max-width: 85%; /* Bulles plus larges */
        font-size: 1rem; /* Texte lisible */
    }

    /* Barre d'input mobile */
    .input-area {
        padding: 10px;
    }
    .input-area input[type="text"] {
        padding: 10px 15px;
    }

    /* Admin & settings sur mobile */
    .admin-container {
        margin: 20px 10px;
        padding: 16px;
        border-radius: 12px;
    }
    .admin-header h1 {
        font-size: 1.3rem;
    }
    table {
        font-size: 0.85rem;
    }
    th, td {
        padding: 10px;
    }
    .settings-wrapper {
        padding: 0 10px 20px;
    }
}

/* Responsive login/settings */
@media screen and (max-width: 860px) {
  .login-wrapper { flex-direction: column; min-height: unset; }
  .login-left { padding: 26px; }
  .login-right { padding: 26px; }
}
@media screen and (max-width: 520px) {
  .settings-body { padding-top: 20px; }
  .profile-card, .danger-card { padding: 18px; border-radius: 16px; }
  .btn-login, .btn-register, .btn-save, .btn-delete {
    width: 100%;
    font-size: 0.9rem;
  }
}
/* --- BOUTONS SIDEBAR (Admin & Sortir) --- */

/* Le conteneur des boutons */
.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 10px; /* Espace entre les boutons */
    margin-top: 15px;
}

/* Bouton Admin (Sombre) */
.btn-admin-link {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #1f2937; /* Gris foncé */
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: transform 0.2s, background 0.2s;
}
.btn-admin-link:hover {
    background-color: #111827;
    transform: translateY(-1px);
}

/* Bouton Sortir (Rouge clair) */
.btn-logout {
    display: flex;
    align-items: center;
    background-color: #fee2e2; /* Rouge très clair */
    color: #b91c1c; /* Rouge foncé */
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: 0.2s;
}
.btn-logout:hover {
    background-color: #fecaca; /* Rouge un peu plus foncé au survol */
    color: #991b1b;
}
/* --- APPELS VOCAUX --- */

/* Bouton Appeler dans le header */
.call-btn {
    background: #10b981;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    margin-right: 15px;
    transition: 0.2s;
}
.call-btn:hover { background: #059669; transform: scale(1.1); }

/* Interface Appel en cours (Flottant) */
.call-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    padding: 15px 25px;
    border-radius: 50px;
    display: flex;
    gap: 20px;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 1000;
    display: none; /* Caché par défaut */
}

.call-status { color: white; font-weight: bold; margin-right: 10px; }

.control-btn {
    width: 50px; height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}

.btn-mute { background: #374151; color: white; }
.btn-mute.muted { background: #ef4444; color: white; position: relative; }
.btn-hangup { background: #ef4444; color: white; }
.btn-hangup:hover { background: #dc2626; }

/* Modal Appel Entrant */
.incoming-call-modal {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 2000;
    display: none;
    animation: slideIn 0.3s ease-out;
    border-left: 5px solid #10b981;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.incoming-buttons { display: flex; gap: 10px; margin-top: 15px; }
.btn-accept { flex: 1; padding: 10px; background: #10b981; color: white; border: none; border-radius: 8px; cursor: pointer; }
.btn-reject { flex: 1; padding: 10px; background: #ef4444; color: white; border: none; border-radius: 8px; cursor: pointer; }