/* ═══════════════════════════════════════════════════════════════════
   lea-talk.css — « Parler à Léa », agent vocal intégré (20/10/2026)
   Préfixe .lea- uniquement (convention maison : dux-, fx-, pv2-, v77-).
   Marque Décroche Toujours : navy #1a2340, or #C7A059, papier #faf6ef.
   Mobile d'abord ; ≥ 900 px : conversation / document en 2 colonnes,
   copie fonctionnelle de la capture démo du site.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Bouton : cercle compact en haut à droite (v298, 07/11/2026) ──
   Décision Daniel, maquette validée le 07/11 : l'ancienne grande
   pastille fixe en bas traversait tout l'écran et recouvrait les
   boutons d'action (Continuer des feuilles du bas, Appeler/Rappelé,
   Mettre à jour…). Le bouton devient un cercle de 46 px ancré en
   haut à droite, dans la bande d'en-tête, juste à gauche de l'icône
   de déconnexion (right: 60px) : il ne peut plus rien recouvrir.
   Le libellé contextuel vit dans une info-bulle affichée 3 s quand
   il change (arrivée sur une vue) — classe .lea-show-bubble posée
   par majBouton (lea-talk.js). Un tap démarre Léa, comme avant. */
#lea-talk {
  position: fixed;
  top: calc(9px + env(safe-area-inset-top, 0px));
  right: 60px;
  z-index: 1200;
  width: 46px;
  height: 46px;
  min-height: 46px;
  border: 2px solid #C7A059;
  border-radius: 50%;
  background: #1a2340;
  color: #C7A059;
  box-shadow: 0 6px 16px rgba(26, 35, 64, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
#lea-talk:active { transform: scale(.96); }
#lea-talk .lea-talk-ico { display: grid; place-items: center; line-height: 0; flex: none; }
#lea-talk .lea-talk-ico svg { width: 21px; height: 21px; }
#lea-talk .lea-dot {
  position: absolute; top: 0; right: 0; width: 11px; height: 11px;
  border-radius: 50%; background: #58b06c; border: 2px solid #faf6ef;
}
#lea-talk .lea-ring {
  position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid rgba(199, 160, 89, .55);
  pointer-events: none; opacity: 0;
}
#lea-talk.lea-show-bubble .lea-ring { animation: lea-pulse 2.6s ease-out infinite; }
@keyframes lea-pulse {
  0% { transform: scale(.85); opacity: .9; }
  70% { transform: scale(1.12); opacity: 0; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #lea-talk.lea-show-bubble .lea-ring { animation: none; }
}
/* Info-bulle : le libellé contextuel, sous le cercle */
#lea-talk .lea-talk-txt {
  position: absolute;
  top: 56px;
  right: -34px;
  width: 228px;
  background: #fff;
  color: #262620;
  border: 1px solid #E4D8C4;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(26, 35, 64, .22);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
  text-align: left;
  opacity: 0;
  transform: translateY(-4px) scale(.97);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#lea-talk .lea-talk-txt::before {
  content: ""; position: absolute; top: -7px; right: 52px;
  width: 12px; height: 12px; background: #fff;
  border-left: 1px solid #E4D8C4; border-top: 1px solid #E4D8C4;
  transform: rotate(45deg);
}
#lea-talk.lea-show-bubble .lea-talk-txt { opacity: 1; transform: none; }
#lea-talk .lea-talk-label { font-size: 14.5px; font-weight: 700; color: #1a2340; }
#lea-talk .lea-talk-sub { font-size: 12px; color: #8a8378; font-weight: 400; margin-top: 2px; }
#lea-talk[hidden] { display: none; }

/* Anciens déclencheurs de dictée création masqués (jamais supprimés) */
.lea-hide { display: none !important; }

