/* ─── Bulle flottante ───
   Position fixe unique (ne bouge plus selon la présence ou non de la
   bottom-nav) — assez haute pour ne jamais chevaucher la nav (~64px) sur
   les pages qui l'ont, tout en restant confortable sur celles qui ne
   l'ont pas. */
#assistant-bubble {
  position: fixed;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  box-shadow: 0 6px 18px rgba(37,99,235,0.45);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 999998; /* sous les overlays (99999+) mais au-dessus de tout le reste */
  transition: transform .15s ease;
}
#assistant-bubble:active { transform: scale(0.92); }

/* ─── Overlay conversation ─── */
#assistant-overlay {
  position: fixed; inset: 0;
  z-index: 999999;
  background: var(--bg-root, #0b1220);
  display: flex; flex-direction: column;
}

/* Header — réduit, plus compact */
#asst-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top,0px) + 8px) 14px 10px;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  flex-shrink: 0;
}
#asst-topbar-info { display: flex; align-items: center; gap: 8px; }
#asst-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#asst-title { color: white; font-size: 14px; font-weight: 700; line-height: 1.2; }
#asst-sub   { color: rgba(255,255,255,0.8); font-size: 11px; line-height: 1.2; margin-top: 1px; }
#asst-close {
  background: none; border: none; color: white;
  padding: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

#asst-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
  background: url('../../img/chat-bg.png') repeat, var(--bg-root, #0b1220);
  background-size: 420px auto, auto;
}
.asst-msg-row { display: flex; }
.asst-msg-row.me  { justify-content: flex-end; }
.asst-msg-row.bot { justify-content: flex-start; }
/* Colonne bulle + feedback — le max-width (78%, comme avant) vit ici plutôt
   que sur .asst-bubble directement, pour laisser la ligne 👍/👎 s'empiler
   dessous sans élargir toute la ligne de message. */
.asst-msg-col { display: flex; flex-direction: column; gap: 4px; max-width: 78%; }
.asst-msg-row.me  .asst-msg-col { align-items: flex-end; }
.asst-msg-row.bot .asst-msg-col { align-items: flex-start; }
.asst-bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.asst-msg-row.me  .asst-bubble { background: var(--blue, #2563eb); color: white; border-bottom-right-radius: 4px; }
.asst-msg-row.bot .asst-bubble { background: var(--bg-card2, #1a2436); color: var(--text-1, #fff); border-bottom-left-radius: 4px; }
.asst-bubble.pop-in { animation: asstPop .18s ease; }
@keyframes asstPop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Feedback 👍/👎 sous une réponse de l'assistant */
.asst-feedback { display: flex; gap: 6px; padding-left: 4px; }
.asst-fb-btn {
  background: none; border: none; cursor: pointer;
  font-size: 15px; padding: 2px 6px; border-radius: 8px;
  opacity: .55; transition: opacity .15s, background .15s;
}
.asst-fb-btn:active { background: var(--bg-card2, #1a2436); }
.asst-fb-btn:disabled { cursor: default; }
.asst-fb-btn.asst-fb-picked { opacity: 1; background: var(--bg-card2, #1a2436); }

/* Carte d'action en attente (Confirmer/Annuler) — bouton natif, pas de
   confiance dans le texte généré par le modèle pour déclencher une action */
.asst-action-card {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-card2, #1a2436);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 2px;
}
.asst-action-preview { font-size: 13px; color: var(--text-1, #fff); line-height: 1.4; }
.asst-action-recipient { font-size: 12px; color: var(--text-3, #8896ab); margin-top: 4px; }
.asst-action-btns { display: flex; gap: 8px; margin-top: 10px; }
.asst-action-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 9px;
  border: none;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
}
.asst-action-confirm { background: var(--blue, #2563eb); color: white; }
.asst-action-cancel  { background: transparent; border: 1px solid var(--border, rgba(255,255,255,0.15)); color: var(--text-2, #ccc); }
.asst-action-btn:disabled { opacity: .6; cursor: default; }
.asst-action-status { font-size: 12px; color: var(--text-3, #8896ab); }
.asst-action-card.asst-action-done       { border-color: rgba(16,185,129,.4); }
.asst-action-card.asst-action-cancelled  { border-color: rgba(239,68,68,.3); }

.asst-typing { display: flex; gap: 4px; padding: 12px 14px; }
.asst-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3, #8896ab);
  animation: asstTyping 1.2s infinite ease-in-out;
}
.asst-typing span:nth-child(2) { animation-delay: .15s; }
.asst-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes asstTyping { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Barre d'input — décollée du bord, séparée visuellement du fil de discussion */
#asst-input-bar {
  flex-shrink: 0;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  background: var(--bg-card, #101a2c);
}

@media (max-width: 360px) {
  #assistant-bubble { width: 50px; height: 50px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}