

:root {
  /* 🎨 Palette claire et apaisante
     Ces variables définissent le thème général (couleurs principales, bulles, textes, etc.)
     → Cela permet de tout modifier facilement sans toucher le reste du code CSS.
  */
  --bg: #f5f7f8;                /* Fond principal très clair */
  --bg-secondary: #ffffff;      /* Éléments secondaires : bandeaux, cartes, entêtes */
  --bg-chat: #f7f9fb;           /* Fond spécifique à la zone de discussion */
  --textb: black;               /* Couleur noire standard pour certains titres/éléments */
  --text: #1f2a33;              /* Texte principal anthracite doux */
  --text-secondary: #5c6b73;    /* Texte secondaire gris bleuté */
  --accent: #6cc2a3;            /* Couleur d’accent (vert sauge clair) */
  --accent-hover: #4fb38e;      /* Variante un peu plus foncée au survol */
  --bubble-sent: #c6f2dd;       /* Couleur des bulles envoyées (vert pâle) */
  --bubble-received: #e7eff2;   /* Couleur des bulles reçues (gris bleuté) */
}

/* ================================
   STYLE GÉNÉRAL DE L’APPLICATION
   ================================ */

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, sans-serif; /* police lisible et moderne */
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 600px;             /* largeur max sur desktop */
  margin: 0 auto;               /* centrage horizontal */
  height: 100vh;                /* occupe toute la hauteur de l’écran */
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ================================
   EN-TÊTE DU CHAT ET DE L’APP
   ================================ */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  padding: 0.7rem 1rem;
  color: var(--text);
}

/* --- Bandeau supérieur général (page principale) --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  padding: 6px 10px;
  border-bottom: 1px solid #333;
  height: 64px;
  position: relative;
  overflow: hidden;
}

.logo {
  height: 70px;
  width: auto;
}

/* --- Slogan sous le logo --- */
.subtitle {
  color: var(--textb);
  font-size: 16px;
  margin-left: 10px;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  transition: opacity 0.2s ease;
}

/* --- Icônes de menu et de recherche --- */
.menu-icon,
.search-toggle {
  color: var(--textb);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
}
.menu-icon:hover,
.search-toggle:hover {
  color: #aaa;
}

/* --- Barre de recherche déroulante --- */
.search-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background-color: #1f1f1f;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  transform: translateY(-100%);
  transition: transform 0.3s ease; /* animation d’apparition fluide */
}

/* --- Quand active : descend en douceur --- */
.search-bar.active {
  transform: translateY(0);
}

.search-bar input {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-size: 15px;
}

.search-bar i {
  color: #aaa;
  font-size: 18px;
}

.close-search {
  cursor: pointer;
}
.close-search:hover {
  color: white;
}

/* ================================
   LISTE DES CONTACTS
   ================================ */

.contacts {
  flex: 1;
  overflow-y: auto; /* scroll vertical si trop de contacts */
}

.contact {
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #222;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease;
}
.contact:hover {
  background: #f0f4f6;
}

.contact img {
  width: 50px;
  height: 50px;
  border-radius: 50%; /* avatar rond */
  margin-right: 1rem;
}

.dynamic-avatar {
  background: orange;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  color: white;          /* plus visible */
  font-weight: bold;
  font-size: 14px;
  display: flex;
  flex-direction: column; /* permet 2 lignes */
  justify-content: center;
  align-items: center;
  text-align: center;
  line-height: 1.1;
}
.dynamic-avatar small {
  font-size: 10px;
  font-weight: 600;
}

.contact .info {
  flex: 1;
  position: relative;
}

.contact .info h3 {
  margin: 0;
  font-size: 1rem;
}

.contact .info p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}


.contact .last-time {
  min-width: 50px; /* ou ce que tu veux */
  text-align: right;
  font-size: 0.8em;
  color: green;
  margin-left: 8px;
}

.side-info {
  margin-left: 8px;
  font-size: 12px;
  color: #888;
  white-space: nowrap;
}

/* ================================
   VUE DU CHAT ACTIF
   ================================ */