/* ── Bannière de reprise de brouillon ───────────────────────────── */
#lea-draft-banner {
  position: fixed;
  left: 16px; right: 16px;
  /* v298 : la pastille du bas n'existe plus, la bannière redescend
     juste au-dessus de la barre de navigation (avant : + 84 px pour
     passer au-dessus de l'ancienne pastille). */
  bottom: calc(76px + env(safe-area-inset-bottom) + 12px);
  /* v326 (16/11/2026) : 1190 → 39. À 1190 la bannière flottait
     au-dessus de TOUTES les feuilles modales de l'app (devis 71,
     planning 41, appels 65) et recouvrait leurs boutons du bas —
     prouvé au navigateur : l'option « Vierge » de la feuille
     « Nouveau devis » était incliquable à la souris. Une bannière
     de rappel ne doit jamais bloquer une action délibérée : elle
     passe sous les feuilles et leurs fonds, et reste visible et
     tappable sur les vues ordinaires. */
  z-index: 39;
  background: #fff;
  border: 1px solid #E4D8C4;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(26, 35, 64, .18);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: #1a2340;
}
#lea-draft-banner[hidden] { display: none; }
#lea-draft-banner .lea-draft-txt { flex: 1; }
#lea-draft-banner button { min-height: 48px; border-radius: 12px; border: 1px solid #D5C6AF; background: #fff; padding: 0 14px; font-weight: 700; cursor: pointer; }
#lea-draft-banner button.lea-draft-go { background: #1a2340; color: #fff; border-color: #1a2340; }

/* ── Feuille ancrée (v229, option 1 de Daniel : la dictée est une
   insertion, pas une destination) ────────────────────────────────
   Le panneau n'est plus une pièce plein écran : c'est une feuille
   modale posée en bas de l'écran courant, qui grandit avec son
   contenu (hauteurs plafonnées, défilement interne). L'application
   reste visible derrière un voile léger ; le voile bloque les clics
   (protection chantier) et un tap dessus signale la porte de sortie.
   aria-modal reste posé côté JS : comportement modal assumé. */
#lea-panel {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(26, 35, 64, .30);
  display: flex; flex-direction: column;
  justify-content: flex-end;
}
#lea-panel[hidden] { display: none; }
#lea-panel > * { background: #f4efe6; box-sizing: border-box; }
#lea-panel > .lea-head { background: #1a2340; border-radius: 18px 18px 0 0; }
#lea-panel > .lea-alert { background: #fdf3e0; }
#lea-panel > .lea-confirm { background: #fff; }
#lea-panel > .lea-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

/* Barre d'état d'écoute : le feedback EST l'interface. Les barres ne
   s'animent que dans l'état « ecoute » posé par lea-talk.js depuis
   les signaux réels (session en cours + prête + micro non suspendu). */
