/* ulivechat — style inspiré de Discord : thème sombre, messages avec avatar, barre d'écriture en bas. */

:root {
  --fond: #313338;          /* zone des messages */
  --fond-entete: #313338;
  --fond-saisie: #383a40;   /* barre d'écriture */
  --fond-carte: #2b2d31;    /* intégrations, pièce jointe */
  --fond-sombre: #1e1f22;   /* champs, bordures fortes */
  --survol: #2e3035;
  --texte: #dbdee1;
  --texte-fort: #f2f3f5;
  --texte-doux: #949ba4;
  --accent: #5865f2;
  --accent-fort: #4752c4;
  --vert: #23a55a;
  --rouge: #f23f43;
  --lien: #00a8fc;
  --police: "gg sans", "Noto Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* L'attribut hidden gagne toujours, même sur un élément qui a un display (grid, flex…). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--police);
  font-size: 1rem;
  color: var(--texte);
}

button { font: inherit; }

.visuellement-cache {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}

/* ───────────── Page « envoyer » ───────────── */

.page-envoyer {
  color-scheme: dark; /* seulement ici : la page écran doit rester transparente (OBS, overlay) */
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--fond);
}

.entete {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  background: var(--fond-entete);
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.25), 0 2px 0 rgb(0 0 0 / 0.05);
  z-index: 1;
}

.diese { font-size: 1.5rem; font-weight: 500; color: var(--texte-doux); line-height: 1; }

.entete h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--texte-fort);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence {
  margin: 0 auto 0 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid #3f4147;
  font-size: 0.875rem;
  color: var(--texte-doux);
  white-space: nowrap;
}

.presence::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.375rem;
  border-radius: 50%;
  background: #80848e;
  vertical-align: 0.05em;
}

.presence.actif::before { background: var(--vert); }

.bouton-icone {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem;
  color: var(--texte-doux);
  background: none;
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
}

.bouton-icone:hover { color: var(--texte-fort); background: var(--survol); }

.bouton-stop span { font-size: 0.875rem; font-weight: 600; }
.bouton-stop:hover { color: var(--rouge); }

.bouton-moi {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 11rem;
  padding: 0.25rem 0.625rem 0.25rem 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--texte-fort);
  background: var(--fond-carte);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bouton-moi:hover { background: var(--fond-sombre); }
.bouton-moi .avatar { width: 1.5rem; height: 1.5rem; font-size: 0.75rem; }

@media (max-width: 30rem) {
  .bouton-stop span { display: none; }
  .presence { margin-left: 0.25rem; padding-left: 0.5rem; }
}

.fil {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0 0.5rem;
  scrollbar-color: var(--fond-sombre) transparent;
}

.accueil { padding: 1rem 1rem 1.5rem; }

.accueil-diese {
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  margin-bottom: 0.75rem;
  border-radius: 50%;
  font-size: 2.5rem;
  color: var(--texte-fort);
  background: #41434a;
}

.accueil h2 { margin: 0 0 0.5rem; font-size: 2rem; line-height: 1.2; color: var(--texte-fort); }
.accueil p { max-width: 60ch; margin: 0; color: var(--texte-doux); line-height: 1.4; }

.messages { margin: 0; padding: 0; list-style: none; }

.message {
  position: relative;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  column-gap: 1rem;
  margin-top: 1.0625rem;
  padding: 0.125rem 1rem 0.125rem 1rem;
}

.message:hover { background: rgb(2 2 2 / 0.06); }

.message .avatar { grid-row: 1 / span 2; margin-top: 0.125rem; }

.message-entete { margin: 0; line-height: 1.375rem; }
.message-entete strong { font-weight: 500; color: var(--texte-fort); }

.message time {
  margin-left: 0.5rem;
  font-size: 0.75rem;
  color: var(--texte-doux);
}

.message-corps { grid-column: 2; min-width: 0; }

