/* =========================
   MODIFICATION: empêcher le scroll général de la page
   Chaque zone interne aura son propre scroll.
========================= */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f7f9fc;
  color: #222;
  margin: 0;
  height: 100%;
  overflow: hidden;
}

header {
  background-color: #0b2850;
  color: white;

  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0.8rem 2rem;

  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);

  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* =========================
   NAVIGATION
========================= */
.top-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.12);
  color: white;

  border: 1px solid rgba(255, 255, 255, 0.15);

  padding: 0.55rem 0.8rem;
  border-radius: 10px;

  cursor: pointer;

  display: flex;
  align-items: center;
  gap: 0.35rem;

  font-weight: 600;
  font-size: 0.9rem;

  transition:
    background 0.3s,
    transform 0.2s,
    border 0.3s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
}

.nav-btn.active {
  background: white;
  color: #0b2850;
}

.nav-btn.logout {
  background: #9ca3af;
}

.nav-btn.logout:hover {
  background: #ef4444;
}

.nav-icon {
  font-size: 1.05rem;
}

.nav-text {
  white-space: nowrap;
}

/* =========================
   MODIFICATION: la page Chat prend une hauteur fixe
   Cela empêche les messages de pousser le formulaire vers le bas.
========================= */
.chat-page {
  max-width: 1460px;
  /* La hauteur disponible est calculée après le header */
  height: calc(100vh - 105px);
  margin: 1rem auto;
  display: grid;
  grid-template-columns: var(--contacts-width, 330px) 6px 1fr 420px;
  background: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  border: 1px solid #d7dde8;
  /* Important pour que les enfants puissent avoir leur propre scroll */
  min-height: 0;
}

/* =========================
   MODIFICATION: colonne contacts fixe
   Seule la liste des contacts doit scroller.
========================= */
.contacts-panel {
  border-right: 1px solid #d7dde8;
  background: white;

  display: flex;
  flex-direction: column;

  min-width: 0;
  min-height: 0;

  overflow: hidden;
}

/* =========================
   BARRE DE REDIMENSIONNEMENT CONTACTS / CHAT
========================= */
.contact-resize-handle {
  position: relative;

  width: 6px;
  min-width: 6px;

  cursor: col-resize;

  background: transparent;

  z-index: 20;
}

.contact-resize-handle::before {
  content: "";

  position: absolute;

  top: 0;
  bottom: 0;
  left: 2px;

  width: 2px;

  background: #d7dde8;

  transition:
    width 0.2s,
    left 0.2s,
    background 0.2s;
}

.contact-resize-handle:hover::before,
body.resizing-contacts .contact-resize-handle::before {
  left: 1px;
  width: 4px;

  background: #0b2850;
}

body.resizing-contacts {
  cursor: col-resize;
  user-select: none;
}

.contact-search-row {
  display: flex;
  gap: 0.7rem;
  padding: 1rem;
  border-bottom: 1px solid #e5e9f0;
}

.contact-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  padding: 0 0.7rem;
}

.contact-search input {
  border: none;
  outline: none;
  width: 100%;
  padding: 0.75rem 0;
  font-size: 0.95rem;
}

/* =========================
   MODIFICATION: scroll uniquement dans la liste des contacts
========================= */
.contacts-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.contact-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #edf1f5;
  cursor: pointer;
}

.contact-item > div:nth-child(2) {
  min-width: 0;
  overflow: hidden;
}

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

.contact-item.active {
  background: #0b2850;
  color: white;
}

.contact-avatar-wrapper {
  position: relative;
}

.contact-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}

.contact-online-dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border: 2px solid white;
  border-radius: 50%;
}

.contact-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.contact-preview {
  margin: 0.2rem 0 0;

  font-size: 0.9rem;
  opacity: 0.85;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  max-width: 100%;
}

.contact-preview.special-preview {
  font-style: italic;
  opacity: 0.65;
}

.contact-time {
  font-size: 0.8rem;
  opacity: 0.8;
  white-space: nowrap;
}

.unread-badge {
  background: #22c55e;
  color: white;
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  margin-left: 0.4rem;
}

/* =========================
   MODIFICATION: colonne conversation fixe
   Le header et le formulaire restent visibles.
   Seule la liste des messages scrolle.
========================= */
.chat-panel {
  background: white;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  min-height: 70px;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid #d7dde8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h1 {
  margin: 0;
  color: #0b2850;
  font-size: 1.3rem;
}

.chat-status {
  margin: 0.25rem 0 0;
  color: #6b7280;
  font-size: 0.85rem;
}

.back-btn {
  display: none;
  background: transparent;
  border: none;
  color: #0b2850;
  font-size: 2rem;
  cursor: pointer;
  margin-right: 0.5rem;
}

.active-indicator {
  color: #2e9f45;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.active-dot {
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}

.active-dot.offline {
  background: #9ca3af;
}

/* =========================
   MODIFICATION: scroll uniquement dans la zone des messages
   Le formulaire reste toujours visible en bas.
========================= */
.messages-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 1.4rem;
  background: #ffffff;
}

.message-row {
  display: flex;
  margin-bottom: 1rem;
}

