/* Assistant du PGRPEC : bouton flottant et panneau de conversation.
   N'utilise que les jetons de jetons.css. Tout est préfixé .asst- */

.asst-lanceur,
.asst-panneau,
.asst-panneau * {
  box-sizing: border-box;
}

/* Bouton flottant */
.asst-lanceur {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px 0 14px;
  border: 1px solid var(--marine-800);
  border-radius: 999px;
  background: var(--marine);
  color: var(--blanc);
  font: 500 15px/1 var(--sans);
  cursor: pointer;
  transition: background-color 200ms var(--courbe), transform 200ms var(--courbe);
}
.asst-lanceur:hover { background: var(--marine-800); }
.asst-lanceur:focus-visible,
.asst-panneau :focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.asst-lanceur svg { flex: none; }
.asst-lanceur[hidden] { display: none; }

/* Panneau */
.asst-panneau {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 901;
  display: flex;
  flex-direction: column;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: min(620px, calc(100vh - 40px));
  height: min(620px, calc(100dvh - 40px));
  background: var(--blanc);
  color: var(--encre);
  border: 1px solid var(--ligne);
  border-radius: var(--rayon-carte);
  box-shadow: 0 12px 32px rgba(15, 29, 48, 0.12);
  font: 400 15px/1.5 var(--sans);
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 240ms var(--courbe), transform 240ms var(--courbe);
}
.asst-panneau[hidden] { display: none; }
.asst-panneau.est-ouvert { opacity: 1; transform: none; }

/* En-tête */
.asst-entete {
  position: relative;
  padding: 18px 64px 16px 20px;
  border-bottom: 1px solid var(--ligne);
  background: var(--papier);
}
.asst-libelle {
  margin: 0 0 6px;
  font: 500 11px/1.2 var(--mono);
  letter-spacing: 0.08em;
  color: var(--encre-2);
}
.asst-titre {
  margin: 0;
  font: 600 21px/1.25 var(--serif);
  color: var(--marine);
}
.asst-fermer {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--rayon);
  background: transparent;
  color: var(--encre-2);
  cursor: pointer;
}
.asst-fermer:hover { border-color: var(--ligne); color: var(--encre); background: var(--blanc); }

/* Fil de conversation */
.asst-fil {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.asst-accueil { margin: 0; color: var(--encre-2); }
.asst-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.asst-suggestion {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  background: var(--blanc);
  color: var(--marine);
  font: 500 14px/1.35 var(--sans);
  text-align: left;
  cursor: pointer;
  transition: border-color 200ms var(--courbe), background-color 200ms var(--courbe);
}
.asst-suggestion:hover { border-color: var(--marine); background: var(--papier); }

.asst-message {
  margin: 0;
  max-width: 88%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.asst-message--user {
  align-self: flex-end;
  padding: 10px 14px;
  border-radius: var(--rayon-carte);
  background: var(--marine);
  color: var(--blanc);
}
.asst-message--assistant {
  align-self: flex-start;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--ligne);
  color: var(--encre);
}
.asst-message--erreur {
  align-self: stretch;
  max-width: none;
  padding: 10px 14px;
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  background: var(--papier);
  color: var(--encre-2);
}

/* Indicateur de chargement : trois points, l'orange marque l'activité en cours */
.asst-attente { display: inline-flex; gap: 5px; padding: 6px 0; }
.asst-attente span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  animation: asst-pulse 1s infinite ease-in-out;
}
.asst-attente span:nth-child(2) { animation-delay: 150ms; }
.asst-attente span:nth-child(3) { animation-delay: 300ms; }
@keyframes asst-pulse {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* Saisie */
.asst-pied {
  border-top: 1px solid var(--ligne);
  padding: 12px 16px 12px;
  background: var(--blanc);
}
.asst-formulaire { display: flex; gap: 8px; align-items: flex-end; }
.asst-saisie {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 12px;
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  background: var(--blanc);
  color: var(--encre);
  font: 400 15px/1.4 var(--sans);
  resize: none;
}
.asst-saisie:focus { border-color: var(--marine); outline: none; }
.asst-saisie:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }
.asst-envoyer {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--marine);
  border-radius: var(--rayon);
  background: var(--marine);
  color: var(--blanc);
  cursor: pointer;
}
.asst-envoyer:hover { background: var(--marine-800); }
.asst-envoyer:disabled { opacity: 0.45; cursor: not-allowed; }
.asst-mention {
  margin: 8px 0 0;
  font: 400 12px/1.4 var(--sans);
  color: var(--encre-3);
}

.asst-invisible {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Mobile : plein écran */
@media (max-width: 599px) {
  /* Pastille ronde, sans libellé : elle ne masque plus les boutons de la page. */
  .asst-lanceur { right: 16px; bottom: 16px; width: 52px; min-height: 52px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .asst-panneau {
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .asst-message { max-width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  .asst-lanceur,
  .asst-panneau,
  .asst-suggestion { transition: none; }
  .asst-panneau { transform: none; }
  .asst-attente span { animation: none; opacity: 0.7; }
}
