/* Écran de conversation d'ABC Chat IA : en-tête, messages (colonne unique façon
   premium), écran vide et composeur flottant.
   La liste des conversations vit dans panneau.css, les briques génériques dans
   composants.css, les couleurs dans themes.css. */

/* ---------- En-tête : sélecteurs (pastilles) et coût ---------- */

/* Le chevron maison (--fleche-select) est deux petits triangles qui se rejoignent.
   À 5 px ils formaient un gros triangle plein qui pesait plus lourd que le texte de la
   pastille : 4 px, et l'aplomb revient. Même dessin sur l'écran Comparer. */
#entete select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 38px;
  max-width: 180px;
  padding: 6px 28px 6px 13px;
  border: 1px solid var(--bordure-forte);
  border-radius: 999px;
  background-color: var(--fond-panneau);
  background-image: var(--fleche-select);
  background-position: calc(100% - 15px) calc(50% - 1px), calc(100% - 11px) calc(50% - 1px);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  font-size: 0.88rem;
  font-weight: 550;
}
#entete select:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--bordure-forte)); box-shadow: var(--ombre); }
#entete select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--halo-focus);
}

#coutConversation {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--texte-doux);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Échanges : étiquette « qui » + bulle ---------- */

.tour {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.tour .qui {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.75rem;   /* 12 px : le minimum absolu fixé par DESIGN.md */
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--texte-doux);
}
.tour .qui .av {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  line-height: 1;   /* sans ça la lettre est calée sur l'interligne, pas sur le carré */
  font-weight: 800;
  color: #fff;
  flex: none;
}
.tour.moi .qui .av { background: var(--texte); }
.tour.ia .qui .av { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.tour.ia .qui .av .icone { color: #fff; }

.message {
  padding: 14px 18px;
  border-radius: var(--r-md);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  line-height: 1.62;
  text-wrap: pretty;
  font-size: 0.97rem;
}
.message.moi {
  background: var(--fond-message-moi);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.message.ia {
  background: var(--fond-message-ia);
  border: 1px solid var(--bordure);
  box-shadow: var(--ombre);
}

/* Fiche technique sous la réponse (modèle · tokens · coût · temps). Elle se collait à
   la dernière ligne du texte et se lisait comme une phrase de plus : un filet fin la
   remet à sa place, celle d'un pied de page. */
.message .infos {
  display: block;
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid var(--bordure);
  font-family: var(--mono);
  font-size: 0.75rem;   /* 12 px : le minimum absolu fixé par DESIGN.md */
  color: var(--texte-doux);
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

/* Attente : « L'IA réfléchit » avec trois points tricolores. */
.message.attente {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--texte-doux);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.points-reflexion { display: inline-flex; gap: 5px; }
.points-reflexion span { width: 7px; height: 7px; border-radius: 50%; }
.points-reflexion span:nth-child(1) { background: var(--accent); }
.points-reflexion span:nth-child(2) { background: var(--accent-2); }
.points-reflexion span:nth-child(3) { background: var(--accent-3); }

/* Erreur : bandeau centré, discret. */
.message.erreur {
  align-self: center;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 560px;
  padding: 11px 15px;
  border-radius: var(--r-sm);
  background: var(--fond-erreur);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 0.9rem;
  text-align: left;
}
.message.erreur .icone { margin-top: 2px; }

/* ---------- Écran vide (premier contact) ---------- */

.ecran-vide {
  margin: auto;
  max-width: 520px;
  padding: 24px 12px;
  text-align: center;
}
.motif-tricolore {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}
.motif-tricolore span { width: 10px; height: 10px; border-radius: 50%; }
.motif-tricolore span:nth-child(1) { background: var(--accent); }
.motif-tricolore span:nth-child(2) { background: var(--accent-2); }
.motif-tricolore span:nth-child(3) { background: var(--accent-3); }

.ecran-vide .salutation {
  margin: 0 0 6px;
  font-size: 1.8rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
/* `balance` plutôt que `pretty` : sur deux lignes, `pretty` laissait « ci-dessous. »
   tout seul en dessous ; `balance` répartit la phrase à parts égales. */
.ecran-vide .sous-titre { margin: 0 0 22px; color: var(--texte-doux); text-wrap: balance; }

.suggestions { display: flex; flex-direction: column; gap: 10px; }
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 11px 15px;
  border: 1px solid var(--bordure);
  border-radius: var(--r-md);
  background: var(--fond-panneau);
  color: var(--texte);
  text-align: left;
  text-wrap: pretty;
  box-shadow: var(--ombre);
}
.suggestion:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--bordure));
  box-shadow: var(--ombre-moyenne);
  translate: 0 -1px;
}
.suggestion:nth-child(1) .icone { color: var(--accent); }
.suggestion:nth-child(2) .icone { color: var(--accent-2); }
.suggestion:nth-child(3) .icone { color: var(--accent-3); }

/* ---------- Composeur (carte flottante) ---------- */

.boite-saisie {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  max-width: 720px;
  margin: 0 auto;
  pointer-events: auto;
  padding: 8px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre-flottant);
}
.boite-saisie:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--bordure-forte));
  box-shadow: var(--ombre-flottant), 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