.message-link {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.message-link:hover {
  opacity: 0.85;
}

.message-row.received {
  justify-content: flex-start;
}

.message-row.sent {
  justify-content: flex-end;
}

.message-content {
  max-width: 65%;
  min-width: 0;

  display: flex;
  flex-direction: column;
}

.message-bubble {
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.35;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.08);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.message-row.received .message-bubble {
  background: #e5e9ef;
  color: #111827;
  border-top-left-radius: 4px;
}

.message-row.sent .message-bubble {
  background: #1f79d0;
  color: white;
  border-top-right-radius: 4px;
}

.message-time {
  font-size: 0.75rem;
  color: #7b8794;
  margin-top: 0.3rem;

  flex-shrink: 0;
  white-space: nowrap;
}

.message-row.sent .message-time {
  align-self: flex-end;
  text-align: right;
}

.message-row.received .message-time {
  align-self: flex-start;
  text-align: left;
}

.message-file {
  margin-top: 0.5rem;
}

.message-file a {
  color: inherit;
  font-weight: 700;
}

.chat-image {
  max-width: 220px;
  border-radius: 10px;
  margin-top: 0.4rem;
  display: block;
}

.load-history-btn {
  display: block;
  margin: 0 auto 1.2rem;
  padding: 0.55rem 1rem;

  border: 1px solid #d1d5db;
  border-radius: 999px;

  background: #f8fafc;
  color: #475569;

  font-size: 0.85rem;
  font-weight: 600;

  cursor: pointer;
}

.load-history-btn:hover {
  background: #f1f5f9;
}

.load-history-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* =========================
   MODIFICATION: formulaire avec bouton fichier + bouton emoji + textarea + bouton envoyer
   On ajoute une colonne de 46px pour le bouton emoji.
========================= */
.message-form {
  display: grid;
  grid-template-columns: 46px 46px 1fr 100px;
  gap: 0.7rem;
  padding: 1rem;
  border-top: 1px solid #d7dde8;
  background: white;
  flex-shrink: 0;
  position: relative;
}

.attach-btn {
  border: 1px solid #cfd7e3;
  background: white;
  color: #0b2850;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
}

.file-input {
  display: none;
}

/* =========================
   MODIFICATION: zone de texte multi-lignes
   Le message passe à la ligne comme dans WhatsApp.
========================= */
.message-form textarea {
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  padding: 0.8rem;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 130px;
  overflow-y: auto;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.send-btn {
  background: #0b2850;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.file-preview {
  margin: 0;
  padding: 0 1rem 0.8rem;
  color: #0b2850;
  font-size: 0.85rem;
  /* Modification : la preview fichier reste sous le formulaire sans casser le layout */
  flex-shrink: 0;
}

/* =========================
   MODIFICATION: profil fixe à droite
   Il ne bouge pas quand on scrolle dans les messages.
   Il scrolle seulement si son propre contenu devient trop long.
========================= */
.profile-panel {
  border-left: 1px solid #d7dde8;
  background: white;
  padding: 1.4rem 1.2rem;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.profile-photo {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 1.2rem;
}

.profile-panel h2 {
  color: #0b2850;
  margin: 0 0 0.8rem;
}

.request-status {
  padding: 0.65rem;
  border-radius: 8px;
  font-weight: 700;
  text-align: center;
}

.request-status.confirmed {
  background: #d8f8df;
  color: #15803d;
  border: 1px solid #86efac;
}

.empty-message {
  color: #6b7280;
  font-style: italic;
}

/* =========================
   PHOTO PROFILE MODAL
========================= */
.photo-modal {
  position: fixed;
  inset: 0;

  background: rgba(0, 0, 0, 0.75);

  display: none;
  justify-content: center;
  align-items: center;

  z-index: 9999;

  padding: 1rem;
}

.photo-modal.open {
  display: flex;
}

.photo-modal-content {
  position: relative;

  width: min(90vw, 420px);

  background: #111827;

  border-radius: 16px;

  padding: 1.2rem;

  text-align: center;

  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);

  animation: photoZoom 0.2s ease;
}

.photo-modal-content h2 {
  color: white;

  margin: 0 0 1rem;

  font-size: 1.2rem;
}

.photo-modal-image {
  width: 100%;
  max-height: 70vh;

  object-fit: contain;

  border-radius: 14px;

  background: #000;
}

.close-photo-modal {
  position: absolute;

  top: 10px;
  right: 12px;

  width: 34px;
  height: 34px;

  border: none;
  border-radius: 50%;

  background: rgba(255, 255, 255, 0.15);
  color: white;

  font-size: 1.6rem;
  line-height: 1;

  cursor: pointer;

  transition:
    background 0.3s,
    transform 0.2s;
}

.close-photo-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.profile-photo,
.contact-avatar {
  cursor: pointer;
}

@keyframes photoZoom {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 600px) {
  .photo-modal-content {
    width: 95vw;
    padding: 1rem;
  }

  .photo-modal-content h2 {
    font-size: 1rem;
  }

  .photo-modal-image {
    max-height: 75vh;
  }

  .nav-text {
    display: none;
  }

  .nav-btn {
    width: 42px;
    height: 42px;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
  }

  .nav-icon {
    font-size: 1.15rem;
  }
}

@media (max-width: 1150px) {
  .chat-page {
    grid-template-columns: 300px 1fr;
  }

  .contact-resize-handle {
    display: none;
  }

  .profile-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  header {
    padding: 0.8rem 1rem;
    flex-direction: column;
    gap: 0.8rem;
  }

  .top-nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .nav-btn {
    padding: 0.5rem 0.7rem;
  }

  /* =========================
    MODIFICATION MOBILE:
    La page garde une hauteur fixe et seul le contenu interne scrolle.
  ========================= */
  .chat-page {
    height: calc(100vh - 120px);
    height: calc(100dvh - 120px);
    margin: 0;
    border-radius: 0;
    display: block;
    border: none;
    overflow: hidden;
  }

  .contacts-panel,
  .chat-panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .chat-panel {
    display: none;
  }

  .chat-page.mobile-chat-open .contacts-panel {
    display: none;
  }

  .chat-page.mobile-chat-open .chat-panel {
    display: flex;
  }

  .back-btn {
    display: inline-block;
  }

  .chat-header {
    justify-content: flex-start;
    gap: 0.6rem;
  }

  .active-indicator {
    margin-left: auto;
  }

  .message-content {
    max-width: 82%;
  }

  .send-btn {
    font-size: 0.8rem;
  }
}

/* =========================
   MODIFICATION: MESSAGE CHAT TERMINÉ
   Ce bloc affiche un message permanent quand la Lernpartnerschaft est terminée.
========================= */
.ended-chat-notice {
  margin: 0;
  padding: 0.85rem 1rem;
  background: #fff7ed;
  color: #9a3412;
  border-top: 1px solid #fed7aa;
  border-bottom: 1px solid #fed7aa;
  font-weight: 700;
  text-align: center;
}

.ended-chat-notice.hidden {
  display: none;
}

/* =========================
   MODIFICATION: FORMULAIRE DÉSACTIVÉ
   Ces styles montrent clairement que l'envoi de message est bloqué.
========================= */
.message-form.disabled {
  background: #f3f4f6;
  opacity: 0.75;
}

/* Modification : style désactivé adapté au textarea */
.message-form.disabled textarea {
  background: #e5e7eb;
  cursor: not-allowed;
}

.message-form.disabled .send-btn,
.message-form.disabled .attach-btn {
  cursor: not-allowed;
  opacity: 0.6;
}

.send-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* =========================
   MODIFICATION: STATUT TERMINÉ
   Ce badge affiche correctement une collaboration terminée.
========================= */
.request-status.ended {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* =========================
   MODIFICATION: MODAL PERSONNALISÉE
   Cette modal remplace les alert() de navigateur.
========================= */
.custom-modal.hidden {
  display: none;
}

.custom-modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-box {
  position: relative;
  width: min(90vw, 430px);
  margin: 15vh auto 0;
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  animation: modalPop 0.2s ease;
}

.modal-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.modal-box h2 {
  margin: 0 0 0.7rem;
  color: #0b2850;
}

.modal-box p {
  margin: 0 0 1.2rem;
  color: #374151;
  line-height: 1.5;
}

.modal-box button {
  background: #0b2850;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.4rem;
  font-weight: 700;
  cursor: pointer;
}


.modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions button {
  flex: 1 1 0;
  margin-top: 0;
}

.modal-actions .modal-cancel-btn.hidden {
  display: none;
}

.modal-actions .modal-cancel-btn {
  background: #e5e7eb;
  color: #1f2937;
}

.modal-actions .modal-cancel-btn:hover {
  background: #d1d5db;
}

@media (max-width: 420px) {
  .modal-actions {
    flex-direction: column;
  }
}

.modal-box.success {
  border-top: 6px solid #22c55e;
}

.modal-box.error {
  border-top: 6px solid #ef4444;
}

.modal-box.warning {
  border-top: 6px solid #f59e0b;
}

.modal-box.info {
  border-top: 6px solid #3b82f6;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(-15px) scale(0.97);
  }

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

/* =========================
   MODIFICATION: BADGES DE NOTIFICATION
   Petit badge rouge sur les boutons de navigation.
========================= */
.nav-btn {
  position: relative;
}

.nav-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #ef4444;
  color: white;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.nav-badge.hidden {
  display: none;
}

/* =========================
   MODIFICATION: conserver les retours à la ligne dans les messages
   Cela permet d'afficher les messages multi-lignes comme dans WhatsApp.
========================= */
.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* =========================
   MODIFICATION: ACTIONS SUR LES MESSAGES
   Ces boutons permettent de copier ou supprimer un message.
========================= */
.message-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.message-row:hover .message-actions {
  opacity: 1;
}

.message-action-btn {
  border: none;
  background: #f3f4f6;
  color: #374151;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.message-action-btn:hover {
  background: #e5e7eb;
}

.message-action-btn.delete {
  color: #b91c1c;
}

.message-row.sent .message-actions {
  justify-content: flex-end;
}

.message-deleted {
  font-style: italic;
  opacity: 0.75;
}

/* =========================
   MODIFICATION: STRUCTURE DU HEADER DU CHAT
   Cette partie permet d'intégrer proprement le menu trois points dans le header.
========================= */
.chat-header-info {
  min-width: 0;
  flex: 1;
}

.chat-header-info h1,
.chat-header-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================
   MODIFICATION: MENU TROIS POINTS DU CHAT
   Ce menu donne accès aux médias/fichiers, liens partagés et recherche.
========================= */
.chat-options-wrapper {
  position: relative;
  margin-left: 0.5rem;
}

.chat-options-btn {
  width: 38px;
  height: 38px;

  border: none;
  border-radius: 50%;

  background: #eef2f7;
  color: #0b2850;

  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition:
    background 0.2s,
    transform 0.2s;
}

.chat-options-btn:hover {
  background: #dbeafe;
  transform: translateY(-2px);
}

.chat-options-menu {
  position: absolute;
  top: 46px;
  right: 0;

  width: 230px;

  background: white;
  border: 1px solid #d7dde8;
  border-radius: 12px;

  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);

  overflow: hidden;

  z-index: 3000;
}

.chat-options-menu.hidden {
  display: none;
}

.chat-options-menu button {
  width: 100%;

  border: none;
  background: white;
  color: #111827;

  padding: 0.85rem 1rem;

  text-align: left;

  cursor: pointer;

  font-weight: 600;
  font-size: 0.9rem;

  transition: background 0.2s;
}

.chat-options-menu button:hover {
  background: #f3f6fb;
}

.chat-options-menu button.chat-delete-option {
  color: #b91c1c;
}

.chat-options-menu button.chat-delete-option:hover {
  background: #fef2f2;
}

/* =========================
   MODIFICATION: MODALS POUR MÉDIAS, LIENS ET RECHERCHE
   Ces modals réutilisent une structure commune.
========================= */
.chat-content-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 1rem;
  box-sizing: border-box;
}

.chat-content-modal.hidden {
  display: none;
}

.chat-content-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(11, 40, 80, 0.45);

  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.chat-content-box {
  position: relative;
  z-index: 1;

  width: min(92vw, 760px);
  max-height: 88vh;

  background: white;
  border-radius: 18px;

  display: flex;
  flex-direction: column;

  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.3);

  overflow: hidden;

  animation: modalPop 0.2s ease;
}