#chat-view.hidden {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.chat-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.chat-info h2 {
  margin: 0;
  font-size: 1rem;
}
.chat-info p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chat-messages {
  flex: 1;
  background: var(--bg-chat);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* --- Styles des bulles de message --- */
.message {
  max-width: 75%;
  padding: 0.6rem 1rem;
  margin-bottom: 0.6rem;
  border-radius: 22px;
  word-wrap: break-word;
  line-height: 1.4;
  position: relative;
  font-size: 0.95rem;
}
.sent {
  background: var(--bubble-sent);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.received {
  background: var(--bubble-received);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* --- Zone d’entrée de message --- */
.chat-input {
  display: flex;
  background: var(--bg-secondary);
  padding: 0.6rem;
  align-items: center;
}

.chat-input input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.6rem;
  border-radius: 20px;
  background: var(--bg-chat);
  color: var(--text);
  font-size: 0.95rem;
}

.chat-input button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.4rem;
  margin-left: 0.6rem;
  cursor: pointer;
}

/* ================================
   ÉLÉMENTS GÉNÉRAUX / UTILITAIRES
   ================================ */

.hidden { display: none; }

/* Menu contextuel (3 points) */
.chat-menu {
  position: absolute;
  top: 55px;
  right: 10px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  overflow: hidden;
  z-index: 50;
  width: 180px;
  animation: fadeIn 0.2s ease;
}
.chat-menu.hidden { display: none; }

.menu-btn {
  background: var(--textb);
  border: none;
  color: black;
  font-size: 20px;
  cursor: pointer;
  margin-right: 10px;
  position: relative;
}
.menu-item {
  padding: 12px 15px;
  font-size: 15px;
  color: #222;
  cursor: pointer;
}
.menu-item:hover {
  background-color: #f1f1f1;
}

/* ================================
   ÉLÉMENTS SPÉCIAUX DU CHAT
   ================================ */

/* Date séparatrice entre messages */
.chat-date {
  text-align: center;
  background: #e1f3ff;
  color: #2a2a2a;
  font-size: 0.8rem;
  margin: 2px auto;
  padding: 5px 10px;
  border-radius: 8px;
  display: inline-block;
}

/* Message d’avertissement (ex : contact réel) */
.system-alert {
  background: #fff8e1;
  color: #6b5200;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px auto;
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
  max-width: 85%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  border: 1px solid #ffe082;
}

/* Responsive (mobile) */
@media (max-width: 480px) {
  .system-alert { font-size: 0.8rem; }
}

/* ================================
   ANIMATIONS GLOBALES
   ================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInTooltip {
  to { opacity: 1; }
}

@media (min-width: 700px) {
  #app {
    border: 1px solid #333;
    border-radius: 10px;
  }
}

/* ================================
   BADGES, POPUPS ET QUIZZ
   ================================ */

.menu-item.red { color: red; }

/* --- Badge de notification sur les contacts --- */
.unread-badge {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  height: 20px;
  min-width: 20px;          /* rond pour 1 chiffre */
  padding: 0 6px;           /* s'élargit doucement si 2 ou 3 chiffres */
  background-color: #25d366;
  border-radius: 999px;     /* rond → capsule auto */
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  line-height: 20px;
  text-align: center;
  white-space: nowrap;
  display: none;
  transition: width 0.2s ease, padding 0.2s ease, background-color 0.2s ease;
}

.unread-badge.show {
  display: inline-block;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: translateY(-50%) scale(1); opacity: 1; }
  50% { transform: translateY(-50%) scale(1.3); opacity: 0.85; }
}

