/* ============================================================================
   LIRISBOT — bouton « Une question ? » et fenêtre de dialogue (layout/lirisbot.php)

   D'après la maquette validée : fenêtre d'environ 380 × 600 en bas à droite,
   bleue, bulles à gauche (Lirisbot) et à droite (visiteur), points d'écriture,
   puces de réponse. Plein écran sous 480 px, hauteur suivie au clavier
   (--lb-hauteur-visible, posée par assets/js/lirisbot.js).

   Tout est rangé sous .lc-lirisbot, classes en lb-… ; aucune règle globale,
   aucune règle sur une balise seule. Les animations ont des noms en lb-….
   ========================================================================== */

.lc-lirisbot {
  --lb-accent: #1f5fbf;
  --lb-accent-fonce: #174a96;
  --lb-accent-doux: #e8f0fb;
  --lb-carte: #ffffff;
  --lb-texte: #1c2430;
  --lb-doux: #5b6675;
  --lb-ligne: #e3e7ec;
  --lb-bulle: #f1f3f6;
  --lb-focus: #f0a35c;
}

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

/* Police de la maquette validée, rendue explicite : le widget n'hérite plus de celle des pages. */
.lc-lirisbot.lc-lirisbot,
.lc-lirisbot.lc-lirisbot * { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

.lc-lirisbot [hidden] { display: none !important; }

/* ---- Bouton d'ouverture ------------------------------------------------- */
.lc-lirisbot .lb-ouvrir {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin: 0;
  padding: 0 20px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--lb-accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 40, 80, .28);
}
.lc-lirisbot .lb-ouvrir:hover { background: var(--lb-accent-fonce); }
.lc-lirisbot .lb-ouvrir svg { width: 24px; height: 24px; flex: none; }

/* Bandeau ou préférences de cookies affichés, menu mobile ouvert, champ de
   la page en cours de saisie : le bouton s'efface (classe posée par le JS). */
.lc-lirisbot.lb-cache .lb-ouvrir { display: none; }

/* ---- Fenêtre ------------------------------------------------------------- */
.lc-lirisbot .lb-fenetre {
  position: fixed;
  top: auto;
  left: auto;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: min(380px, calc(100vw - 24px));
  height: min(600px, calc(100vh - 40px));
  height: min(600px, calc(100dvh - 40px));
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--lb-ligne);
  border-radius: 18px;
  background: var(--lb-carte);
  color: var(--lb-texte);
  font-size: 15px;
  line-height: 1.5;
  text-align: left;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .25);
  transform-origin: bottom right;
}
.lc-lirisbot .lb-fenetre[open] {
  display: flex;
  animation: lb-apparition .2s ease-out;
}
.lc-lirisbot .lb-fenetre:focus:not(:focus-visible) { outline: none; }
.lc-lirisbot .lb-fenetre::backdrop { background: rgba(16, 28, 44, .18); }

@keyframes lb-apparition { from { opacity: 0; transform: translateY(12px) scale(.97); } }

