/*
 * shared/conversation.css — Design de messagerie PARTAGÉ (source: conversation.html LEAD).
 * Système .conv-* + composeur .cmp-* : en-tête psy, fil, bulles, méta, animations, saisie.
 * Extrait tel quel du lead (money-path) le 08/07 pour être la base commune lead+patient.
 * NE dépend que des tokens de theme.css (--accent, --ink, --muted, --surface, --line…).
 * N'INCLUT PAS : le layout de page (.app/.conv-main/html/body) ni le paywall/Stripe (lead-only).
 */
/* ─── EN-TÊTE PSY ─────────────────────────────────────────────────────── */
.conv-head {
  display: flex; align-items: center; gap: var(--palette-espacement-cabinet-conversation-5);
  padding: var(--palette-espacement-cabinet-conversation-2) var(--palette-espacement-components-5); background: var(--surface);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.conv-head .av {
  position: relative; width: 44px; height: 44px; border-radius: var(--palette-rayon-cabinet-conversation-3); overflow: hidden;
  flex: 0 0 44px; background: linear-gradient(135deg, var(--accent-soft), var(--adaptation-fond-action-accent, var(--accent)));
  color: var(--palette-texte-inverse-components); display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--palette-typographie-cabinet-conversation-5);
}
.conv-head .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Point vert « en ligne » sur l'avatar. */
.conv-head .av::after {
  content: ''; position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px;
  border-radius: var(--palette-rayon-composants-2); background: var(--adaptation-fond-succes-success, var(--success)); border: 2px solid var(--adaptation-bordure-surface, var(--surface));
}
/* Flèche retour → home : MOBILE uniquement (cf. @media 720). */
.conv-back { display: none; }
.conv-head-id { min-width: 0; flex: 1; }
.conv-head-name {
  font-family: var(--palette-police-editoriale-conversation); font-weight: 500; font-size: var(--palette-typographie-components-6);
  color: var(--ink); letter-spacing: var(--palette-typographie-conversation); line-height: 1.1;
}
.conv-head-name em { font-style: italic; font-weight: 500; color: var(--accent-ink); }
.conv-head-sub { font-size: var(--palette-typographie-cabinet-conversation-3); color: var(--muted); margin-top: var(--palette-espacement-conversation); }
.conv-head-r { display: flex; align-items: center; gap: var(--palette-espacement-cabinet-conversation-2); flex: 0 0 auto; }
.conv-head-resp { font-size: var(--palette-typographie-components-2); color: var(--success); display: inline-flex; align-items: center; gap: var(--palette-espacement-cabinet-conversation-3); }
.conv-head-resp .dot { width: 7px; height: 7px; border-radius: var(--palette-rayon-composants-2); background: var(--adaptation-fond-succes-success, var(--success)); }
.conv-head-user {
  width: 34px; height: 34px; border-radius: var(--palette-rayon-composants-2); background: var(--surface-2);
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.conv-head-user:hover { background: var(--accent-softer, var(--palette-surface-action-composants-2)); color: var(--accent, var(--palette-texte-action-composants)); }
.conv-head-user svg { width: 18px; height: 18px; }

/* ─── FIL DE MESSAGES ─────────────────────────────────────────────────── */
.conv-thread {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: var(--palette-espacement-composants-2) var(--palette-espacement-components-5) var(--palette-espacement-cabinet-conversation-2); display: flex; flex-direction: column; gap: var(--palette-espacement-cabinet-conversation-8);
}
.conv-inner { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--palette-espacement-cabinet-conversation-8); }

/* Pill « début de conversation chiffrée », centré. */
.conv-pill {
  align-self: center; display: inline-flex; align-items: center; gap: var(--palette-espacement-components);
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-size: var(--palette-typographie-cabinet-conversation-4); padding: var(--palette-espacement-components) var(--palette-espacement-composants-7); border-radius: var(--palette-rayon-components-2);
}
.conv-pill svg { width: 13px; height: 13px; color: var(--accent); }