.lea-etat {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px; font-size: 14px; font-weight: 700; color: #1a2340;
  background: #fdf8ec !important; border-bottom: 1px solid #EADFCB;
}
.lea-etat[hidden] { display: none; }
.lea-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; flex: none; }
.lea-bars i { width: 3px; height: 5px; border-radius: 2px; background: #b9ac8f; transform-origin: bottom; }
.lea-etat[data-etat="ecoute"] .lea-bars i { background: #2e7d32; animation: lea-bars-son .8s ease-in-out infinite alternate; }
.lea-etat[data-etat="ecoute"] .lea-bars i:nth-child(2) { animation-delay: .18s; }
.lea-etat[data-etat="ecoute"] .lea-bars i:nth-child(3) { animation-delay: .36s; }
.lea-etat[data-etat="ecoute"] .lea-bars i:nth-child(4) { animation-delay: .54s; }
.lea-etat[data-etat="lea"] .lea-bars i { background: #C7A059; }
.lea-etat[data-etat="coupe"] .lea-bars i { background: #b3261e; }
@keyframes lea-bars-son { from { transform: scaleY(.45); } to { transform: scaleY(2.4); } }
#lea-panel .lea-signal { animation: lea-signal-pouls .5s ease-in-out 2; }
@keyframes lea-signal-pouls {
  0%, 100% { box-shadow: 0 0 0 0 rgba(199, 160, 89, 0); }
  50% { box-shadow: 0 0 0 5px rgba(199, 160, 89, .6); }
}
@media (prefers-reduced-motion: reduce) {
  .lea-etat .lea-bars i, #lea-panel .lea-signal { animation: none !important; }
}
.lea-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #1a2340; color: #fff;
}
.lea-head h2 { font-size: 19px; margin: 0; font-weight: 800; }
.lea-head-txt { flex: 1; min-width: 0; }
#lea-ctx { margin: 2px 0 0; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lea-close {
  width: 48px; height: 48px; flex: none;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.35);
  background: transparent; color: #fff; font-size: 20px; cursor: pointer;
}
.lea-timer { flex: none; text-align: right; font-size: 13px; opacity: .9; }
.lea-timer b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.lea-alert {
  background: #fdf3e0; color: #6b5216; border-bottom: 1px solid #EADFCB;
  padding: 10px 14px; font-size: 15px;
}
.lea-alert[hidden] { display: none; }

.lea-main { flex: 0 1 auto; display: flex; flex-direction: column; min-height: 0; }
.lea-conv {
  flex: 0 1 auto; max-height: 168px; min-height: 0; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.lea-msg { max-width: 92%; padding: 9px 12px; border-radius: 14px; font-size: 16px; line-height: 1.35; }
.lea-msg .lea-who { font-weight: 800; margin-right: 6px; }
.lea-msg.lea { background: #1a2340; color: #fff; align-self: flex-start; border-bottom-left-radius: 4px; }
.lea-msg.lea .lea-who { color: #C7A059; }
.lea-msg.vous { background: #fff; color: #1a2340; align-self: flex-end; border: 1px solid #E4D8C4; border-bottom-right-radius: 4px; }
.lea-msg.encours { opacity: .65; font-style: italic; }
.lea-msg.sys { background: transparent; color: #5b5344; align-self: center; font-size: 14px; text-align: center; }

/* Zone document « papier » */
.lea-doc {
  flex: 0 1 auto; max-height: 34dvh; min-height: 0; overflow-y: auto; margin: 0 12px 6px;
  background: #faf6ef; border: 1px solid #E4D8C4; border-radius: 16px;
  padding: 16px; color: #1a2340;
  box-shadow: 0 4px 14px rgba(26, 35, 64, .08);
}
.lea-doc-vide { color: #8a7f68; font-size: 15px; text-align: center; padding: 16px 8px; }
.lea-doc h3 { margin: 0 0 2px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: #8E692D; }
.lea-doc .lea-doc-entreprise { font-size: 19px; font-weight: 800; margin: 0 0 2px; }
.lea-doc .lea-doc-titre { font-size: 16px; font-weight: 700; margin: 0 0 2px; }
.lea-doc .lea-doc-client { font-size: 15px; color: #44403a; margin: 0 0 10px; }
.lea-doc table { width: 100%; border-collapse: collapse; font-size: 15px; }
.lea-doc td, .lea-doc th { padding: 8px 4px; border-bottom: 1px solid #EDE4D2; text-align: left; vertical-align: top; }
.lea-doc .lea-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lea-doc tr.lea-ligne-nouvelle { animation: lea-in .35s ease-out; background: #fdf6e3; }
@keyframes lea-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .lea-doc tr.lea-ligne-nouvelle { animation: none; } }
.lea-doc .lea-flag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #f7e8c3; color: #6b5216; font-size: 12px; font-weight: 700; white-space: nowrap; }
.lea-doc .lea-ok { display: inline-block; margin-left: 6px; color: #2e7d32; font-size: 13px; font-weight: 700; }
.lea-totaux { margin-top: 10px; font-size: 16px; }
.lea-totaux .lea-trow { display: flex; justify-content: space-between; padding: 3px 4px; }
/* v325 : cartes de recherche tappables (renvoi vers la fiche visée) */
.lea-carte-lien { cursor: pointer; }
.lea-carte-lien .lea-chev { float: right; font-weight: 700; opacity: 0.55; font-size: 1.15em; line-height: 1; }
/* v324 : lignes de ventilation TVA par taux (taux mixtes) — plus
   petites et grisées sous le « Total TVA ». */
.lea-totaux .lea-trow.small { font-size: 0.86em; opacity: 0.75; padding: 1px 4px 1px 14px; }
.lea-totaux .lea-ttc { font-size: 21px; font-weight: 800; border-top: 2px solid #1a2340; margin-top: 6px; padding-top: 8px; }
.lea-doc .lea-carte { border: 1px solid #E4D8C4; border-radius: 12px; padding: 12px; background: #fff; margin-bottom: 10px; font-size: 15px; }
.lea-doc .lea-avant { text-decoration: line-through; opacity: .65; }
.lea-doc .lea-apres { font-weight: 800; }
.lea-doc button.lea-ouvrir {
  width: 100%; min-height: 52px; margin-top: 10px; border: none; border-radius: 12px;
  background: #1a2340; color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
}
.lea-doc .lea-ligne-edit { display: flex; gap: 8px; align-items: center; }
.lea-doc .lea-ligne-edit input {
  width: 92px; min-height: 48px; font-size: 17px; padding: 6px 8px;
  border: 1px solid #D5C6AF; border-radius: 10px; background: #fff;
}

/* Barre de confirmation au doigt — bornée dans la feuille (v229) :
   hauteur plafonnée, défilement interne, ses boutons restent
   atteignables au plus petit viewport. */
.lea-confirm {
  margin: 10px 12px 0; background: #fff; border: 1px solid #E4D8C4; border-radius: 16px; padding: 14px;
  max-height: 42dvh; overflow-y: auto; flex: 0 1 auto; min-height: 0;
}
/* Confirmation ouverte : c'est elle le focus — mais la conversation et
   le document restent LISIBLES (v319, 16/11/2026, constat Daniel en
   dictée réelle : à 64 px / 18 dvh, le récap de Léa était coupé en
   pleine phrase et les totaux du devis invisibles au moment même de
   vérifier). Plafonds rééquilibrés : conversation 88 px (ses dernières
   lignes + sa question), document 30 dvh (lignes + totaux d'un devis
   courant), confirmation 42 dvh. Le bas de .lea-main reçoit un padding
   quand la confirmation est ouverte : la surface de la feuille reste
   continue jusqu'à la carte. */
#lea-panel:has(> .lea-confirm:not([hidden])) .lea-main { padding-bottom: 10px; }
#lea-panel:has(> .lea-confirm:not([hidden])) .lea-conv { max-height: 88px; }
#lea-panel:has(> .lea-confirm:not([hidden])) .lea-doc { max-height: 30dvh; }

/* Confirmation DANS la colonne centrale (v319, suite) : quand le JS a
   déplacé la carte dans #lea-main (cas normal pendant une dictée), la
   colonne devient l'unique zone de défilement — conversation et
   document à hauteur naturelle, la carte suit le document à hauteur
   naturelle aussi. Plus aucune boîte écrasée, plus de bouton tranché. */
#lea-main:has(> .lea-confirm:not([hidden])) {
  display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto;
}
#lea-main:has(> .lea-confirm:not([hidden])) .lea-conv {
  max-height: none; overflow: visible; flex: none;
}
#lea-main:has(> .lea-confirm:not([hidden])) .lea-doc {
  max-height: none; overflow: visible; flex: none;
}
#lea-main > .lea-confirm { margin: 10px 12px 12px; max-height: none; overflow: visible; }
.lea-confirm[hidden] { display: none; }
.lea-confirm h3 { margin: 0 0 6px; font-size: 18px; color: #1a2340; }
.lea-confirm .lea-lettres { font-size: 18px; color: #1a2340; margin: 0 0 4px; }
.lea-confirm .lea-arevoir { color: #8a5a00; font-size: 15px; margin: 0 0 8px; }
.lea-confirm .lea-confirm-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* Pied de la feuille — « Terminer » a sa rangée propre, pleine
   largeur, toujours à la même place (v229, Operator) : les boutons
   secondaires vivent sur la rangée du dessus et ne le déplacent
   jamais quand ils apparaissent. */
.lea-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
#lea-finish { order: 2; flex: 1 1 100%; }
/* v320 (16/11/2026, demande Daniel) : les trois boutons secondaires
   tiennent sur UNE seule ligne — avant, « Tout effacer » tombait sur
   une deuxième rangée. Ils se partagent la largeur en trois parts
   égales, texte resserré, jamais de retour à la ligne. */
#lea-repeat, #lea-aside, #lea-wipe {
  order: 1; flex: 1 1 0; min-width: 0;
  padding: 0 4px; font-size: 14.5px; white-space: nowrap;
}
#lea-panel .lea-btn[hidden] { display: none !important; }
.lea-btn {
  min-height: 52px; border-radius: 14px; padding: 0 18px;
  font-size: 16px; font-weight: 700; cursor: pointer; border: 1px solid #D5C6AF; background: #fff; color: #1a2340;
}
.lea-btn-primary { flex: 1; background: #1a2340; color: #fff; border-color: #1a2340; min-height: 56px; }
.lea-btn-gold { flex: 1; background: #C7A059; color: #1a2340; border-color: #C7A059; min-height: 56px; font-size: 17px; }
.lea-btn-link { border: none; background: transparent; text-decoration: underline; font-weight: 600; min-height: 48px; }
.lea-btn[disabled] { opacity: .45; cursor: default; }

/* Écran d'état / erreur (dans la feuille) — borné et défilant (v229) */
.lea-screen { padding: 22px 16px; overflow-y: auto; max-height: 64dvh; flex: 0 1 auto; min-height: 0; }
.lea-screen h3 { font-size: 20px; margin: 0 0 8px; color: #1a2340; }
.lea-screen p { font-size: 16px; color: #44403a; margin: 0 0 14px; line-height: 1.45; }
.lea-screen .lea-confirm-btns { display: flex; flex-direction: column; gap: 8px; }

/* Compteur deux lignes (carte Abonnement) */
.lea-min-lines { border-top: 1px solid #EDE4D2; margin-top: 4px; }
.lea-min-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; min-height: 48px; }
.lea-min-line + .lea-min-line { border-top: 1px solid #EDE4D2; }
.lea-min-line .lea-min-titre { font-weight: 700; color: #1a2340; font-size: 15px; }
.lea-min-line .lea-min-sub { font-size: 13px; color: #77705f; }
.lea-min-line .lea-min-num { font-size: 19px; font-weight: 800; color: #1a2340; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lea-offertes { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #eef5e9; color: #2e7d32; font-size: 12px; font-weight: 700; }
.lea-min-resume { font-size: 14px; color: #44403a; margin: 8px 2px 0; }
.lea-min-resume[hidden] { display: none; }

/* Desktop (v229) : la feuille devient une carte ancrée en bas à
   droite ; l'application reste visible à gauche et en haut. Colonne
   unique à toutes les largeurs — l'ancien 50/50 conversation navy /
   document (messages système illisibles sur navy) disparaît. */
@media (min-width: 900px) {
  #lea-panel { align-items: flex-end; padding: 14px; }
  #lea-panel > * { width: min(560px, calc(100vw - 28px)); box-shadow: 0 18px 50px rgba(26, 35, 64, .35); }
  #lea-panel > .lea-foot { border-radius: 0 0 18px 18px; }
  .lea-conv { max-height: 190px; }
  .lea-doc { max-height: 38vh; }
  /* Confirmation ouverte sur desktop : la place existe, on ne compacte
     pas comme au téléphone (v319). */
  #lea-panel:has(> .lea-confirm:not([hidden])) .lea-conv { max-height: 150px; }
  #lea-panel:has(> .lea-confirm:not([hidden])) .lea-doc { max-height: 34vh; }
}