.chat-content-header {
  padding: 1rem 1.2rem;

  border-bottom: 1px solid #e5e9f0;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;

  background: #f8fafc;
}

.chat-content-header h2 {
  margin: 0;

  color: #0b2850;
  font-size: 1.25rem;
}

.chat-content-close {
  width: 36px;
  height: 36px;

  border: none;
  border-radius: 50%;

  background: #eef2f7;
  color: #0b2850;

  font-size: 1.6rem;
  line-height: 1;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition:
    background 0.2s,
    transform 0.2s;
}

.chat-content-close:hover {
  background: #ef4444;
  color: white;
  transform: scale(1.05);
}

.chat-content-list {
  padding: 1rem;
  overflow-y: auto;
  min-height: 160px;
}

/* =========================
   MODIFICATION: AFFICHAGE DES MÉDIAS ET FICHIERS
   Les images sont affichées en grille, les fichiers en cartes.
========================= */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.9rem;
}

.media-item {
  border: 1px solid #e5e9f0;
  border-radius: 12px;

  background: #f8fafc;

  padding: 0.7rem;

  overflow: hidden;
}

.media-item img {
  width: 100%;
  height: 130px;

  object-fit: cover;

  border-radius: 10px;

  display: block;
  margin-bottom: 0.55rem;
}

.media-item a {
  color: #0b2850;
  font-weight: 700;
  text-decoration: none;

  word-break: break-word;
}

.media-item a:hover {
  text-decoration: underline;
}

.file-item {
  border: 1px solid #e5e9f0;
  border-radius: 12px;

  background: #f8fafc;

  padding: 0.9rem;

  margin-bottom: 0.75rem;

  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.file-icon {
  width: 42px;
  height: 42px;

  border-radius: 10px;

  background: #eaf3ff;
  color: #0b2850;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 1.3rem;

  flex-shrink: 0;
}

.file-details {
  min-width: 0;
}

.file-details a {
  color: #0b2850;
  font-weight: 700;
  text-decoration: none;

  word-break: break-word;
}

.file-details a:hover {
  text-decoration: underline;
}

.file-details small {
  display: block;
  margin-top: 0.2rem;

  color: #6b7280;
}

/* =========================
   MODIFICATION: AFFICHAGE DES LIENS PARTAGÉS
========================= */
.link-item {
  border: 1px solid #e5e9f0;
  border-radius: 12px;

  background: #f8fafc;

  padding: 0.9rem;

  margin-bottom: 0.75rem;
}

.link-item a {
  color: #0b2850;
  font-weight: 700;

  word-break: break-all;
}

.link-item small {
  display: block;
  margin-top: 0.35rem;

  color: #6b7280;
}

/* =========================
   MODIFICATION: RECHERCHE DANS LA CONVERSATION
========================= */
.message-search-box {
  padding: 1rem;
  border-bottom: 1px solid #e5e9f0;
}

.message-search-box input {
  width: 100%;

  box-sizing: border-box;

  border: 1px solid #cfd7e3;
  border-radius: 10px;

  padding: 0.8rem 0.9rem;

  font-size: 0.95rem;
  outline: none;

  transition:
    border 0.2s,
    box-shadow 0.2s;
}

.message-search-box input:focus {
  border-color: #0b2850;
  box-shadow: 0 0 0 4px rgba(11, 40, 80, 0.1);
}

.search-result-item {
  border: 1px solid #e5e9f0;
  border-radius: 12px;

  background: #f8fafc;

  padding: 0.9rem;

  margin-bottom: 0.75rem;
}

.search-result-text {
  margin: 0 0 0.4rem;

  color: #111827;

  white-space: pre-wrap;
  word-break: break-word;
}

.search-result-meta {
  color: #6b7280;
  font-size: 0.8rem;
}

.search-highlight {
  background: #fff7d6;
  color: #92400e;
  border-radius: 4px;
  padding: 0 0.15rem;
  font-weight: 800;
}

/* =========================
   MODIFICATION: RÉSULTAT DE RECHERCHE DANS CONTACTS
   Cette classe sera utilisée quand un contact correspond grâce à un message trouvé.
========================= */
.contact-match-hint {
  display: block;

  margin-top: 0.2rem;

  color: inherit;
  opacity: 0.8;

  font-size: 0.78rem;
  font-style: italic;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================
   MODIFICATION: RESPONSIVE DU MENU ET DES MODALS CHAT
========================= */
@media (max-width: 760px) {
  .chat-options-menu {
    right: 0;
    width: 215px;
  }

  .chat-options-btn {
    width: 36px;
    height: 36px;
  }

  .chat-content-box {
    width: 96vw;
    max-height: 90vh;
  }

  .chat-content-header h2 {
    font-size: 1.05rem;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .media-item img {
    height: 115px;
  }
}

/* =========================
   MODIFICATION: BOUTON EMOJI DANS LE CHAT
   Le bouton emoji est placé entre la pièce jointe et le champ de message.
========================= */
.emoji-wrapper {
  position: relative;
  display: grid;
  place-items: center;
}

.emoji-btn {
  width: 46px;
  height: 100%;

  border: 1px solid #cfd7e3;
  background: white;
  color: #0b2850;

  border-radius: 8px;

  cursor: pointer;

  display: grid;
  place-items: center;

  font-size: 1.25rem;

  transition:
    background 0.2s,
    transform 0.2s,
    border 0.2s;
}

.emoji-btn:hover {
  background: #eef2f7;
  border-color: #0b2850;
  transform: translateY(-2px);
}

/* =========================
   MODIFICATION: PICKER EMOJI
   Petite boîte qui s'ouvre au-dessus du formulaire.
========================= */
.emoji-picker {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);

  width: 260px;

  background: white;
  border: 1px solid #d7dde8;
  border-radius: 14px;

  padding: 0.7rem;

  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;

  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);

  z-index: 3500;
}

.emoji-picker.hidden {
  display: none;
}

.emoji-option {
  width: 34px;
  height: 34px;

  border: none;
  border-radius: 8px;

  background: #f8fafc;

  cursor: pointer;

  font-size: 1.15rem;

  display: flex;
  align-items: center;
  justify-content: center;

  transition:
    background 0.2s,
    transform 0.2s;
}

.emoji-option:hover {
  background: #eaf3ff;
  transform: scale(1.12);
}

/* =========================
   MODIFICATION: état désactivé du bouton emoji
   Quand la Lernpartnerschaft est terminée, le bouton emoji est aussi désactivé.
========================= */
.message-form.disabled .emoji-btn {
  cursor: not-allowed;
  opacity: 0.6;
  background: #e5e7eb;
}

.emoji-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background: #e5e7eb;
}

/* =========================
   MODIFICATION: responsive du formulaire avec emoji
========================= */
@media (max-width: 760px) {
  .message-form {
    grid-template-columns: 42px 42px 1fr 78px;
    gap: 0.45rem;
    padding: 0.75rem;
  }

  .emoji-btn {
    width: 42px;
  }

  .emoji-picker {
    width: 230px;
    grid-template-columns: repeat(6, 1fr);
    left: -52px;
  }

  .emoji-option {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }
}

@media (max-width: 420px) {
  .message-form {
    grid-template-columns: 40px 40px 1fr 68px;
  }

  .emoji-picker {
    width: 210px;
    left: -48px;
  }
}

/* =========================
   MODIFICATION: BOUTON ET MODAL DE CRÉATION DE LERNGRUPPE
   Ces styles ajoutent la première version des groupes sans modifier le layout du chat privé.
========================= */
.new-group-btn {
  width: 44px;
  min-width: 44px;
  border: none;
  border-radius: 10px;
  background: #0b2850;
  color: white;
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 0.2s,
    transform 0.2s;
}