/* Rangée de message (psy = gauche / patient = droite). */
.conv-row { display: flex; flex-direction: column; max-width: 78%; }
.conv-row.them { align-self: flex-start; }
.conv-row.me   { align-self: flex-end; align-items: flex-end; }
.conv-bubble {
  padding: var(--palette-espacement-cabinet-conversation-5) var(--palette-espacement-conversation-2); border-radius: var(--palette-rayon-cabinet-conversation); font-size: var(--palette-typographie-composants-14); line-height: 1.6;
  letter-spacing: var(--palette-typographie-conversation-2); white-space: pre-line; word-wrap: break-word;
}
/* Bulles CONTRASTÉES (Vague 1 UX, 03/07 — retour « trop fondu ») */
.conv-row.them .conv-bubble {
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong, var(--palette-bordure-composants));
  border-bottom-left-radius: var(--palette-rayon-conversation);
  box-shadow: 0 1px 2px var(--palette-ombre-conversation-2), 0 8px 20px -14px var(--palette-ombre-conversation);
}
.conv-row.me .conv-bubble {
  background: linear-gradient(135deg, var(--palette-fond-action-composants), var(--palette-fond-action-conversation)); color: var(--palette-texte-inverse-components); border-bottom-right-radius: var(--palette-rayon-conversation);
  box-shadow: 0 8px 20px -12px var(--palette-ombre-conversation-3);
}
/* ── Vague 1 UX : arrivée des messages + envoi optimiste + ✈️ qui décolle ── */
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.conv-row.msg-new { animation: msgIn .38s cubic-bezier(.22, 1, .36, 1) both; }
@media (prefers-reduced-motion: reduce) { .conv-row.msg-new { animation: none; } }
.conv-row.is-sending .conv-bubble { opacity: .65; }
@keyframes sendFly { 30% { transform: translate(3px, -5px) rotate(-14deg) scale(1.06); } }
.cmp-send.did-send { animation: sendFly .38s cubic-bezier(.22, 1, .36, 1); }
.conv-meta {
  font-size: var(--palette-typographie-composants-3); color: var(--muted); padding: var(--palette-espacement-cabinet-conversation-9) var(--palette-espacement-cabinet-2) 0;
  display: inline-flex; align-items: center; gap: var(--palette-espacement-components);
}
.conv-meta .mini-av {
  width: 16px; height: 16px; border-radius: var(--palette-rayon-composants-2); overflow: hidden; flex: 0 0 16px;
  background: linear-gradient(135deg, var(--accent-soft), var(--adaptation-fond-action-accent, var(--accent)));
  color: var(--palette-texte-inverse-components); display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--palette-typographie-conversation-3); font-weight: 600;
}
.conv-meta .mini-av img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ════════════════════════════════════════════════════════════════════════
   BAS DE PAGE : COMPOSER (état 1) ⟷ PAYWALL (état 2). Un seul des deux affiché.
   ════════════════════════════════════════════════════════════════════════ */
.conv-foot { flex: 0 0 auto; background: var(--bg); border-top: 1px solid var(--line); padding: var(--palette-espacement-cabinet-conversation-2) var(--palette-espacement-components-5) var(--palette-espacement-cabinet-conversation-8); transition: max-height .3s ease, padding .3s ease, opacity .25s ease; }
.conv-foot-inner { width: 100%; max-width: 760px; margin: 0 auto; }

/* ─── BILAN EN COURS : le composer se REPLIE pour laisser toute la place au widget.
   Un bouton flottant « ⌃ Messagerie » permet de le remonter ponctuellement. ──── */
body.bilan-active .conv-foot { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; overflow: hidden; pointer-events: none; }
body.bilan-active.foot-open .conv-foot { max-height: 360px; padding-top: var(--palette-espacement-cabinet-conversation-2); padding-bottom: var(--palette-espacement-cabinet-conversation-8); opacity: 1; overflow: visible; pointer-events: auto; }
.conv-foot-peek {
  /* En bas à DROITE (demande user 01/07) — ne recouvre pas les boutons du widget
     bilan, centrés en bas. */
  position: fixed; right: 18px; bottom: 14px;
  display: none; align-items: center; gap: var(--palette-espacement-components); z-index: 40;
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--line); border-radius: var(--palette-rayon-components-2);
  padding: var(--palette-espacement-cabinet-conversation-4) var(--palette-espacement-conversation-2); cursor: pointer;
  font-family: var(--palette-police-interface-conversation); font-size: var(--palette-typographie-cabinet-conversation-3); font-weight: 600;
  box-shadow: 0 8px 22px -8px var(--palette-ombre-composants-3);
}
.conv-foot-peek:hover { border-color: var(--adaptation-bordure-action-accent, var(--accent)); }
body.bilan-active .conv-foot-peek { display: inline-flex; }
.conv-foot-peek .cfp-chev { display: inline-block; transition: transform .25s ease; font-size: var(--palette-typographie-composants-3); line-height: 1; }
body.foot-open .conv-foot-peek .cfp-chev { transform: rotate(180deg); }

/* ─── COMPOSER ────────────────────────────────────────────────────────── */
.cmp-preamble { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--palette-espacement-cabinet-conversation-5); margin-bottom: var(--palette-espacement-cabinet-conversation-6); padding: 0 var(--palette-espacement-composants-5); }
.cmp-label { font-size: var(--palette-typographie-cabinet-conversation-3); letter-spacing: var(--palette-typographie-conversation-4); text-transform: uppercase; color: var(--ink); font-weight: 700; }
.cmp-draft { font-size: var(--palette-typographie-components-4); color: var(--muted-2); display: inline-flex; align-items: center; gap: var(--palette-espacement-cabinet-conversation-3); }
.cmp-draft .dot { width: 6px; height: 6px; border-radius: var(--palette-rayon-composants-2); background: var(--accent-soft); display: inline-block; }
.cmp-draft.is-ready .dot { background: var(--adaptation-fond-succes-success, var(--success)); }