.message-texte {
  margin: 0;
  line-height: 1.375rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Messages qui suivent un message du même auteur : ni avatar ni pseudo. */
.message.suite { margin-top: 0; }
.message.suite time {
  position: absolute;
  left: 0;
  width: 4.5rem;
  margin: 0;
  padding-top: 0.2rem;
  text-align: center;
  font-size: 0.6875rem;
  visibility: hidden;
}
.message.suite:hover time { visibility: visible; }

.message-piece { margin-top: 0.25rem; }
.message-piece img,
.message-piece video {
  display: block;
  max-width: min(100%, 25rem);
  max-height: 21rem;
  border-radius: 0.5rem;
}
.message-piece audio { width: min(100%, 25rem); }

.integration {
  display: grid;
  gap: 0.375rem;
  max-width: 27rem;
  margin-top: 0.25rem;
  padding: 0.5rem 1rem 1rem 0.75rem;
  background: var(--fond-carte);
  border-left: 4px solid var(--texte-doux);
  border-radius: 0.25rem;
}

.integration-youtube { border-left-color: #ff0000; }
.integration-tiktok { border-left-color: #25f4ee; }
.integration-x { border-left-color: #e7e9ea; }
.integration-twitch { border-left-color: #9146ff; }

.integration-nom { margin: 0.25rem 0 0; font-size: 0.75rem; color: var(--texte-doux); }
.integration a { font-weight: 600; color: var(--lien); text-decoration: none; }
.integration a:hover { text-decoration: underline; }
.integration-miniature { width: 100%; max-width: 25rem; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 0.25rem; }

.message-systeme {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding-left: 4.5rem;
}
.message-systeme p { margin: 0; color: var(--texte-doux); }
.message-systeme time { margin: 0; }

.saisie { padding: 0 1rem calc(0.75rem + env(safe-area-inset-bottom)); }

.piece {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem;
  background: var(--fond-saisie);
  border-radius: 0.5rem 0.5rem 0 0;
  border-bottom: 1px solid #4e5058;
}

.piece[hidden] { display: none; }

.piece-apercu {
  display: grid;
  place-items: center;
  flex: none;
  width: 4rem;
  height: 4rem;
  overflow: hidden;
  font-size: 1.75rem;
  background: var(--fond-carte);
  border-radius: 0.25rem;
}

.piece-apercu img { width: 100%; height: 100%; object-fit: cover; }
.piece-infos { flex: 1; min-width: 0; }
.piece-nom { margin: 0; font-size: 0.875rem; color: var(--texte-fort); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.piece-taille { margin: 0.125rem 0 0; font-size: 0.75rem; color: var(--texte-doux); }

.progression { height: 0.25rem; margin-top: 0.5rem; background: var(--fond-sombre); border-radius: 999px; overflow: hidden; }
.progression-barre { width: 0; height: 100%; background: var(--accent); transition: width 150ms linear; }

.barre {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  padding: 0 0.5rem 0 0.25rem;
  background: var(--fond-saisie);
  border-radius: 0.5rem;
}

.piece:not([hidden]) + .barre { border-radius: 0 0 0.5rem 0.5rem; }

.bouton-plus,
.bouton-envoyer {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  color: #b5bac1;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.bouton-plus svg {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0.1rem;
  color: var(--fond-saisie);
  background: #b5bac1;
  border-radius: 50%;
}

.bouton-plus:hover svg { background: var(--texte-fort); }
.bouton-plus:focus-within { outline: 2px solid var(--accent); }
.bouton-envoyer:hover { color: var(--texte-fort); }
.bouton-envoyer:disabled { opacity: 0.5; cursor: wait; }

.barre textarea {
  flex: 1;
  min-height: 2.75rem;
  max-height: 10rem;
  padding: 0.6875rem 0.25rem;
  font: inherit;
  line-height: 1.375rem;
  color: var(--texte);
  background: none;
  border: 0;
  resize: none;
}

.barre textarea::placeholder { color: #6d6f78; }
.barre textarea:focus-visible { outline: none; }

.resultat { min-height: 1.25rem; margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--texte-doux); }
.resultat.erreur { color: var(--rouge); }

.dialogue {
  width: min(27rem, calc(100vw - 2rem));
  padding: 1.5rem;
  color: var(--texte);
  background: var(--fond);
  border: 0;
  border-radius: 0.5rem;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.3), 0 1rem 3rem rgb(0 0 0 / 0.5);
}

.dialogue::backdrop { background: rgb(0 0 0 / 0.7); }
.dialogue h2 { margin: 0 0 0.5rem; font-size: 1.5rem; text-align: center; color: var(--texte-fort); }
.dialogue p { margin: 0 0 1.25rem; text-align: center; color: var(--texte-doux); }

.dialogue label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--texte-doux);
}

.dialogue input {
  width: 100%;
  padding: 0.625rem;
  font: inherit;
  color: var(--texte);
  background: var(--fond-sombre);
  border: 0;
  border-radius: 0.25rem;
}

.dialogue .resultat { margin: 0.5rem 0 0; text-align: left; }

.dialogue button {
  width: 100%;
  margin-top: 1rem;
  padding: 0.625rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
}

.dialogue button:hover { background: var(--accent-fort); }

/* ───────────── Page « écran » (deviendra l'overlay) ───────────── */

.page-ecran {
  height: 100vh;
  overflow: hidden;
  background: transparent; /* transparent pour l'app overlay et OBS */
}

.scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 2rem 2rem 10vh;
  pointer-events: none;
}

/* Un envoi s'affiche comme un message : avatar, pseudo, puis texte et média. */
.carte {
  display: grid;
  justify-items: start;
  gap: 0.5rem;
  max-width: min(64rem, 92vw);
  margin: 0;
  padding: 0.875rem 1rem 1rem;
  background: rgb(43 45 49 / 0.96);
  border-radius: 0.5rem;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25), 0 0.5rem 1.5rem rgb(0 0 0 / 0.45);
  animation: apparition 260ms cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.carte.sortie { animation: disparition 200ms ease-in both; }

.carte-entete { display: flex; align-items: center; gap: 0.625rem; }
.carte-entete .avatar { width: 2.25rem; height: 2.25rem; }
.carte-entete strong { font-size: 1.125rem; font-weight: 600; color: var(--texte-fort); }

.carte-texte {
  max-width: 50ch;
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  font-weight: 500;
  line-height: 1.25;
  color: var(--texte-fort);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.carte-media {
  display: block;
  max-width: min(60vw, 60rem);
  max-height: 60vh;
  border-radius: 0.5rem;
  background: var(--fond-sombre);
}

.carte-son { margin: 0; font-size: 1.125rem; color: var(--texte-doux); }

.integre { display: block; border: 0; border-radius: 0.5rem; background: #000; }
.integre-paysage { width: min(56vw, 60rem); aspect-ratio: 16 / 9; }
.integre-portrait { height: min(66vh, 46rem); aspect-ratio: 9 / 16; }
.integre-post { width: min(34rem, 80vw); height: min(60vh, 40rem); background: transparent; }

.etat {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  margin: 0;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--texte-fort);
  background: rgb(30 31 34 / 0.9);
  border-radius: 999px;
  transition: opacity 600ms ease;
}

.etat::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--rouge);
}

.etat.connecte::before { background: var(--vert); }
.etat.discret { opacity: 0; }

.bandeau-son {
  position: fixed;
  top: 1rem;
  left: 50%;
  translate: -50% 0;
  padding: 0.625rem 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
}

.bandeau-son[hidden] { display: none; }

@keyframes apparition {
  from { opacity: 0; transform: translateY(0.75rem) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes disparition {
  to { opacity: 0; transform: translateY(0.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  .carte, .carte.sortie { animation: none; }
  .etat, .progression-barre { transition: none; }
}

/* ───────────── Boutons communs ───────────── */

.bouton-principal,
.bouton-secondaire,
.bouton-danger {
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25rem;
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
  white-space: nowrap;
}

.bouton-principal { color: #fff; background: var(--accent); }
.bouton-principal:hover { background: var(--accent-fort); }
.bouton-principal:disabled { opacity: 0.6; cursor: wait; }
.bouton-secondaire { color: var(--texte-fort); background: #4e5058; }
.bouton-secondaire:hover { background: #6d6f78; }
.bouton-danger { color: #fff; background: #da373c; }
.bouton-danger:hover { background: #a12828; }

.bouton-lien-danger {
  padding: 0.5rem 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--rouge);
  background: none;
  border: 0;
  cursor: pointer;
}
.bouton-lien-danger:hover { text-decoration: underline; }

.ligne-boutons { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }
.dialogue .ligne-boutons button { width: auto; margin: 0; }

/* ───────────── Pages d'entrée (code, connexion) ───────────── */

.page-portail {
  color-scheme: dark;
  min-height: 100dvh;
  background: var(--accent);
}

.portail {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1.5rem 1rem;
}

.portail-carte {
  width: min(30rem, 100%);
  padding: 2rem;
  background: var(--fond);
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.25);
}

.portail-carte h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  text-align: center;
  color: var(--texte-fort);
}

.portail-intro { margin: 0 0 1.25rem; text-align: center; color: #b5bac1; }

.portail-carte label,
.bloc-formulaire label {
  display: block;
  margin: 1rem 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #b5bac1;
}

.portail-carte input,
.bloc-formulaire input:not([type="checkbox"]) {
  width: 100%;
  padding: 0.625rem;
  font: inherit;
  color: var(--texte);
  background: var(--fond-sombre);
  border: 0;
  border-radius: 0.25rem;
}

#champ-code { font-size: 1.5rem; font-weight: 600; letter-spacing: 0.25em; text-align: center; text-transform: uppercase; }

.portail-carte .bouton-principal { width: 100%; margin-top: 1.25rem; padding: 0.625rem; font-size: 1rem; }
.portail-carte .resultat { margin-top: 0.5rem; }
.portail-pied { margin: 1rem 0 0; font-size: 0.875rem; color: var(--texte-doux); }
.portail-pied a, .page-contenu a { color: var(--lien); text-decoration: none; }
.portail-pied a:hover, .page-contenu a:hover { text-decoration: underline; }

/* ───────────── Pages des créateurs (livechats, administration) ───────────── */

.page-appli { color-scheme: dark; min-height: 100dvh; background: var(--fond); }

.entete-titre { margin: 0; font-size: 1rem; font-weight: 700; color: var(--texte-fort); }
.entete-titre a { color: inherit; text-decoration: none; }

.entete-liens {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  font-size: 0.875rem;
}
.entete-liens a { color: var(--texte-doux); text-decoration: none; font-weight: 600; }
.entete-liens a:hover { color: var(--texte-fort); }

.page-contenu { max-width: 50rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page-contenu h2 { margin: 0.5rem 0 1rem; font-size: 1.25rem; color: var(--texte-fort); }
.vide { color: var(--texte-doux); }

.liste-livechats { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }

.livechat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--fond-carte);
  border-radius: 0.5rem;
}

.livechat-infos { flex: 1; min-width: 10rem; }
.livechat-nom { font-size: 1.0625rem; font-weight: 600; color: var(--texte-fort) !important; }
.livechat-code { margin: 0.125rem 0 0; font-size: 0.875rem; color: var(--texte-doux); letter-spacing: 0.05em; }
.livechat-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.bloc-formulaire {
  margin-top: 2rem;
  padding: 1rem;
  background: var(--fond-carte);
  border-radius: 0.5rem;
}

.bloc-formulaire h3 { margin: 0; font-size: 1rem; color: var(--texte-fort); }
.bloc-formulaire summary { font-weight: 700; color: var(--texte-fort); cursor: pointer; }
.bloc-formulaire form .bouton-principal { margin-top: 1rem; }
.ligne-champ { display: flex; gap: 0.5rem; }
.ligne-champ input { flex: 1; }

.case { display: flex !important; align-items: center; gap: 0.5rem; font-size: 0.875rem !important; font-weight: 400 !important; }

.tableau-defilant { overflow-x: auto; }
.tableau { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.tableau th { padding: 0.5rem; text-align: left; font-size: 0.75rem; color: var(--texte-doux); border-bottom: 1px solid #3f4147; }
.tableau td { padding: 0.625rem 0.5rem; border-bottom: 1px solid #3f4147; vertical-align: middle; }
.pseudo-avec-avatar { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--texte-fort); }
.pseudo-avec-avatar .avatar { width: 1.75rem; height: 1.75rem; font-size: 0.8rem; }

.encart-mdp {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgb(88 101 242 / 0.15);
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
}
.encart-mdp p { margin: 0 0 0.5rem; }
.mdp-provisoire code { padding: 0.25rem 0.5rem; font-size: 1.125rem; color: var(--texte-fort); background: var(--fond-sombre); border-radius: 0.25rem; }
.encart-note { font-size: 0.8125rem; color: var(--texte-doux); }

.accueil-code { margin-top: 0.75rem !important; }
.accueil-code strong { color: var(--texte-fort); letter-spacing: 0.05em; }

@media (max-width: 30rem) {
  .ligne-champ { flex-direction: column; }
  .portail-carte { padding: 1.5rem 1.25rem; }
}