.new-group-btn:hover {
  background: #17457f;
  transform: translateY(-2px);
}

.group-modal-box {
  width: min(92vw, 560px);
}

.group-form {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.group-form label {
  font-weight: 800;
  color: #0b2850;
}

.group-form input[type="text"] {
  border: 1px solid #cfd7e3;
  border-radius: 10px;
  padding: 0.85rem 0.9rem;
  font-size: 1rem;
  outline: none;
}

.group-form input[type="text"]:focus {
  border-color: #0b2850;
  box-shadow: 0 0 0 3px rgba(11, 40, 80, 0.12);
}

/* =========================
   PHOTO DE LA LERNGRUPPE
========================= */

.group-photo-field {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.group-photo-label {
  font-weight: 800;
  color: #0b2850;
}

.group-photo-picker {
  display: flex;
  align-items: center;
  gap: 1rem;

  padding: 0.9rem;
  border: 1px solid #e5e9f0;
  border-radius: 12px;
  background: #f8fafc;
}

.group-photo-preview {
  width: 76px;
  height: 76px;
  flex: 0 0 76px;

  border-radius: 50%;
  object-fit: cover;

  border: 2px solid #dbe5f2;
  background: #e0ecff;
}

.group-photo-actions {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.45rem;
}

.group-photo-select-btn,
.group-photo-remove-btn {
  border: 0;
  border-radius: 9px;
  padding: 0.6rem 0.8rem;

  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.group-photo-select-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 150px;
  padding: 0.7rem 1rem;

  background: #0b2850;
  color: white;

  border: 1px solid #0b2850;
  border-radius: 9px;

  font-weight: 700;
  cursor: pointer;

  box-sizing: border-box;
}

.group-form .group-photo-select-btn {
  color: white;
}

.group-photo-select-btn:hover {
  background: #17457f;
  border-color: #17457f;
}

.group-photo-remove-btn {
  background: #fee2e2;
  color: #991b1b;
}

.group-photo-actions small {
  color: #6b7280;
  line-height: 1.35;
}

.group-photo-error {
  margin: 0;
  color: #b91c1c;
  font-size: 0.9rem;
  font-weight: 700;
}

.group-photo-error.hidden,
.group-photo-remove-btn.hidden {
  display: none;
}

@media (max-width: 480px) {
  .group-photo-picker {
    align-items: flex-start;
  }

  .group-photo-preview {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
  }
}

.group-members-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #374151;
}

.group-members-header span {
  font-size: 0.85rem;
  color: #6b7280;
  white-space: nowrap;
}

.accepted-partners-list {
  max-height: 310px;
  overflow-y: auto;
  border: 1px solid #e5e9f0;
  border-radius: 12px;
  background: #f8fafc;
}

.accepted-partner-option {
  display: grid;
  grid-template-columns: 24px 44px 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid #e5e9f0;
  cursor: pointer;
}

.accepted-partner-option:last-child {
  border-bottom: none;
}

.accepted-partner-option:hover {
  background: #eef2f7;
}

.accepted-partner-option input {
  width: 18px;
  height: 18px;
  accent-color: #0b2850;
}

.accepted-partner-option img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.accepted-partner-name {
  margin: 0;
  font-weight: 800;
  color: #111827;
}

.accepted-partner-meta {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: #6b7280;
}

.create-group-btn {
  background: #0b2850;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-weight: 800;
  cursor: pointer;
}

.create-group-btn:hover {
  background: #17457f;
}

.create-group-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.contact-avatar.group-avatar {
  background: #e0ecff;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.group-member-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.6rem;
}

.group-member-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
}

.group-member-item img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.message-sender-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: #0b2850;
  margin: 0 0 0.25rem;
}

@media (max-width: 760px) {
  .contact-search-row {
    gap: 0.55rem;
  }

  .new-group-btn {
    width: 42px;
    min-width: 42px;
  }
}

/* =========================
   MODIFICATION: PROFIL D'UN MEMBRE DE GROUPE
   Cette partie stylise la modal qui affiche les informations détaillées d'un membre.
========================= */
.group-member-profile-box {
  width: min(92vw, 620px);
}

.group-member-profile-content {
  padding: 1.2rem;
  overflow-y: auto;
}

.group-member-profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.group-member-profile-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e5e9f0;
  flex-shrink: 0;
}

.group-member-profile-title h3 {
  margin: 0;
  color: #0b2850;
  font-size: 1.25rem;
}

.group-member-profile-title p {
  margin: 0.25rem 0 0;
  color: #6b7280;
  word-break: break-word;
}

.group-member-profile-info {
  display: grid;
  gap: 0.65rem;
}

.group-member-profile-info p {
  margin: 0;
  line-height: 1.45;
}

.group-member-profile-info strong {
  color: #0b2850;
}

.group-member-courses {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.group-member-course-tag {
  background: #eaf3ff;
  color: #0b2850;
  border: 1px solid #bfd8ff;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.group-member-actions {
  margin-top: 1.2rem;
  display: flex;
  justify-content: flex-end;
}

.group-member-profile-btn {
  border: none;
  border-radius: 999px;
  background: #0b2850;
  color: white;
  padding: 0.45rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.group-member-profile-btn:hover {
  background: #17457f;
}

.group-member-item {
  justify-content: space-between;
  gap: 0.7rem;
}

.group-member-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.group-member-main span {
  word-break: break-word;
}

@media (max-width: 760px) {
  .group-member-profile-header {
    flex-direction: column;
    text-align: center;
  }

  .group-member-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .group-member-main {
    width: 100%;
  }

  .group-member-profile-btn {
    width: 100%;
  }
}

/* =========================
   MODIFICATION: bouton de demande de Lernpartnerschaft
   Ce bouton est affiché dans le profil d'un membre de groupe.
========================= */
.group-member-partner-btn {
  border: none;
  border-radius: 10px;
  background: #0b2850;
  color: white;
  padding: 0.75rem 1rem;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  transition:
    background 0.2s,
    transform 0.2s;
}

.group-member-partner-btn:hover:not(:disabled) {
  background: #17457f;
  transform: translateY(-1px);
}

.group-member-partner-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.85;
}

.group-member-partner-note {
  margin: 0.75rem 0 0;
  color: #6b7280;
  font-size: 0.85rem;
  text-align: center;
}

/* =========================
   MODIFICATION: GESTION DES PARTICIPANTS D'UN GROUPE
   Ces styles concernent uniquement la modal utilisée par les admins.
========================= */
.manage-group-members-box {
  width: min(92vw, 560px);
}

.manage-group-members-description {
  margin: 0;
  color: #6b7280;
  line-height: 1.45;
}

.group-management-actions {
  margin-top: 1rem;
}

.manage-group-members-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: #0b2850;
  color: white;
  padding: 0.75rem 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
}

.manage-group-members-btn:hover {
  background: #17457f;
  transform: translateY(-1px);
}

/* =========================
   MODIFICATION: boutons de gestion des membres d'un groupe
   Le bouton supprimer est visible uniquement pour les admins.
========================= */
.group-member-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.remove-group-member-btn {
  border: none;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  padding: 0.45rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.2s,
    transform 0.2s;
}

.remove-group-member-btn:hover {
  background: #fecaca;
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  .group-member-buttons {
    width: 100%;
    justify-content: stretch;
  }

  .group-member-buttons button {
    flex: 1;
  }
}

/* =========================
   MODIFICATION: MEMBRES RETIRÉS D'UN GROUPE
   Cette zone permet à l'admin de réintégrer un ancien membre.
========================= */
.removed-members-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.removed-member-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid #e5e9f0;
}

.removed-member-option:last-child {
  border-bottom: none;
}

.removed-member-option img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.removed-member-info {
  flex: 1;
  min-width: 0;
}

.removed-member-name {
  margin: 0;
  color: #111827;
  font-weight: 800;
}

.removed-member-meta {
  margin: 0.15rem 0 0;
  color: #6b7280;
  font-size: 0.82rem;
}

.restore-group-member-btn {
  border: none;
  border-radius: 999px;
  background: #d8f8df;
  color: #15803d;
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.restore-group-member-btn:hover {
  background: #bbf7d0;
}

/* =========================
   MODIFICATION: MODAL INFORMATIONS CONTACT ET GROUPE
   Cette modal permet d'accéder au panneau droit depuis le téléphone.
========================= */
.chat-info-modal-box {
  width: min(94vw, 580px);
}

.chat-info-content {
  padding: 1.1rem;
}

.chat-info-profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e9f0;
}