.cmp-box {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--palette-rayon-cabinet);
  padding: var(--palette-espacement-cabinet-conversation-5) var(--palette-espacement-cabinet-conversation-2) var(--palette-espacement-cabinet-conversation-6); transition: border-color .15s;
}
.cmp-box:focus-within { border-color: var(--adaptation-bordure-action-accent, var(--accent)); }
.cmp-textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  font-family: var(--palette-police-interface-conversation); font-size: var(--palette-typographie-composants-14); line-height: 1.6;
  color: var(--ink); min-height: 76px; max-height: 220px;
}
.cmp-textarea::placeholder { color: var(--muted-2); }
/* FIX 02/07 — DOUBLE surbrillance au focus (mobile ET desktop) : la règle
   GLOBALE `textarea:focus` de shared/components.css (border-color accent +
   box-shadow 0 0 0 4px accent-softer) allumait un 2e halo autour du textarea
   LUI-MÊME, en plus du grand cadre .cmp-box:focus-within (la seule surbrillance
   voulue). On neutralise ici pour TOUS les viewports — le textarea reste « nu »
   dans la grande boîte. Couvre les DEUX composers (actif + verrouillé : même
   markup .cmp-box/.cmp-textarea). Spécificité 0,2,1 > textarea:focus (0,1,1). */
.cmp-box .cmp-textarea:focus { border: 0; outline: 0; box-shadow: none; background: transparent; }

.cmp-bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--palette-espacement-cabinet-conversation-7); margin-top: var(--palette-espacement-cabinet-conversation-11); }
.cmp-tools { display: flex; align-items: center; gap: var(--palette-espacement-composants-5); }
.cmp-tools button {
  width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted);
  border-radius: var(--palette-rayon-cabinet-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.cmp-tools button:hover { background: var(--surface-2); color: var(--ink-2); }
.cmp-tools button svg { width: 17px; height: 17px; }
.cmp-right { display: flex; align-items: center; gap: var(--palette-espacement-cabinet-conversation-5); }
.cmp-count { font-size: var(--palette-typographie-cabinet-conversation-4); color: var(--muted); }
.cmp-count b { color: var(--accent); font-weight: 600; }
.cmp-count.is-ok { color: var(--success); }
.cmp-count.is-ok b { color: var(--success); }

/* 🎙 rond du composer actif : composant MOBILE (pilule) — masqué en desktop
   (le vocal n'existe pas sur le 1er message ; le bouton mobile informe). */
.cmp-mic-round { display: none; }
/* Mini-bulle d'info au-dessus du 🎙 (posée par showMicHint, tous viewports). */
.cmp-mic-hint {
  position: fixed;
  z-index: 300;
  max-width: 260px;
  background: var(--ink, var(--palette-fond-inverse-conversation));
  color: var(--palette-texte-inverse-components);
  font-size: var(--palette-typographie-cabinet-conversation-4);
  font-weight: 600;
  line-height: 1.4;
  padding: var(--palette-espacement-cabinet-conversation-4) var(--palette-espacement-cabinet-conversation-7);
  border-radius: var(--palette-rayon-cabinet-conversation-4);
  box-shadow: 0 10px 24px -10px var(--palette-ombre-conversation-4);
}
.cmp-send {
  display: inline-flex; align-items: center; gap: var(--palette-espacement-cabinet-conversation-11);
  background: var(--adaptation-fond-action-accent, var(--accent)); color: var(--palette-texte-inverse-components); border: 0; border-radius: var(--palette-rayon-components);
  padding: var(--palette-espacement-cabinet-conversation-6) var(--palette-espacement-cabinet-conversation-8); font-size: var(--palette-typographie-cabinet-conversation-2); font-weight: 600; cursor: pointer;
  font-family: var(--palette-police-interface-conversation); transition: background .15s, opacity .15s;
}
.cmp-send svg { width: 16px; height: 16px; }
.cmp-send:hover:not(:disabled) { background: var(--adaptation-fond-action-accent-hover, var(--accent-hover)); }
.cmp-send:disabled { opacity: .45; cursor: not-allowed; }

.cmp-footer {
  margin-top: var(--palette-espacement-cabinet-conversation-6); font-size: var(--palette-typographie-components-4); color: var(--muted-2);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--palette-espacement-cabinet-conversation-3) var(--palette-espacement-cabinet-conversation-5);
}
.cmp-footer .kbd {
  font-family: var(--palette-police-monospace-conversation); font-size: var(--palette-typographie-composants-3); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--palette-rayon-conversation-2); padding: var(--palette-espacement-conversation) var(--palette-espacement-cabinet-conversation-3); color: var(--muted);
}
.cmp-footer .enc { display: inline-flex; align-items: center; gap: var(--palette-espacement-cabinet-conversation-9); }
.cmp-footer .enc svg { width: 12px; height: 12px; color: var(--success); }