/* ---- En-tête ------------------------------------------------------------- */
.lc-lirisbot .lb-tete {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--lb-accent);
  color: #ffffff;
}
/* Avatar « L » de la maquette : décoratif (aria-hidden), sans image. */
.lc-lirisbot .lb-avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--lb-accent);
  font-size: 17px;
  font-weight: 800;
  line-height: 36px;
  text-align: center;
  user-select: none;
}
.lc-lirisbot .lb-identite { min-width: 0; }
.lc-lirisbot .lb-titre {
  margin: 0;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: normal;
  text-transform: none;
}
.lc-lirisbot .lb-sous-titre {
  margin: 0;
  color: #ffffff;
  font-size: 12px;
  line-height: 1.4;
  opacity: .9;
}
.lc-lirisbot .lb-actions { margin-left: auto; display: flex; gap: 4px; flex: none; }
.lc-lirisbot .lb-icone {
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.lc-lirisbot .lb-icone:hover { background: rgba(255, 255, 255, .16); }
.lc-lirisbot .lb-icone svg { width: 20px; height: 20px; }

/* ---- Fil de la conversation ---------------------------------------------- */
.lc-lirisbot .lb-fil {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lc-lirisbot .lb-msg {
  max-width: 85%;
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-line;
  overflow-wrap: anywhere;
  animation: lb-msg .18s ease-out;
}
.lc-lirisbot .lb-msg--robot {
  align-self: flex-start;
  background: var(--lb-bulle);
  color: var(--lb-texte);
  border-bottom-left-radius: 4px;
}
.lc-lirisbot .lb-msg--moi {
  align-self: flex-end;
  background: var(--lb-accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
@keyframes lb-msg { from { opacity: 0; transform: translateY(6px); } }

/* Points d'écriture : décoratifs (aria-hidden), jamais lus. */
.lc-lirisbot .lb-ecrit {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  background: var(--lb-bulle);
}
.lc-lirisbot .lb-ecrit span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lb-doux);
  animation: lb-point 1s infinite ease-in-out;
}
.lc-lirisbot .lb-ecrit span:nth-child(2) { animation-delay: .15s; }
.lc-lirisbot .lb-ecrit span:nth-child(3) { animation-delay: .3s; }
@keyframes lb-point {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Liens d'action : contacts fixes et liens du catalogue. */
.lc-lirisbot .lb-liens {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 85%;
}
.lc-lirisbot .lb-lien {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--lb-ligne);
  border-radius: 12px;
  background: var(--lb-carte);
  color: var(--lb-texte);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.lc-lirisbot .lb-lien:hover { border-color: var(--lb-accent); color: var(--lb-accent); text-decoration: none; }
.lc-lirisbot .lb-lien svg { width: 18px; height: 18px; flex: none; color: var(--lb-accent); }

/* Sources publiques d'une réponse : titre, puis libellé du type. */
.lc-lirisbot .lb-sources {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 85%;
}
.lc-lirisbot .lb-sources-titre {
  margin: 0;
  color: var(--lb-doux);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.lc-lirisbot .lb-source {
  display: block;
  padding: 8px 14px;
  border: 1px solid var(--lb-ligne);
  border-radius: 12px;
  background: var(--lb-carte);
  color: var(--lb-accent);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.lc-lirisbot .lb-source:hover { border-color: var(--lb-accent); text-decoration: none; }
.lc-lirisbot .lb-source-type {
  display: block;
  margin-top: 2px;
  color: var(--lb-doux);
  font-size: 12px;
  font-weight: 400;
}

/* ---- Puces de réponse ------------------------------------------------------ */
.lc-lirisbot .lb-choix {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 33%;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--lb-ligne);
}
.lc-lirisbot .lb-choix:empty { display: none; }
.lc-lirisbot .lb-puce {
  max-width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 8px 14px;
  border: 1.5px solid var(--lb-accent);
  border-radius: 999px;
  background: var(--lb-carte);
  color: var(--lb-accent);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.lc-lirisbot .lb-puce:hover { background: var(--lb-accent-doux); }

/* ---- Contact permanent : hors du fil et des puces ------------------------ */
.lc-lirisbot .lb-permanent {
  flex: none;
  max-height: 40%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 14px;
  border-top: 1px solid var(--lb-ligne);
}
.lc-lirisbot .lb-permanent-ouvrir {
  display: block;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 8px 14px;
  border: 1.5px solid var(--lb-accent);
  border-radius: 999px;
  background: var(--lb-carte);
  color: var(--lb-accent);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.lc-lirisbot .lb-permanent-ouvrir:hover,
.lc-lirisbot .lb-permanent-ouvrir[aria-expanded="true"] { background: var(--lb-accent-doux); }
.lc-lirisbot .lb-permanent-liens { margin-top: 8px; }
.lc-lirisbot .lb-permanent-liens .lb-liens { width: 100%; }

/* ---- Message de longueur de la question ------------------------------------ */
.lc-lirisbot .lb-alerte {
  flex: none;
  margin: 0;
  padding: 8px 14px 0;
  color: var(--lb-accent-fonce);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* ---- Saisie libre --------------------------------------------------------- */
.lc-lirisbot .lb-saisie {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 6px;
  border-top: 1px solid var(--lb-ligne);
}
.lc-lirisbot .lb-champ {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--lb-ligne);
  border-radius: 999px;
  background: var(--lb-carte);
  color: var(--lb-texte);
  font-size: 16px;                 /* 16 px : pas de zoom automatique sur iOS */
  line-height: 1.3;
}
.lc-lirisbot .lb-champ::placeholder { color: var(--lb-doux); opacity: 1; }
.lc-lirisbot .lb-poser {
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--lb-accent);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.lc-lirisbot .lb-poser:hover { background: var(--lb-accent-fonce); }
.lc-lirisbot .lb-poser svg { width: 20px; height: 20px; }

.lc-lirisbot .lb-pied {
  flex: none;
  margin: 0;
  padding: 2px 14px 10px;
  color: var(--lb-doux);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}
.lc-lirisbot .lb-pied:empty { display: none; }

.lc-lirisbot .lb-invisible {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.lc-lirisbot :focus-visible { outline: 3px solid var(--lb-focus); outline-offset: 2px; }

/* ---- Petits écrans : plein écran, zones sûres, clavier -------------------- */
@media (max-width: 480px) {
  .lc-lirisbot .lb-fenetre {
    top: var(--lb-decalage, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: var(--lb-hauteur-visible, 100vh);
    border: 0;
    border-radius: 0;
  }
  .lc-lirisbot .lb-tete {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
  }
  .lc-lirisbot .lb-fil,
  .lc-lirisbot .lb-choix,
  .lc-lirisbot .lb-saisie,
  .lc-lirisbot .lb-pied {
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
  }
  .lc-lirisbot .lb-pied { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}

/* Petits écrans : contact permanent et message de longueur dans les zones sûres. */
@media (max-width: 480px) {
  .lc-lirisbot .lb-permanent,
  .lc-lirisbot .lb-alerte {
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
  }
}

/* ---- Mouvement réduit : ni animation, ni défilement animé ----------------- */
@media (prefers-reduced-motion: reduce) {
  .lc-lirisbot .lb-fenetre[open],
  .lc-lirisbot .lb-msg,
  .lc-lirisbot .lb-ecrit span { animation: none; }
  .lc-lirisbot .lb-fil { scroll-behavior: auto; }
}

/* Mouvement réduit : les nouveaux blocs n'ont aucune animation ni défilement animé. */
@media (prefers-reduced-motion: reduce) {
  .lc-lirisbot .lb-permanent { scroll-behavior: auto; }
}

@media print {
  .lc-lirisbot { display: none; }
}