.chat-info-profile-photo {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid #e5e9f0;
}

.chat-info-profile-header h3,
.chat-info-group-summary h3 {
  margin: 0;
  color: #0b2850;
}

.chat-info-profile-header p,
.chat-info-group-summary p {
  margin: 0.3rem 0 0;
  color: #6b7280;
}

.chat-info-details {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.chat-info-details p {
  margin: 0;
  line-height: 1.45;
}

.chat-info-details strong {
  color: #0b2850;
}

.chat-info-group-summary {
  padding-bottom: 0.9rem;
  border-bottom: 1px solid #e5e9f0;
}

.chat-info-members-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.chat-info-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #e5e9f0;
  border-radius: 12px;
  background: #f8fafc;
}

.chat-info-member-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.chat-info-member-main img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
}

.chat-info-member-main div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-info-member-main strong {
  color: #111827;
  word-break: break-word;
}

.chat-info-member-main span {
  color: #15803d;
  font-size: 0.78rem;
  font-weight: 800;
  margin-top: 0.15rem;
}

.chat-info-member-profile-btn,
.chat-info-group-management-btn {
  border: none;
  border-radius: 999px;
  background: #0b2850;
  color: white;
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.chat-info-group-management-btn {
  width: 100%;
  margin-top: 1rem;
  border-radius: 10px;
  padding: 0.8rem;
}

.chat-info-removed-message {
  padding: 1rem;
  border-radius: 12px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.chat-info-removed-message h3,
.chat-info-removed-message p {
  margin: 0;
}

.chat-info-removed-message p {
  margin-top: 0.5rem;
  line-height: 1.5;
}

.profile-photo.has-group-photo {
  cursor: zoom-in;
}

@media (max-width: 760px) {
  .chat-info-modal-box {
    width: 96vw;
    max-height: 90vh;
  }

  .chat-info-member-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-info-member-main {
    width: 100%;
  }

  .chat-info-member-profile-btn {
    width: 100%;
  }
}

/* =========================
   MODIFICATION: styles pour quitter une Lerngruppe
========================= */
.leave-group-modal-box {
  width: min(92vw, 480px);
}

.leave-group-modal-content {
  padding: 1.2rem;
}

.leave-group-modal-content > p {
  margin: 0;
  color: #374151;
  line-height: 1.5;
}

#leaveGroupAdminTransferSection {
  display: grid;
  gap: 0.55rem;
  margin-top: 1.1rem;
  padding: 0.9rem;
  border: 1px solid #fde68a;
  border-radius: 10px;
  background: #fffbeb;
}

#leaveGroupAdminTransferSection.hidden {
  display: none;
}

#leaveGroupAdminTransferSection label {
  color: #92400e;
  font-weight: 800;
}

#newGroupAdminSelect {
  width: 100%;
  padding: 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  font: inherit;
}

.leave-group-admin-hint {
  margin: 0;
  color: #92400e;
  font-size: 0.85rem;
  line-height: 1.4;
}

.leave-group-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.leave-group-cancel-btn,
.leave-group-confirm-btn,
.leave-group-btn,
.chat-info-leave-group-btn {
  border: none;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.leave-group-cancel-btn {
  background: #e5e7eb;
  color: #374151;
}

.leave-group-confirm-btn,
.leave-group-btn,
.chat-info-leave-group-btn {
  background: #b91c1c;
  color: white;
}

.leave-group-confirm-btn:hover,
.leave-group-btn:hover,
.chat-info-leave-group-btn:hover {
  background: #991b1b;
}

.chat-info-group-actions {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.leave-group-btn {
  width: 100%;
  margin-top: 0.7rem;
}

.chat-info-leave-group-btn {
  width: 100%;
}

@media (max-width: 760px) {
  .leave-group-modal-actions {
    flex-direction: column-reverse;
  }

  .leave-group-cancel-btn,
  .leave-group-confirm-btn {
    width: 100%;
  }
}

/* =========================
   MODIFICATION: erreur affichée directement dans "Gruppe verlassen"
========================= */
.leave-group-error {
  margin: 1rem 0 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 700;
  line-height: 1.4;
}

.leave-group-error.hidden {
  display: none;
}

/* =========================
   MODIFICATION: la modal Gruppe verlassen passe devant les autres modales de contenu
========================= */
#leaveGroupModal {
  z-index: 12500;
}

/* =========================
   MODIFICATION : boutons d'action des membres dans la modal mobile.
   Le bouton rouge permet aux admins de retirer un membre.
========================= */
.chat-info-member-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.chat-info-remove-member-btn {
  border: none;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.chat-info-remove-member-btn:hover {
  background: #fecaca;
}

@media (max-width: 760px) {
  .chat-info-member-buttons {
    width: 100%;
    flex-direction: column;
  }

  .chat-info-member-buttons button {
    width: 100%;
  }
}

/* =========================
   MODIFICATION : bouton et liste des archives privées.
========================= */
.archived-chats-btn {
  width: 44px;
  min-width: 44px;
  border: none;
  border-radius: 10px;
  background: #eef2f7;
  color: #0b2850;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 0.2s,
    transform 0.2s;
}

.archived-chats-btn:hover {
  background: #dbeafe;
  transform: translateY(-2px);
}

.archived-chats-modal-box {
  width: min(92vw, 620px);
}

.archived-chat-item {
  width: 100%;
  border: 1px solid #e5e9f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.9rem;
  margin-bottom: 0.75rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: #111827;
}

.archived-chat-item:hover {
  background: #eef2f7;
}

.archived-chat-title {
  margin: 0;
  color: #0b2850;
  font-size: 1rem;
  font-weight: 800;
}

.archived-chat-meta {
  margin: 0.35rem 0 0;
  color: #6b7280;
  font-size: 0.85rem;
}

.archived-chat-status {
  display: inline-block;
  margin-top: 0.55rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.archived-chat-status.ready {
  background: #d8f8df;
  color: #15803d;
}

.archived-chat-status.pending {
  background: #fff7ed;
  color: #9a3412;
}

@media (max-width: 760px) {
  .archived-chats-btn {
    width: 42px;
    min-width: 42px;
  }
}

/* =========================
   VISIONNEUSE DES IMAGES DU CHAT
========================= */

.chat-image,
.media-item img {
  cursor: zoom-in;
}

.chat-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 20000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 4rem 1.5rem 1.5rem;
  box-sizing: border-box;
}

.chat-image-viewer.hidden {
  display: none;
}

.chat-image-viewer-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(0, 0, 0, 0.88);

  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.chat-image-viewer-image {
  position: relative;
  z-index: 1;

  display: block;

  max-width: min(94vw, 1400px);
  max-height: 88vh;

  object-fit: contain;
  border-radius: 10px;

  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.5);
}

.chat-image-viewer-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 2;

  width: 48px;
  height: 48px;

  display: grid;
  place-items: center;

  padding: 0;
  border: 0;
  border-radius: 50%;

  background: rgba(255, 255, 255, 0.15);
  color: white;

  font-size: 2.2rem;
  line-height: 1;

  cursor: pointer;
}

.chat-image-viewer-close:hover,
.chat-image-viewer-close:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  outline: 2px solid white;
  outline-offset: 2px;
}

body.chat-image-viewer-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .chat-image-viewer {
    padding: 4.5rem 0.75rem 1rem;
  }

  .chat-image-viewer-image {
    max-width: 96vw;
    max-height: 84vh;
  }

  .chat-image-viewer-close {
    top: 0.75rem;
    right: 0.75rem;
  }
}
/* =========================
   FINITIONS CHAT : recherche cliquable, suppression personnelle,
   transfert de messages et compteur dans les archives.
========================= */
.contact-match-hint {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.contact-match-hint:hover,
.contact-match-hint:focus-visible {
  text-decoration: underline;
  outline: none;
}

.search-result-item.search-result-jump {
  width: 100%;
  display: block;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.search-result-item.search-result-jump:hover,
.search-result-item.search-result-jump:focus-visible {
  background: #eef2f7;
  border-color: #bfd8ff;
  outline: none;
}

.search-result-item .search-result-text,
.search-result-item .search-result-meta,
.search-result-file {
  display: block;
}

.search-result-file {
  margin-top: 0.35rem;
  color: #0b2850;
  font-size: 0.86rem;
  font-weight: 700;
  word-break: break-word;
}

.message-forwarded-label {
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-style: italic;
  opacity: 0.72;
}

.message-row.message-jump-highlight .message-bubble {
  animation: messageJumpPulse 2.2s ease;
}

@keyframes messageJumpPulse {
  0%, 100% {
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.08);
  }
  25%, 65% {
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.28), 0 8px 20px rgba(0, 0, 0, 0.12);
  }
}

