:root {
  --fond: #000000;         /* fond noir, demandé */
  --surface: #121212;      /* cartes / barres / champs — légèrement soulevé du noir pur */
  --surface-2: #1c1c1c;    /* bulle « l'autre », champs de saisie */
  --ligne: #2a2a2a;        /* séparateurs discrets */
  --texte: #f2f2f2;
  --gris: #9a9a9a;
  --rouge: #d7263d;        /* rouge principal : boutons, bulle « moi » */
  --rouge-clair: #ff6b6b;  /* rouge plus clair : liens/texte sur fond sombre (meilleure lisibilité) */
  --rouge-sombre: #b81f33; /* état pressé/survol */
  --alerte-fond: #1a0a0c;  /* fond des bandeaux d'alerte (rouge très sombre) */
  --alerte-bord: #3a1218;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--texte);
  background: var(--fond);
}

/* ---------------- Connexion ---------------- */
.page-login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: var(--fond);   /* épuré : plus de dégradé, noir plat */
}
.carte-login {
  background: var(--surface); width: 100%; max-width: 360px; padding: 28px 24px 26px;
  border-radius: 16px; border: 1px solid var(--ligne);
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
  display: flex; flex-direction: column;
}
.logo-rond {
  width: 60px; height: 60px; border-radius: 50%; background: var(--surface-2);
  border: 1.5px solid var(--rouge);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 10px;
}
.carte-login h1 { text-align: center; font-size: 20px; margin: 4px 0 2px; color: var(--texte); }
.carte-login .sous { text-align: center; color: var(--gris); font-size: 13px; margin: 0 0 18px; }
.carte-login label { font-size: 13px; font-weight: 600; margin: 12px 0 5px; color: #cfcfcf; }
.carte-login select, .carte-login input {
  padding: 12px; border: 1px solid var(--ligne); border-radius: 10px; font-size: 15px;
  background: var(--surface-2); color: var(--texte);
}
.carte-login select:focus, .carte-login input:focus {
  outline: none; border-color: var(--rouge);
}
.carte-login button {
  margin-top: 20px; padding: 13px; border: 0; border-radius: 10px;
  background: var(--rouge); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.carte-login button:hover { background: var(--rouge-sombre); }
.carte-login button:active { transform: translateY(1px); }
.erreur {
  background: var(--alerte-fond); color: var(--rouge-clair); border: 1px solid var(--alerte-bord);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 6px;
}

/* ---------------- Chat ---------------- */
.page-chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.barre-haut {
  background: var(--surface); color: var(--texte); padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--ligne);
}
.barre-haut .titre { font-weight: 700; font-size: 16px; }
.barre-haut .moi { font-size: 13px; opacity: .95; text-align: right; color: var(--texte); }
.deconnexion { display: block; color: var(--gris); font-size: 11px; text-decoration: none; margin-top: 2px; }

.bandeau-connexion {
  background: var(--alerte-fond); color: var(--rouge-clair); border-bottom: 1px solid var(--alerte-bord);
  padding: 8px 14px; font-size: 12.5px; text-align: center; font-weight: 600;
}

.bandeau-notif {
  background: var(--surface); color: var(--texte); border-bottom: 1px solid var(--ligne);
  padding: 8px 14px; font-size: 12.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
/* Même piège que .overlay-appel : sans ça, "hidden" ne suffit pas à cacher un
   élément qui a sa propre règle "display" — voir la leçon dans style.css plus haut. */
.bandeau-notif[hidden] { display: none; }
.bandeau-notif-boutons { display: flex; gap: 8px; flex-shrink: 0; }
.bandeau-notif button {
  border: 0; border-radius: 14px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
#bouton-activer-notif { background: var(--rouge); color: #fff; }
#bouton-activer-notif:hover { background: var(--rouge-sombre); }
#bouton-ignorer-notif { background: none; color: var(--gris); }
#bouton-ignorer-notif:hover { color: var(--texte); }

.erreur-envoi {
  background: var(--alerte-fond); color: var(--rouge-clair); border-top: 1px solid var(--alerte-bord);
  padding: 8px 14px; font-size: 12.5px; text-align: center;
}

/* Onglets : 2 fils séparés entre les 2 mêmes comptes (discussion / presse-papier). */
.onglets {
  display: flex; background: var(--surface); border-bottom: 1px solid var(--ligne);
}
.onglet {
  flex: 1; padding: 10px 8px; background: none; border: 0; cursor: pointer;
  color: var(--gris); font-size: 13.5px; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.onglet.actif { color: var(--texte); border-bottom-color: var(--rouge); }

.fil {
  flex: 1; overflow-y: auto; padding: 16px 12px 8px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--fond);
}

.bulle {
  max-width: 78%; padding: 8px 12px; border-radius: 14px; position: relative;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.bulle .auteur { font-size: 11px; font-weight: 700; color: var(--rouge-clair); margin-bottom: 2px; }
.bulle .texte { font-size: 15px; line-height: 1.35; white-space: pre-wrap; }
.bulle .heure { font-size: 10px; color: var(--gris); text-align: right; margin-top: 3px; }

.bulle.moi { align-self: flex-end; background: var(--rouge); border-bottom-right-radius: 4px; }
.bulle.autre { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
/* Sur la bulle rouge (mes messages), le texte secondaire clair passe en blanc
   translucide — un rouge sur rouge serait illisible (contraste insuffisant). */
.bulle.moi .heure { color: rgba(255,255,255,.75); }

/* Coche de statut (façon Signal) : de plus en plus visible à mesure que le
   message avance envoyé → reçu → vu, jusqu'au blanc plein pour "vu". */
.statut { letter-spacing: -1px; }
.statut[data-statut="envoye"] { color: rgba(255,255,255,.5); }
.statut[data-statut="recu"] { color: rgba(255,255,255,.75); }
.statut[data-statut="vu"] { color: #fff; }

/* Appel manqué : bulle discrète, façon message système plutôt qu'un vrai message. */
.bulle.appel-manque { opacity: .85; }
.texte-appel-manque { font-size: 14px; font-style: italic; }

/* pièce jointe (fichier) */
.fichier { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.fichier .icone { font-size: 26px; }
.fichier .infos { display: flex; flex-direction: column; }
.fichier .nom { font-size: 14px; font-weight: 600; color: var(--texte); }
.fichier .meta { font-size: 12px; color: var(--gris); }
.fichier .dl { font-size: 12px; color: var(--rouge-clair); font-weight: 600; }
/* Même raison que .heure ci-dessus : sur fond rouge, on repasse en blanc. */
.bulle.moi .fichier .meta { color: rgba(255,255,255,.8); }
.bulle.moi .fichier .dl { color: #fff; text-decoration: underline; }

/* message vocal : le lecteur natif du navigateur, juste ajusté à la largeur
   de la bulle — pas de faux lecteur maison, on garde ça simple et fiable. */
.bulle audio { display: block; width: 220px; max-width: 100%; height: 32px; }

.glisser-info {
  text-align: center; color: var(--gris); font-size: 13px; margin: auto;
  border: 2px dashed var(--ligne); border-radius: 12px; padding: 24px; background: var(--surface);
}
.fil.glisser-actif { outline: 3px dashed var(--rouge); outline-offset: -8px; }

/* barre de progression d'envoi de fichier */
.progress-fichier { padding: 6px 14px; background: var(--surface); border-top: 1px solid var(--ligne); }
.progress-nom { font-size: 12px; color: var(--gris); margin-bottom: 4px; }
.progress-piste { height: 8px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.progress-barre { height: 100%; width: 0; background: var(--rouge); transition: width .15s; }

.barre-bas {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface); border-top: 1px solid var(--ligne);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.bouton-joindre {
  font-size: 22px; cursor: pointer; padding: 4px 6px; user-select: none;
}
.bouton-micro {
  font-size: 20px; cursor: pointer; padding: 4px 6px; user-select: none;
  background: none; border: 0; border-radius: 50%; line-height: 1;
}
.bouton-micro.en-cours {
  background: var(--rouge); animation: pouls-micro 1.4s ease-in-out infinite;
}
@keyframes pouls-micro {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215,38,61,.55); }
  50% { box-shadow: 0 0 0 7px rgba(215,38,61,0); }
}

.bandeau-enregistrement {
  background: var(--surface); color: var(--rouge-clair); border-top: 1px solid var(--ligne);
  padding: 8px 14px; font-size: 12.5px; text-align: center; font-weight: 600;
}
.champ-texte {
  flex: 1; padding: 12px 14px; border: 1px solid var(--ligne); border-radius: 22px;
  font-size: 15px; background: var(--surface-2); color: var(--texte);
}
.champ-texte::placeholder { color: var(--gris); }
.champ-texte:focus { outline: none; border-color: var(--rouge); }
.bouton-envoyer {
  border: 0; background: var(--rouge); color: #fff; font-weight: 600;
  padding: 12px 18px; border-radius: 22px; font-size: 15px; cursor: pointer;
}
.bouton-envoyer:hover:not(:disabled) { background: var(--rouge-sombre); }
.bouton-envoyer:hover:not(:disabled) { background: var(--rouge-sombre); }
.bouton-envoyer:disabled { opacity: .5; cursor: default; }

/* ---------------- Appel (Mac à Mac) ---------------- */
.bouton-appel {
  font-size: 19px; cursor: pointer; padding: 4px 10px; user-select: none;
  background: none; border: 0; color: var(--texte); line-height: 1;
}
.bouton-appel:disabled { opacity: .35; cursor: default; }

.overlay-appel {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
/* Piège CSS classique : une règle "display" sur la classe peut prendre le pas
   sur l'attribut HTML "hidden" (même spécificité, la règle de la page gagne).
   Cette ligne force "caché" à toujours gagner, quoi qu'il arrive. */
.overlay-appel[hidden] { display: none; }
.carte-appel {
  background: var(--surface); border: 1px solid var(--ligne); border-radius: 18px;
  padding: 32px 28px; text-align: center; max-width: 320px; width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
}
.appel-icone {
  font-size: 36px; width: 74px; height: 74px; border-radius: 50%;
  background: var(--surface-2); border: 1.5px solid var(--rouge);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
  animation: pouls-appel 1.4s ease-in-out infinite;
}
@keyframes pouls-appel {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215,38,61,.5); }
  50% { box-shadow: 0 0 0 12px rgba(215,38,61,0); }
}
.appel-titre { font-size: 17px; font-weight: 700; color: var(--texte); margin-bottom: 4px; }
.appel-sous { font-size: 13px; color: var(--gris); margin-bottom: 20px; min-height: 16px; }
.appel-boutons { display: flex; gap: 12px; justify-content: center; }
.appel-bouton {
  border: 0; border-radius: 22px; padding: 11px 22px; font-size: 14px; font-weight: 600;
  cursor: pointer; color: #fff;
}
/* Vert = décrocher, rouge = refuser/raccrocher : seule exception à la palette
   noir/rouge — convention universelle des appels, trop utile pour s'en passer. */
.appel-bouton.appel-accepter { background: #2ea043; }
.appel-bouton.appel-accepter:hover { background: #268038; }
.appel-bouton.appel-refuser, .appel-bouton.appel-raccrocher { background: var(--rouge); }
.appel-bouton.appel-refuser:hover, .appel-bouton.appel-raccrocher:hover { background: var(--rouge-sombre); }
