/* ==========================================================================
   ViSAgree — L'ASSISTANT : fenêtre de discussion
   Mobile-first. Boutons fins (36-40 px de haut, radius 6-8 px, jamais de forme
   pilule). Aucun élément ne dépasse de l'écran, même sur un téléphone de 320 px.
   ========================================================================== */

/* Le bouton d'ouverture : discret, en bas à droite, au-dessus de la barre
   d'onglets (sinon il la recouvrirait et deviendrait intouchable). */
.ag-launcher {
  position: fixed;
  right: 14px;
  bottom: 78px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #6C4CE0, #4A2FB8);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15, 15, 26, .18);
  cursor: pointer;
}
.ag-launcher:active { transform: translateY(1px); }
.ag-launcher svg { width: 18px; height: 18px; }

/* La fenêtre : plein écran sur téléphone, panneau ancré sur ordinateur. */
.ag-panel {
  position: fixed;
  z-index: 1300;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 -8px 30px rgba(15, 15, 26, .22);
}

.ag-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #6C4CE0, #4A2FB8);
  color: #fff;
  flex: 0 0 auto;
}
.ag-head-in { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.ag-title { font-size: 15px; font-weight: 600; }
.ag-quota { font-size: 12px; opacity: .85; }
.ag-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.ag-close svg { width: 16px; height: 16px; }

/* La conversation : c'est elle qui défile, jamais la page derrière. */
.ag-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}
.ag-msg {
  max-width: 92%;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.5;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ag-agent { align-self: flex-start; background: #fff; color: #1a1a2e; box-shadow: 0 1px 4px rgba(15, 15, 26, .07); }
.ag-user { align-self: flex-end; background: #6C4CE0; color: #fff; }
.ag-attente { align-self: flex-start; color: #6b6b7b; font-size: 14px; padding: 10px 12px; }
.ag-erreur { align-self: flex-start; background: #fff4f4; color: #a12b2b; border: 1px solid #f0d0d0; }

/* Les suggestions : des boutons courts, sur leur propre ligne, qui passent à la
   ligne automatiquement. Aucun ne peut être coupé. */
.ag-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.ag-chip {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #4A2FB8;
  background: #fff;
  border: 1px solid #ddd6f5;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
}
.ag-chip:active { background: #f3f0fd; }

/* La zone de saisie : fixe en bas, jamais recouverte par le clavier virtuel. */
.ag-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #eceaf3;
}
.ag-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 12px;
  font-size: 16px; /* 16 px : en dessous, iOS zoome automatiquement au focus */
  color: #1a1a2e;
  background: #f7f6fb;
  border: 1px solid #e4e1ee;
  border-radius: 8px;
}
.ag-input:focus { outline: none; border-color: #6C4CE0; background: #fff; }
.ag-send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #6C4CE0;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.ag-send svg { width: 18px; height: 18px; }
.ag-send[disabled] { opacity: .5; cursor: default; }

.ag-foot {
  flex: 0 0 auto;
  padding: 0 12px 12px;
  font-size: 11.5px;
  color: #7b7b8b;
  background: #fff;
  text-align: center;
}

/* Ordinateur : la fenêtre devient un panneau ancré, on ne masque pas tout l'écran
   pour une question qu'on veut poser en regardant ses dossiers. */
@media (min-width: 768px) {
  .ag-panel {
    left: auto;
    right: 18px;
    bottom: 18px;
    top: auto;
    width: 400px;
    height: 620px;
    max-height: calc(100vh - 36px);
    border-radius: 14px;
    overflow: hidden;
  }
  .ag-launcher { bottom: 18px; }
}