.archived-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.forward-message-modal-box {
  width: min(92vw, 620px);
}

.forward-message-content {
  padding: 1rem;
  overflow-y: auto;
}

.forward-message-preview {
  padding: 0.9rem;
  border: 1px solid #d7dde8;
  border-radius: 12px;
  background: #f8fafc;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}

.forward-message-label {
  margin: 1rem 0 0.55rem;
  color: #0b2850;
  font-weight: 800;
}

.forward-message-chats-list {
  display: grid;
  gap: 0.6rem;
  max-height: 48vh;
  overflow-y: auto;
}

.forward-chat-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid #e5e9f0;
  border-radius: 12px;
  background: white;
  padding: 0.75rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.forward-chat-option:hover:not(:disabled),
.forward-chat-option:focus-visible:not(:disabled) {
  background: #eef2f7;
  border-color: #bfd8ff;
  outline: none;
}

.forward-chat-option:disabled {
  opacity: 0.6;
  cursor: wait;
}

.forward-chat-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #e0ecff;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.forward-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.forward-chat-details {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.forward-chat-details strong,
.forward-chat-details span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forward-chat-details strong {
  color: #111827;
}

.forward-chat-details span {
  margin-top: 0.15rem;
  color: #6b7280;
  font-size: 0.8rem;
}

.message-actions {
  flex-wrap: wrap;
}

/* =========================
   MODIFICATION : panneau droit moderne pour les Lerngruppen
   Ces styles sont limités au panneau de groupe et ne changent pas
   l'affichage du profil d'un chat privé.
========================= */
.group-profile-panel {
  padding: 1.6rem 1.35rem 1.8rem;
  background: #ffffff;
  scrollbar-width: thin;
  scrollbar-color: #c7d0dc transparent;
}

.group-profile-panel .profile-photo {
  width: 124px;
  height: 124px;
  margin: 0 auto 1rem;
  border: 4px solid #f1f5f9;
  box-shadow: 0 10px 26px rgba(11, 40, 80, 0.12);
}

.group-profile-panel .profile-photo.group-photo-placeholder {
  background: #eef4fb;
}

.group-profile-panel > h2,
.group-profile-panel .profile-name {
  margin: 0;
  color: #0b2850;
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 800;
  text-align: left;
  overflow-wrap: break-word;
}

.group-profile-panel .profile-info {
  margin-top: 1.15rem;
}

.group-panel-divider {
  height: 1px;
  margin: 1.05rem 0;
  background: #dfe5ee;
}

.group-info-list {
  display: grid;
  gap: 0.85rem;
}

.group-info-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 0.85rem;
}

.group-info-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #eef4fb;
  color: #0b2850;
  font-size: 1.2rem;
  font-weight: 800;
}

.group-info-icon.members {
  color: #1f79d0;
}

.group-info-icon.status {
  background: #e9f8ed;
  color: #16a34a;
  font-size: 1.35rem;
}

.group-info-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.group-info-label {
  color: #738095;
  font-size: 0.86rem;
  font-weight: 600;
}

.group-info-text strong {
  color: #10284f;
  font-size: 1.05rem;
  line-height: 1.25;
}

.group-members-section {
  min-width: 0;
}

.group-members-title {
  margin: 0 0 0.8rem;
  color: #10284f;
  font-size: 1.35rem;
  line-height: 1.2;
}

.group-profile-panel .group-member-list {
  gap: 0.7rem;
  margin-top: 0;
}

.group-profile-panel .group-member-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.7rem 0.75rem;
  border: 1px solid #dfe6f0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(15, 35, 69, 0.04);
}

.group-profile-panel .group-member-main {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.group-profile-panel .group-member-avatar,
.group-profile-panel .group-member-item img {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #eef2f7;
}

.group-member-identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
}

