/* Chat web des sites (illico-4c, 31/10/2026 ; v3 01/11 : bouton WhatsApp vert avec logo ; v4 05/11 : logo du site dans l'en-tête ; v5 et v6 11/11 : téléphone, clavier ouvert). Couleurs réglables par le site : --cw-accent, --cw-accent-texte, --cw-fond,
   --cw-carte, --cw-texte, --cw-doux, --cw-moi, --cw-bot. Aucune ressource externe ; propriétés logiques (arabe à gauche). */
.cw {
  --cw-accent: #128c7e; --cw-accent-texte: #fff; --cw-fond: #f4f6f8; --cw-carte: #fff; --cw-texte: #1d2330; --cw-doux: #667085;
  --cw-moi: var(--cw-accent); --cw-moi-texte: #fff; --cw-bot: #fff; --cw-ligne: #e4e7ec;
  position: fixed; z-index: 1000; inset-block-end: 96px; right: 22px; left: auto;
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--cw-fond); color: var(--cw-texte); border: 1px solid var(--cw-ligne); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .28), 0 4px 12px rgba(16, 24, 40, .12);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.cw[hidden] { display: none; }
/* v5 : la fenêtre ne prend rien des règles qu'une page pose sur ses balises nues (« section { padding } », « footer a { margin } »…). */
.cw { padding: 0; }
.cw, .cw__tete, .cw__forme, .cw__pied, .cw__wa { margin: 0; }
/* La fenêtre s'ouvre du côté de son bouton (même en arabe, où les boutons des sites restent à droite). */
.cw.cw--gauche { right: auto; left: 22px; }
@media (prefers-color-scheme: dark) {
  .cw { --cw-fond: #12161d; --cw-carte: #1b2029; --cw-texte: #e6e8ee; --cw-doux: #98a2b3; --cw-bot: #232a35; --cw-ligne: #2c3340; }
}
.cw__tete { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px;
  background: var(--cw-accent); color: var(--cw-accent-texte); }
.cw__qui { display: flex; flex-direction: column; min-width: 0; }
/* v4 (05/11) : logo du site avant le titre (à droite en arabe), rond de 36 px sur fond blanc. */
.cw__ident { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cw__logo { flex: none; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.cw__qui strong { font-size: 16px; }
.cw__qui span { font-size: 12px; opacity: .9; }
.cw__fermer { background: transparent; border: 0; color: inherit; font-size: 26px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.cw__fermer:focus-visible, .cw__envoyer:focus-visible, .cw__bouton:focus-visible, .cw__wa:focus-visible { outline: 3px solid var(--cw-accent); outline-offset: 2px; }
.cw__fermer:focus-visible { outline-color: currentColor; }   /* sur l'en-tête de couleur, le liseré d'accent serait invisible */
.cw__liste { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.cw__msg { max-width: 84%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cw__msg--bot { align-self: flex-start; background: var(--cw-bot); border: 1px solid var(--cw-ligne); border-start-start-radius: 4px; }
.cw__msg--moi { align-self: flex-end; background: var(--cw-moi); color: var(--cw-moi-texte); border-start-end-radius: 4px; }
.cw__msg a { color: inherit; text-decoration: underline; }
.cw__ecrit { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: var(--cw-bot); border: 1px solid var(--cw-ligne); border-radius: 14px; }
.cw__ecrit i { width: 7px; height: 7px; border-radius: 50%; background: var(--cw-doux); animation: cw-point 1s infinite ease-in-out; }
.cw__ecrit i:nth-child(2) { animation-delay: .15s; } .cw__ecrit i:nth-child(3) { animation-delay: .3s; }
@keyframes cw-point { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cw__choix { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.cw__choix:empty { display: none; }
.cw__bouton { border: 1px solid var(--cw-accent); color: var(--cw-accent); background: var(--cw-carte); border-radius: 999px; padding: 7px 12px; cursor: pointer; font: inherit; font-size: 14px; }
.cw__forme { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-block-start: 1px solid var(--cw-ligne); background: var(--cw-carte); }
.cw__zone { flex: 1; resize: none; border: 1px solid var(--cw-ligne); border-radius: 12px; padding: 9px 11px; font: inherit; color: var(--cw-texte); background: var(--cw-fond); max-height: 120px; }
.cw__envoyer { flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--cw-accent); color: var(--cw-accent-texte); font-size: 18px; cursor: pointer; }
.cw[dir="rtl"] .cw__envoyer { transform: scaleX(-1); }
.cw__envoyer:disabled { opacity: .5; cursor: wait; }
.cw__pied { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px 10px; background: var(--cw-carte); text-align: center; }
.cw__pied small { color: var(--cw-doux); font-size: 11px; }
/* v3 : « Continuer sur WhatsApp » = bouton vert WhatsApp avec son logo, quelle que soit la couleur du site
   (--cw-wa réglable ; #1a7f37 sous texte blanc : contraste 5,1:1). */
.cw { --cw-wa: #1a7f37; --cw-wa-survol: #136a2c; --cw-wa-texte: #fff; }
.cw__wa { box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border-radius: 999px; background: var(--cw-wa); color: var(--cw-wa-texte); font-size: 15px; font-weight: 700;
  text-decoration: none; box-shadow: 0 2px 8px rgba(26, 127, 55, .35); transition: background-color .15s; }
.cw__wa:hover { background: var(--cw-wa-survol); }
.cw__wa:focus-visible { outline-color: var(--cw-wa); }
.cw__wa-logo { width: 22px; height: 22px; flex: none; }
.cw__wa--msg { align-self: flex-start; min-height: 40px; padding: 8px 14px; font-size: 14px; }
.cw__wa--msg .cw__wa-logo { width: 20px; height: 20px; }
@media (max-width: 640px) { body.cw-ouvert .cw-lanceur { visibility: hidden; } }
/* v5 (11/11) : le champ est à 16 px sur téléphone et sur écran tactile. Sous 16 px, Safari sur iPhone agrandit la page
   quand on touche le champ, et le bord droit de la fenêtre était rogné. La balise viewport des pages ne change pas. */
@media (max-width: 640px), (pointer: coarse) { .cw .cw__zone { font-size: 16px; } }
/* v6 (11/11, soir ; demande du fondateur après essai sur son iPhone) : sur téléphone, la fenêtre s'ouvre en PLEINE PAGE.
   La carte flottante de la v5 restait bridée à 160 px clavier ouvert (une hauteur mesurée tombait à son plancher dans
   Safari) et son en-tête sortait de l'écran. C'est chat-web.js qui pose « cw--plein » sous 640 px de large :
   - sans autre indication, la fenêtre couvre toute la page (haut, bas, gauche, droite à 0) ;
   - quand le navigateur donne sa zone réellement visible (cw--vv), elle en prend exactement la place : son haut
     (--cw-top), son bord gauche (--cw-left), sa largeur (--cw-vvw) et sa hauteur (--cw-vvh). Clavier ouvert, le champ
     et le bouton d'envoi sont donc juste au-dessus de lui, l'en-tête en haut de ce qui reste visible ;
   - clavier ouvert (cw--clavier), le pied (bouton WhatsApp et mention) s'efface le temps de la saisie ;
   - la page derrière ne défile pas (html.cw-plein) ; l'encoche et la barre du bas sont respectées.
   Les sélecteurs à deux et trois classes l'emportent sur les réglages de position qu'un site pose sur « .cw ».
   Sur ordinateur et tablette large : rien de cela ne s'applique. */
.cw.cw--plein, .cw.cw--plein.cw--gauche {
  top: 0; right: 0; left: 0; bottom: 0; inset-block-end: 0; width: auto; height: auto; max-height: none; z-index: 2147483000;
  border: 0; border-radius: 0; overscroll-behavior: contain;
  box-shadow: 0 2px 0 var(--cw-carte);   /* vu sur iPhone : un filet de la page restait visible entre le champ et la barre du navigateur */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.cw.cw--plein.cw--vv, .cw.cw--plein.cw--gauche.cw--vv {
  top: var(--cw-top); left: var(--cw-left); right: auto; bottom: auto; inset-block-end: auto; width: var(--cw-vvw); height: var(--cw-vvh);
}
.cw.cw--plein.cw--clavier { padding-bottom: 0; }
.cw.cw--plein.cw--clavier .cw__pied { display: none; }
.cw.cw--plein .cw__tete { padding-block: 8px; padding-inline: 14px 8px; }
.cw.cw--plein .cw__fermer, .cw.cw--plein .cw__nouveau { min-width: 44px; min-height: 44px; }   /* 44 px : la taille d'un doigt */
html.cw-plein, html.cw-plein body { overflow: hidden; overscroll-behavior: none; }
/* v6 : l'en-tête ne peut plus sortir de la fenêtre. Si la place manque, ce sont les messages et les suggestions qui se
   réduisent et défilent ; l'en-tête, le champ et le pied gardent leur taille. */
.cw__tete, .cw__forme, .cw__pied, .cw__diag, .cw__actions { flex: none; }
.cw__liste { min-height: 0; overscroll-behavior: contain; }
.cw__choix { flex: 0 1 auto; min-height: 0; max-height: 45%; overflow-y: auto; padding-block-end: 8px; }
/* v6 : « Nouvelle discussion », à côté de la croix. Même liseré de focus qu'elle, sur l'en-tête de couleur. */
.cw__actions { display: flex; align-items: center; gap: 2px; }
.cw__nouveau { display: flex; align-items: center; justify-content: center; min-width: 34px; min-height: 34px; background: transparent; border: 0; color: inherit; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.cw__nouveau svg { width: 20px; height: 20px; }
.cw__nouveau:disabled { opacity: .45; cursor: wait; }
.cw__nouveau:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
.cw__fermer { display: flex; align-items: center; justify-content: center; }
/* v6 : ligne de diagnostic, seulement si l'adresse de la page porte « ?cwdiag=1 » (nombres de l'écran, rien d'autre). */
.cw__diag { padding: 4px 8px; background: #fff7d6; color: #1d2330; font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .cw__ecrit i { animation: none; } }
