/* Assistant IA — bouton flottant bas-gauche + panneau chat.
   Tokens du design system d'index.html (--accent, --ink, --paper, --line, --ease…). */

.assist-fab {
  position: fixed; inset-inline-start: 1.15rem; bottom: 1.15rem; z-index: 46;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem .95rem; border-radius: 999px; cursor: pointer;
  font: 600 .92rem "General Sans", system-ui, sans-serif;
  background: var(--ink); color: var(--paper);
  border: 1px solid rgba(16, 22, 35, .9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), var(--shadow-md);
  transition: box-shadow .3s, transform .3s var(--ease);
}
.assist-fab:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), var(--shadow-lg); transform: translateY(-1px); }
.assist-fab img { display: block; border-radius: 4px; }
.assist-fab[aria-expanded="true"] { background: var(--accent-ink); border-color: var(--accent-ink); }

.assist-panel {
  position: fixed; inset-inline-start: 1.15rem; bottom: 4.4rem; z-index: 47;
  width: min(24rem, calc(100vw - 2.3rem));
  /* Le panneau est un <section> : sans ce reset il hérite du padding 5.5rem
     des sections de page, qui mange 176 px de hauteur utile en pure zone vide. */
  padding: 0;
  max-height: 70vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: assist-pop .35s var(--ease);
}
@keyframes assist-pop { from { opacity: 0; transform: translateY(10px); } }
/* L'attribut hidden doit gagner sur display:flex (même motif que .modepanel[hidden]). */
.assist-panel[hidden] { display: none; }

.assist-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem .9rem; border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
}
.assist-head b { font-size: .95rem; }
.assist-head img { border-radius: 4px; }
.assist-badge {
  font-family: var(--mono); font-size: .6rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent-ink); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: .12rem .5rem;
}
.assist-close {
  margin-inline-start: auto; width: 1.8rem; height: 1.8rem;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  background: var(--paper); color: var(--ink-soft); font-size: 1.05rem; line-height: 1;
}
.assist-close:hover { color: var(--ink); border-color: var(--line-strong); }

.assist-msgs {
  flex: 1 1 auto; overflow-y: auto; min-height: 8rem;
  padding: .9rem; display: flex; flex-direction: column; gap: .55rem;
}
.assist-msg {
  max-width: 88%; padding: .55rem .8rem; border-radius: 12px;
  font-size: .9rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.assist-user { align-self: flex-end; background: var(--ink); color: var(--paper); border-end-end-radius: 4px; }
.assist-assistant {
  align-self: flex-start; background: var(--paper-soft); color: var(--ink);
  border: 1px solid var(--line); border-end-start-radius: 4px;
}
.assist-typing { color: var(--ink-soft); font-style: italic; }
.assist-typing span {
  display: inline-block; width: .32rem; height: .32rem; border-radius: 50%;
  background: var(--accent); margin-inline-end: .15rem;
  animation: assist-dot 1s infinite var(--ease);
}
.assist-typing span:nth-child(2) { animation-delay: .15s; }
.assist-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes assist-dot { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.assist-suggs { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .9rem .6rem; }
.assist-suggs button {
  font: 500 .78rem "General Sans", system-ui, sans-serif; cursor: pointer;
  padding: .35rem .7rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink-soft);
  transition: color .2s, border-color .2s;
}
.assist-suggs button:hover { color: var(--accent-ink); border-color: var(--accent-ink); }

.assist-bar { display: flex; gap: .5rem; padding: .6rem .9rem; border-top: 1px solid var(--line); }
.assist-bar input {
  flex: 1 1 auto; min-width: 0; padding: .55rem .75rem;
  font: 400 .9rem "General Sans", system-ui, sans-serif;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--paper); color: var(--ink);
}
.assist-bar input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.assist-bar button {
  padding: .55rem .9rem; border-radius: 10px; cursor: pointer;
  font: 600 .85rem "General Sans", system-ui, sans-serif;
  background: var(--accent); color: #fff; border: 1px solid var(--accent-ink);
}
.assist-bar button:disabled { opacity: .55; cursor: wait; }

.assist-foot {
  margin: 0; padding: 0 .9rem .7rem;
  font-size: .68rem; line-height: 1.45; color: var(--ink-soft);
}

/* Mobile : plein écran */
@media (max-width: 640px) {
  .assist-panel { inset: 0; width: 100vw; max-height: none; border-radius: 0; border: 0; }
}

/* ═══ Bannière de contexte : d'où l'assistant a été appelé ═══ */
.assist-ctx {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .9rem; border-bottom: 1px solid var(--line);
  background: rgba(255, 107, 26, .07); color: var(--accent-ink);
  font-size: .74rem; line-height: 1.4;
}
.assist-ctx[hidden] { display: none; }
.assist-ctx-t { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.assist-ctx-off {
  flex: none; width: 1.4rem; height: 1.4rem; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--paper); color: var(--ink-soft); font-size: .9rem; line-height: 1;
}
.assist-ctx-off:hover { color: var(--ink); border-color: var(--accent-ink); }

/* ═══ Ancrages contextuels : bouton « Demander » près de chaque étape ═══ */
.ctx-row { margin-top: .9rem; text-align: end; }
.ctx-ask {
  display: inline-flex; align-items: center; gap: .3rem; cursor: pointer;
  font: 500 .74rem "General Sans", system-ui, sans-serif;
  padding: .24rem .64rem; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  transition: color .25s, border-color .25s, background .25s;
}
.ctx-ask:hover,
.ctx-ask:focus-visible,
.card:hover .ctx-ask,
.step:hover .ctx-ask,
.rsec:hover .ctx-ask {
  color: var(--accent-ink); border-color: var(--accent-ink); background: rgba(255, 107, 26, .07);
}
.ctx-ask:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Bande sombre (les 4 modes) : mêmes règles, tokens sombres */
.darkband .ctx-ask { border-color: var(--dark-line); color: var(--dark-fg-soft); }
.darkband .ctx-ask:hover,
.darkband .ctx-ask:focus-visible,
.darkband .mstep:hover .ctx-ask {
  color: var(--accent); border-color: var(--accent);
}

/* Reduced motion : aucune animation ni transition */
@media (prefers-reduced-motion: reduce) {
  .assist-panel { animation: none; }
  .assist-typing span { animation: none; opacity: .7; }
  .assist-fab { transition: none; }
  .assist-fab:hover { transform: none; }
  .ctx-ask { transition: none; }
}