#saisie {
  flex: 1;
  min-height: 44px;
  max-height: 180px;
  resize: none;
  padding: 12px 10px;
  border: none;
  background: transparent;
  outline: none;
  line-height: 1.5;
}
#saisie:focus-visible { outline: none; }

#btnAmeliorer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--bordure);
  border-radius: 12px;
  background: var(--fond-panneau-2);
  color: var(--texte-doux);
}
#btnAmeliorer:hover { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, var(--bordure)); }

/* Retrait plus court du côté de l'icône (14 contre 16) : à retraits égaux, un avion en
   papier pèse moins qu'un mot et le contenu semble poussé vers la droite. */
#btnEnvoyer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px 0 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-texte);
  font-weight: 600;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 38%, transparent);
}
#btnEnvoyer:hover:not(:disabled) { filter: brightness(1.04); }

.note-saisie {
  max-width: 720px;
  margin: 8px auto 0;
  font-size: 0.75rem;
  color: var(--texte-doux);
  text-align: center;
  text-wrap: pretty;
}

/* L'alerte de conversation longue doit se distinguer de la note de vie privée juste
   au-dessus, sinon elle se lit comme une ligne de plus et personne ne la voit : texte
   à pleine force et icône, sans virer au rouge (ce n'est pas une erreur). */
.note-saisie.contexte-long {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--texte);
}
.note-saisie.contexte-long svg { flex: none; color: var(--accent); }

/* ---------- Écrans tactiles : viser au pouce ---------- */

@media (pointer: coarse) {
  #entete select { min-height: 44px; }
}

/* ---------- Téléphone ---------- */

@media (max-width: 760px), (max-height: 500px) and (max-width: 950px) and (pointer: coarse) {
  /* Chaque sélecteur garde sa taille dans la ligne qui défile (voir .selecteurs). */
  #entete select {
    flex: none;
    max-width: 54vw;
    scroll-snap-align: start;
  }

  /* La saisie prend toute la largeur, les deux boutons se rangent en dessous : on
     retrouve une vraie zone d'écriture au lieu d'une fente de 180 px. */
  .boite-saisie {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
  }
  #saisie {
    flex: 1 1 100%;
    padding: 4px 2px;
    min-height: 40px;
  }
  /* Rayons concentriques : la carte est arrondie à 20 px et retirée de 10 px, donc les
     boutons qu'elle contient valent 10 px. À 12 px (le réglage du grand écran, où le
     retrait n'est que de 8 px) leur courbe ne suivait plus celle de la carte. */
  #btnAmeliorer, #btnEnvoyer { border-radius: 10px; }
  #btnAmeliorer { order: 1; }
  #btnEnvoyer { order: 2; margin-left: auto; }

  .note-saisie { margin-top: 7px; font-size: 0.7rem; }

  .ecran-vide { padding: 8px 2px; }
  .ecran-vide .salutation { font-size: 1.5rem; }
  .ecran-vide .sous-titre { margin-bottom: 18px; font-size: 0.95rem; }
  .suggestion { font-size: 0.92rem; }
}

/* Téléphone couché : la saisie ne doit pas dévorer les quelques lignes de conversation.
   La largeur, elle, ne manque pas : les deux boutons reprennent leur place à côté du
   champ au lieu de coûter une rangée entière. */
@media (pointer: coarse) and (max-height: 500px) and (min-width: 500px) {
  .boite-saisie { flex-wrap: nowrap; gap: 6px; padding: 8px; }
  #btnAmeliorer, #btnEnvoyer { border-radius: 12px; }   /* retrait 8 px → 20 - 8 */
  #saisie {
    flex: 1 1 auto;
    max-height: 84px;
    padding: 8px 8px;
  }
  #btnEnvoyer { margin-left: 0; }
  .ecran-vide .salutation { font-size: 1.25rem; }
  .motif-tricolore { margin-bottom: 10px; }
}

/* Petit téléphone, clavier ouvert (voir mise-en-page.css) : les boutons reviennent à
   côté du champ, sinon la rangée du bas — donc « Envoyer » — sort de l'écran. */
@media (pointer: coarse) and (max-height: 400px) and (max-width: 500px) {
  .boite-saisie { flex-wrap: nowrap; gap: 6px; padding: 8px; }
  #btnAmeliorer, #btnEnvoyer { border-radius: 12px; }   /* retrait 8 px → 20 - 8 */
  #saisie {
    flex: 1 1 auto;
    max-height: 56px;
    padding: 8px;
  }
  /* Le mot « Envoyer » vaut 110 px : rendus au texte qu'on est en train d'écrire.
     L'icône avion suffit à ce moment-là, et le bouton reste nommé pour les lecteurs
     d'écran (aria-label dans index.html). */
  #btnEnvoyer {
    margin-left: 0;
    padding: 0;
    width: 48px;
    min-width: 48px;
  }
  #btnEnvoyer .libelle { display: none; }
}