/* --- Popup page sombre (simule page modale) --- */
.popup-page {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(20, 20, 20, 0.9);
  color: white;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

.popup-content {
  background: #222;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.popup-content h2 { margin-bottom: 10px; }

.popup-content button {
  margin-top: 15px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: red;
  color: white;
  cursor: pointer;
}



/* ================================
   STYLE DU QUIZZ
   ================================ */

/* Conteneur vertical des réponses */
.quizz-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

/* Boutons principaux du quiz */
.quizz-btn {
  background-color: var(--bubble-sent);
  color: white;
  padding: 10px 14px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 15px;
  text-align: center;
  transition: background 0.25s ease, transform 0.15s ease;
}
.quizz-btn:hover {
  background-color: var(--accent);
  transform: scale(1.05);
}

/* Overlay sombre du quiz */
.quiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

/* Popup principale du quiz */
.quiz-popup {
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: 12px;
  width: 90%;
  max-width: 360px;
  color: var(--textb);
  text-align: center;
  box-shadow: 0 0 15px rgba(0,0,0,0.4);
  animation: quizFadeIn 0.4s ease-out forwards;
}

/* Titre du quiz */
.quiz-popup h2 {
  color: var(--accent);
  margin-bottom: 1rem;
}

/* Boutons de choix de réponse */
.quiz-choice {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--bubble-received);
  color: var(--textb);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.2s ease;
}
.quiz-choice:hover {
  background: var(--accent);
  color: #000;
}

.quiz-questions {
  transition: opacity 0.35s ease;
  opacity: 1;
}

.quiz-questions.fade-out {
  opacity: 0;
  pointer-events: none; /* empêche les clics pendant la transition */
}

.quiz-questions.fade-in {
  opacity: 1;
}

.quiz-choice[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* Animation d’apparition du popup */
@keyframes quizFadeIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* petit badge affichant les crédits a coté du nom */
.credit-badge {
  background: #ffcc00;
  color: black;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 12px;
  font-weight: 600;
  vertical-align: middle;
  display: inline-block;
}

/* ============================================================
   🎉 VERSION PC / DESKTOP (affichage côte à côte + améliorations)
   ============================================================ *//* ==========================
   Desktop override (safe)
   ========================== */
@media (min-width: 1000px) {

  /* Container principal - passe en layout côte-à-côte */
  #app.desktop-layout,
  #app {
    display: flex !important;
    flex-direction: row !important;
    width: min(1100px, 96%) !important;
    height: 92vh !important;
    max-width: none !important;
    border-radius: 14px !important;
    box-shadow: 0 18px 40px rgba(0,0,0,0.12) !important;
    margin: 0 auto !important;
    background: white !important;
    overflow: hidden !important;
  }

  /* Colonne contacts */
  .contacts {
    display: block !important;
    width: 540px !important;       /* largeur fixe (peut être ajustée) */
    min-width: 280px !important;
    max-width: 40% !important;
    border-right: 1px solid #e6e6e6 !important;
    height: 100% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  /* Empêche le script de cacher la colonne contacts */
  .contacts.hidden { display: block !important; visibility: visible !important; }

  /* Zone de chat */
  #chat-view {
    display: flex !important;
    flex-direction: column !important;
    width: calc(100% - 540px) !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-width: 560px !important;
    overflow: hidden !important;
  }
  /* Empêche le script de masquer la zone de chat */
  #chat-view.hidden { display: flex !important; visibility: visible !important; }

  /* Headers / inputs */
  .app-header, .chat-header {
    height: 70px !important;
    padding: 10px 16px !important;
    align-items: center !important;
  }

  .chat-messages {
    padding: 20px !important;
    overflow-y: auto !important;
  }

  .chat-input {
    padding: 12px !important;
  }

  /* Avatars et items */
  .contact img, .dynamic-avatar {
    width: 58px !important;
    height: 58px !important;
  }

  /* Ajustement badges / scrollbars */
  .contacts::-webkit-scrollbar,
  .chat-messages::-webkit-scrollbar {
    width: 10px !important;
  }
  .contacts::-webkit-scrollbar-thumb,
  .chat-messages::-webkit-scrollbar-thumb {
    background: #cfcfcf !important;
    border-radius: 6px !important;
  }

  /* Prévenir un centrage trop petit */
  body {
    align-items: flex-start !important; /* évite que tout soit centré verticalement */
    padding: 20px !important;
    background: #e9edf0 !important;
  }

}