.group-member-name {
  display: block;
  width: 100%;
  min-width: 0;
  color: #162b4d;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}

.group-admin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0.15rem 0.48rem;
  border-radius: 999px;
  background: #e6f0ff;
  color: #245a9b;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.group-profile-panel .group-member-buttons {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.group-profile-panel .group-member-profile-btn,
.group-profile-panel .remove-group-member-btn {
  min-height: 36px;
  padding: 0.48rem 0.68rem;
  border-radius: 10px;
  font-size: 0.74rem;
  line-height: 1;
  white-space: nowrap;
}

.group-profile-panel .group-member-profile-btn {
  background: #0b2850;
  box-shadow: 0 3px 8px rgba(11, 40, 80, 0.12);
}

.group-profile-panel .remove-group-member-btn {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}

.group-profile-panel .group-management-actions {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.15rem;
}

.group-profile-panel .manage-group-members-btn,
.group-profile-panel .leave-group-btn {
  width: 100%;
  min-height: 52px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border-radius: 13px;
  padding: 0.85rem 1rem;
  font-size: 0.98rem;
  font-weight: 800;
  transition:
    background 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
}

.group-profile-panel .manage-group-members-btn {
  background: #0b2850;
  box-shadow: 0 5px 14px rgba(11, 40, 80, 0.14);
}

.group-profile-panel .manage-group-members-btn:hover {
  background: #17457f;
  transform: translateY(-1px);
}

.group-profile-panel .leave-group-btn {
  background: #c91f25;
  box-shadow: 0 5px 14px rgba(185, 28, 28, 0.12);
}

.group-profile-panel .leave-group-btn:hover {
  background: #aa171c;
  transform: translateY(-1px);
}

.group-main-action-icon {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  font-size: 1.05rem;
}

@media (max-width: 1280px) and (min-width: 1151px) {
  .chat-page {
    grid-template-columns: var(--contacts-width, 330px) 6px 1fr 390px;
  }

  .group-profile-panel {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .group-profile-panel .group-member-profile-btn,
  .group-profile-panel .remove-group-member-btn {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    font-size: 0.71rem;
  }
}


/* =========================
   SÉCURITÉ : blocage et déblocage d'un utilisateur.
   Les actions restent discrètes dans les panneaux d'information et les profils.
========================= */
.private-chat-safety {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e9f0;
  display: grid;
  gap: 0.65rem;
}

.private-chat-safety-label {
  color: #6b7280;
  font-size: 0.82rem;
  font-weight: 700;
}

.private-chat-report-btn,
.group-member-report-btn {
  width: 100%;
}

.private-chat-block-btn,
.group-member-block-btn {
  width: 100%;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff1f2;
  color: #b91c1c;
  padding: 0.72rem 0.9rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
}

.private-chat-block-btn:hover,
.group-member-block-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  transform: translateY(-1px);
}

.private-chat-unblock-btn,
.group-member-block-btn.private-chat-unblock-btn {
  border-color: #bfd8ff;
  background: #eef4fb;
  color: #0b2850;
}

.private-chat-unblock-btn:hover,
.group-member-block-btn.private-chat-unblock-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.chat-info-safety {
  margin-top: 1.2rem;
}

.group-member-actions {
  display: grid;
  gap: 0.75rem;
}

.group-member-safety-action {
  padding-top: 0.75rem;
  border-top: 1px solid #e5e9f0;
  display: grid;
  gap: 0.65rem;
}

@media (max-width: 760px) {
  .private-chat-block-btn,
  .group-member-block-btn {
    width: 100%;
  }
}

/* =========================
   CHAT COMPOSER
========================= */
.message-form {
  grid-template-columns: 48px 48px minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.55rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.attach-btn,
.emoji-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border: 1px solid #d6deea;
  border-radius: 12px;
  background: #ffffff;
  color: #53657a;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 35, 69, 0.04);
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.attach-btn:hover,
.emoji-btn:hover {
  color: #0b2850;
  background: #f8fbff;
  border-color: #9fb3cc;
  box-shadow: 0 5px 14px rgba(11, 40, 80, 0.08);
  transform: translateY(-1px);
}

.attach-btn:focus-visible,
.emoji-btn:focus-visible,
.send-btn:focus-visible {
  outline: 3px solid rgba(31, 121, 208, 0.2);
  outline-offset: 2px;
}

.composer-icon,
.send-icon {
  display: block;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-icon {
  width: 22px;
  height: 22px;
}

.emoji-wrapper {
  height: 48px;
}

.message-form textarea {
  width: 100%;
  min-height: 48px;
  max-height: 130px;
  padding: 0.72rem 1rem;
  border: 1px solid #d6deea;
  border-radius: 14px;
  background: #ffffff;
  color: #1f2937;
  box-shadow: inset 0 1px 2px rgba(15, 35, 69, 0.025);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.message-form textarea::placeholder {
  color: #8a97a8;
}

.message-form textarea:focus {
  border-color: #6f91b8;
  box-shadow: 0 0 0 4px rgba(11, 40, 80, 0.08);
  background: #ffffff;
}

.send-btn {
  min-width: 112px;
  min-height: 48px;
  padding: 0 1.1rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #0b2850;
  color: #ffffff;
  box-shadow: 0 5px 14px rgba(11, 40, 80, 0.14);
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.send-btn:hover:not(:disabled) {
  background: #163b70;
  box-shadow: 0 7px 17px rgba(11, 40, 80, 0.2);
  transform: translateY(-1px);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0);
}

.send-icon {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

.message-form.disabled .attach-btn,
.message-form.disabled .emoji-btn {
  color: #9ca3af;
  background: #e5e7eb;
  box-shadow: none;
  transform: none;
}

@media (max-width: 760px) {
  .message-form {
    grid-template-columns: 44px 44px minmax(0, 1fr) auto;
    gap: 0.4rem;
    padding: 0.65rem;
  }

  .attach-btn,
  .emoji-btn,
  .emoji-wrapper {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .message-form textarea {
    min-height: 44px;
    padding: 0.65rem 0.8rem;
  }

  .send-btn {
    min-width: 86px;
    min-height: 44px;
    padding: 0 0.8rem;
  }
}

@media (max-width: 420px) {
  .message-form {
    grid-template-columns: 40px 40px minmax(0, 1fr) 48px;
  }

  .attach-btn,
  .emoji-btn,
  .emoji-wrapper {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  .message-form textarea {
    min-height: 40px;
  }

  .send-btn {
    width: 48px;
    min-width: 48px;
    min-height: 40px;
    padding: 0;
  }

  .send-btn span {
    display: none;
  }
}

/* =========================
   FIX : alignement du formulaire de message
========================= */

.message-form {
  display: grid;
  grid-template-columns: 48px 48px minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 0.65rem;
}

.message-form textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.message-form .send-btn {
  position: static;
  min-width: 112px;
  height: auto;
  margin: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;

  align-self: stretch;
}

@media (max-width: 760px) {
  .message-form {
    grid-template-columns: 42px 42px minmax(0, 1fr) auto;
    gap: 0.45rem;
  }

  .message-form .send-btn {
    min-width: 82px;
  }
}

@media (max-width: 480px) {
  .message-form .send-btn {
    min-width: 48px;
    padding: 0 0.75rem;
  }

  .message-form .send-btn .send-text {
    display: none;
  }
}
/* =========================
   GRUPPENBILD NACH DER ERSTELLUNG ÄNDERN
========================= */
.edit-group-photo-btn,
.chat-info-edit-group-photo-btn {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd8e7;
  border-radius: 12px;
  background: #f7faff;
  color: #0b2850;
  padding: 0.72rem 0.9rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
}

.edit-group-photo-btn:hover,
.chat-info-edit-group-photo-btn:hover {
  background: #eef4fb;
  border-color: #9fb6d1;
  box-shadow: 0 5px 14px rgba(11, 40, 80, 0.08);
  transform: translateY(-1px);
}

.group-profile-panel .edit-group-photo-btn {
  margin-top: 0.9rem;
}

.edit-group-photo-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edit-group-photo-modal-box {
  width: min(92vw, 520px);
}

.edit-group-photo-content {
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}

.edit-group-photo-preview {
  width: 132px;
  height: 132px;
  margin: 0 auto;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #eef2f7;
  background: #eef4fb;
  box-shadow: 0 10px 26px rgba(11, 40, 80, 0.12);
}

.edit-group-photo-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-align: center;
}

.edit-group-photo-actions .group-photo-select-btn {
  min-width: 190px;
}

.edit-group-photo-actions .group-photo-remove-btn {
  min-width: 190px;
}

.edit-group-photo-actions small {
  color: #6b7280;
  line-height: 1.4;
}

.edit-group-photo-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  padding-top: 0.25rem;
}

.edit-group-photo-footer .create-group-btn,
.edit-group-photo-footer .leave-group-cancel-btn {
  min-width: 145px;
}

.chat-info-group-summary-with-photo {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.chat-info-group-photo {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #eef2f7;
  background: #eef4fb;
}

@media (max-width: 560px) {
  .edit-group-photo-footer {
    flex-direction: column-reverse;
  }

  .edit-group-photo-footer .create-group-btn,
  .edit-group-photo-footer .leave-group-cancel-btn {
    width: 100%;
  }

  .edit-group-photo-preview {
    width: 112px;
    height: 112px;
  }
}

/* =========================
   RÉPONDRE À UN MESSAGE
   Aperçu dans le composer et référence cliquable dans la bulle.
========================= */
.reply-composer-preview {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

.reply-composer-preview.hidden {
  display: none;
}

.reply-composer-accent {
  align-self: stretch;
  min-height: 42px;
  border-radius: 999px;
  background: #1f79d0;
}

.reply-composer-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.reply-composer-content strong {
  color: #0b2850;
  font-size: 0.84rem;
  line-height: 1.2;
}

.reply-composer-content span {
  color: #64748b;
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-composer-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.reply-composer-close:hover,
.reply-composer-close:focus-visible {
  background: #e8eef6;
  color: #0b2850;
  transform: scale(1.04);
  outline: none;
}

.message-reply-reference {
  width: 100%;
  margin: 0 0 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-left: 3px solid #6f91b8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.message-row.sent .message-reply-reference {
  border-left-color: #cfe5fb;
  background: rgba(255, 255, 255, 0.14);
}

.message-reply-reference:hover,
.message-reply-reference:focus-visible {
  background: rgba(255, 255, 255, 0.82);
  transform: translateY(-1px);
  outline: none;
}

.message-row.sent .message-reply-reference:hover,
.message-row.sent .message-reply-reference:focus-visible {
  background: rgba(255, 255, 255, 0.22);
}

.message-reply-author {
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
  color: #0b2850;
}

.message-row.sent .message-reply-author {
  color: #ffffff;
}

.message-reply-preview {
  font-size: 0.8rem;
  line-height: 1.3;
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-action-btn.reply-btn {
  color: #0b2850;
  font-weight: 700;
}

@media (max-width: 760px) {
  .reply-composer-preview {
    padding: 0.6rem 0.7rem;
    grid-template-columns: 4px minmax(0, 1fr) 32px;
    gap: 0.6rem;
  }

  .reply-composer-close {
    width: 32px;
    height: 32px;
  }
}


/* =========================
   SPRACHNACHRICHTEN
   Aufnahme mit Pause/Fortsetzen und kompakter Player mit Replay.
========================= */

.message-form {
  grid-template-columns: 48px 48px minmax(0, 1fr) 48px auto;
}

.voice-record-btn {
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  border: 1px solid #d6deea;
  border-radius: 12px;
  background: #ffffff;
  color: #53657a;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 35, 69, 0.04);
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.voice-record-btn:hover:not(:disabled) {
  color: #0b2850;
  background: #f8fbff;
  border-color: #9fb3cc;
  box-shadow: 0 5px 14px rgba(11, 40, 80, 0.08);
  transform: translateY(-1px);
}

.voice-record-btn:focus-visible {
  outline: 3px solid rgba(31, 121, 208, 0.2);
  outline-offset: 2px;
}

.voice-record-btn:disabled,
.message-form.disabled .voice-record-btn {
  color: #9ca3af;
  background: #e5e7eb;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.message-form.voice-recording-active {
  display: none;
}

.voice-recording-panel {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin: 0.7rem 0.9rem;
  padding: 0.72rem 0.8rem;
  border: 1px solid #dbe3ee;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 7px 20px rgba(15, 35, 69, 0.08);
  flex-shrink: 0;
}

.voice-recording-panel.hidden {
  display: none;
}

.voice-recording-status {
  min-width: 0;
  display: grid;
  grid-template-columns: 10px auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
}

.voice-recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  animation: voiceRecordingPulse 1.15s ease-in-out infinite;
}

.voice-recording-timer {
  min-width: 44px;
  color: #0b2850;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  font-weight: 800;
  text-align: left;
}

.voice-recording-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}

.voice-recording-copy strong {
  color: #0b2850;
  font-size: 0.84rem;
  line-height: 1.2;
}

.voice-recording-copy span {
  color: #7b8798;
  font-size: 0.72rem;
  line-height: 1.2;
}

.voice-recording-waveform {
  height: 34px;
  min-width: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
  color: #68809e;
}

.voice-recording-waveform span {
  width: 3px;
  height: var(--bar-height, 14px);
  flex: 0 0 3px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.72;
  transform-origin: center;
  animation: voiceWavePulse 1s ease-in-out infinite alternate;
}

.voice-recording-waveform span:nth-child(3n + 1) {
  animation-delay: -0.15s;
}

.voice-recording-waveform span:nth-child(3n + 2) {
  animation-delay: -0.45s;
}

.voice-recording-waveform span:nth-child(4n) {
  animation-delay: -0.7s;
}

.voice-recording-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.voice-recording-action {
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.voice-recording-action svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-recording-action:hover:not(:disabled) {
  transform: translateY(-1px);
}

.voice-recording-cancel {
  background: #f3f4f6;
  color: #64748b;
}

.voice-recording-cancel:hover:not(:disabled) {
  background: #e8edf4;
  color: #b91c1c;
}

.voice-recording-pause {
  background: #eef4fb;
  color: #0b2850;
}

.voice-recording-pause:hover:not(:disabled) {
  background: #dce9f8;
}

.voice-recording-send {
  background: #0b2850;
  color: white;
  box-shadow: 0 4px 10px rgba(11, 40, 80, 0.14);
}

.voice-recording-send:hover:not(:disabled) {
  background: #163b70;
  box-shadow: 0 6px 14px rgba(11, 40, 80, 0.18);
}

.voice-recording-action:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
}

.voice-recording-panel.paused {
  border-color: #cfd8e5;
  background: #f8fafc;
}

.voice-recording-panel.paused .voice-recording-dot {
  background: #94a3b8;
  animation: none;
}

.voice-recording-panel.paused .voice-recording-waveform span {
  animation-play-state: paused;
  opacity: 0.36;
}

.voice-recording-panel.paused .voice-recording-pause {
  background: #0b2850;
  color: white;
}

.voice-recording-panel.sending .voice-recording-dot,
.voice-recording-panel.sending .voice-recording-waveform span {
  animation: none;
}

.voice-recording-panel.sending .voice-recording-waveform {
  opacity: 0.45;
}

@keyframes voiceRecordingPulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.72);
  }
}

@keyframes voiceWavePulse {
  from {
    transform: scaleY(0.55);
  }

  to {
    transform: scaleY(1);
  }
}

/* Player de Sprachnachricht */
.voice-message-player {
  --voice-progress: 0%;
  min-width: min(315px, 54vw);
  margin-top: 0.3rem;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 0.7rem;
  padding: 0.58rem 0.68rem;
  border-radius: 14px;
  background: rgba(11, 40, 80, 0.075);
}

.message-row.sent .voice-message-player {
  background: rgba(255, 255, 255, 0.14);
}

.voice-message-audio {
  display: none;
}

.voice-message-play {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #0b2850;
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 9px rgba(11, 40, 80, 0.14);
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.message-row.sent .voice-message-play {
  background: white;
  color: #1f79d0;
  box-shadow: none;
}

.voice-message-play:hover {
  transform: scale(1.045);
}

.voice-message-play:focus-visible {
  outline: 3px solid rgba(31, 121, 208, 0.24);
  outline-offset: 2px;
}

.voice-message-play svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.voice-message-player.is-ended .voice-message-play {
  transform: rotate(-2deg);
}

.voice-message-track {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.voice-message-waveform-wrap {
  position: relative;
  height: 34px;
  min-width: 0;
  display: flex;
  align-items: center;
  padding-inline: 1px;
}

.voice-message-waveform {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  color: currentColor;
  opacity: 0.58;
  pointer-events: none;
}

.voice-message-waveform span {
  height: var(--voice-bar-height, 12px);
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.34;
  transform-origin: center;
  transition:
    height 0.2s ease,
    opacity 0.18s ease,
    background 0.18s ease;
}

.voice-message-waveform span.is-played {
  opacity: 0.95;
}

.voice-message-player.is-playing .voice-message-waveform span.is-played {
  opacity: 1;
}

.voice-message-waveform-wrap::after {
  content: "";
  position: absolute;
  left: clamp(4px, var(--voice-progress), calc(100% - 4px));
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}

.voice-message-progress {
  --voice-progress: 0%;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 34px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
}

.voice-message-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  font-size: 0.71rem;
  line-height: 1.2;
  opacity: 0.84;
  font-variant-numeric: tabular-nums;
}

.voice-message-state {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.voice-message-player.is-playing .voice-message-state {
  font-weight: 800;
}

.voice-message-player.is-ended .voice-message-state {
  font-weight: 800;
}

.voice-message-time {
  flex-shrink: 0;
  white-space: nowrap;
}

@keyframes voicePlaybackPulse {
  from {
    transform: scaleY(0.72);
  }

  to {
    transform: scaleY(1);
  }
}

@media (max-width: 760px) {
  .message-form {
    grid-template-columns: 42px 42px minmax(0, 1fr) 42px auto;
  }

  .voice-record-btn {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
  }

  .voice-recording-panel {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.6rem 0.8rem;
    margin: 0.55rem 0.65rem;
    padding: 0.65rem 0.7rem;
  }

  .voice-recording-status {
    grid-column: 1;
  }

  .voice-recording-waveform {
    grid-column: 2;
    min-width: 80px;
  }

  .voice-recording-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .voice-message-player {
    min-width: min(270px, 70vw);
  }
}

@media (max-width: 480px) {
  .message-form {
    grid-template-columns: 40px 40px minmax(0, 1fr) 40px 48px;
  }

  .voice-record-btn {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .voice-recording-panel {
    margin: 0.45rem 0.5rem;
    grid-template-columns: minmax(0, 1fr);
  }

  .voice-recording-status,
  .voice-recording-waveform,
  .voice-recording-actions {
    grid-column: 1;
  }

  .voice-recording-waveform {
    width: 100%;
    justify-content: flex-start;
  }

  .voice-recording-copy span {
    display: none;
  }

  .voice-recording-actions {
    justify-content: space-between;
  }

  .voice-recording-action {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 50%;
  }

  .voice-recording-action span {
    display: none;
  }

  .voice-recording-action svg {
    width: 18px;
    height: 18px;
  }

  .voice-message-player {
    min-width: min(245px, 74vw);
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 0.55rem;
    padding: 0.5rem 0.55rem;
  }

  .voice-message-play {
    width: 40px;
    height: 40px;
  }

  .voice-message-waveform {
    gap: 1.5px;
  }
}

/* Mobile form fields stay at 16px or more so iOS browsers do not
   auto-zoom them. Pinch-to-zoom remains available to the user. */
@media (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="hidden"]),
  textarea:not([data-allow-small-text]),
  select:not([data-allow-small-text]) {
    font-size: 16px;
  }
}


/* =========================
   MOBILE VIEWPORT / WIDTH FIX
   Keep the Chat layout inside the layout viewport. This fixes the horizontal
   expansion that iOS can expose after focusing or closing the keyboard.
========================= */
@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  header,
  .chat-page,
  .contacts-panel,
  .chat-panel,
  .contact-search-row,
  .chat-header,
  .messages,
  .message-form {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .chat-page {
    width: 100%;
  }

  .contact-search-row {
    width: 100%;
  }

  .contact-search {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .contact-search input {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .message-form {
    width: 100%;
  }

  .message-form textarea {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .contact-item,
  .contact-item > div:nth-child(2),
  .contact-match-hint {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Course role details in study-group member profiles. */
.group-member-course-tag {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
  border-radius: 14px;
  line-height: 1.25;
}

.group-member-course-tag small {
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.78;
}
