/* ═══════════════════════════════════════════════════════════════════
   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 flottant unique ─────────────────────────────────────── */
#lea-talk {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom) + 12px);
  z-index: 1200;
  min-height: 60px;
  border: none;
  border-radius: 999px;
  background: #1a2340;
  color: #fff;
  box-shadow: 0 10px 24px rgba(26, 35, 64, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 20px;
  cursor: pointer;
  font-family: inherit;
}
#lea-talk:active { transform: scale(.98); }
#lea-talk .lea-talk-ico { font-size: 24px; color: #C7A059; flex: none; }
#lea-talk .lea-talk-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
#lea-talk .lea-talk-label { font-size: 17px; font-weight: 700; }
#lea-talk .lea-talk-sub { font-size: 12px; opacity: .75; font-weight: 400; }
@media (min-width: 480px) {
  #lea-talk { left: auto; min-width: 230px; }
}
/* Au-dessus d'un FAB de création visible (Devis / Factures / Planning) */
#lea-talk.lea-above-fab { bottom: calc(76px + env(safe-area-inset-bottom) + 84px); }
#lea-talk[hidden] { display: none; }

/* Planning : la pastille « Aujourd'hui » se décale au-dessus du bouton */
body.lea-on .pv2-today-pill { bottom: calc(76px + env(safe-area-inset-bottom) + 84px) !important; }
body.lea-on.lea-fab-on .pv2-today-pill { bottom: calc(76px + env(safe-area-inset-bottom) + 156px) !important; }

/* 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;
  bottom: calc(76px + env(safe-area-inset-bottom) + 84px);
  z-index: 1190;
  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; }
.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: 52dvh; overflow-y: auto; flex: 0 1 auto; min-height: 0;
}
/* Confirmation ouverte : c'est elle le focus — la conversation et le
   document lui cèdent la place (plafonds réduits), pour que ses
   boutons tiennent dans la feuille sans défilement interne. */
#lea-panel:has(> .lea-confirm:not([hidden])) .lea-conv { max-height: 64px; }
#lea-panel:has(> .lea-confirm:not([hidden])) .lea-doc { max-height: 18dvh; }
.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%; }
#lea-repeat, #lea-aside, #lea-wipe { order: 1; }
#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; }
}
