/* ==========================================================================
   Design system du portail ZS AI — feuille partagée par toutes les pages.
   Jetons (couleurs, ombres, rayons) puis composants : en-tête, boutons,
   cartes, puces d'état, bulles de chat, saisie, toast, focus clavier.
   Contrastes conformes WCAG AA (texte secondaire ≥ 4.5:1 sur fond blanc).
   ========================================================================== */

:root {
  --bleu: #0070C0; --bleu-fonce: #005a9c; --bleu-pale: #e9f2fa;
  --rouge: #C00000; --vert: #2e7d32; --ambre: #b98300;
  --fond: #f7f7f5; --carte: #ffffff;
  --bord: #d9d9d9; --bord-leger: #e9e9e6;
  --encre: #1a1a1a; --texte-2: #444444; --texte-3: #5f5f5f;
  --gris: #f4f4f2;
  --ombre-1: 0 1px 3px rgba(26, 26, 26, .06);
  --ombre-2: 0 6px 18px rgba(26, 26, 26, .10);
  --rayon: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14.5px/1.55 "Segoe UI", Arial, sans-serif;
  color: var(--encre);
  background: var(--fond);
}

/* --- focus clavier visible partout ------------------------------------- */
:focus-visible {
  outline: 2px solid var(--bleu);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- en-tête commun ------------------------------------------------------ */
.entete {
  background: var(--carte);
  border-bottom: 3px solid var(--bleu);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.entete .marque {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  background: var(--bleu); color: #fff;
  font-weight: 700; font-size: 15px; letter-spacing: .5px;
  border-radius: 8px;
  user-select: none;
}
.entete h1 { font-size: 19px; margin: 0; color: var(--bleu); letter-spacing: .3px; }
.entete .sous { color: var(--texte-3); font-size: 12.5px; }
.entete a.retour {
  text-decoration: none; color: var(--texte-3);
  padding: 4px 8px; border-radius: 6px; transition: background .15s, color .15s;
}
.entete a.retour:hover { background: var(--bleu-pale); color: var(--bleu-fonce); }
.entete .droite { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* --- formulaires --------------------------------------------------------- */
select, input, textarea, button { font: inherit; }
select, input[type=text], textarea {
  padding: 6px 9px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  background: var(--carte);
  color: var(--encre);
}
select:hover { border-color: #c0c0c0; }

/* --- boutons ------------------------------------------------------------- */
button, a.bouton {
  padding: 7px 14px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  background: var(--carte);
  color: var(--encre);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
button:hover, a.bouton:hover { background: var(--gris); border-color: #c4c4c4; }
button:active, a.bouton:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; transform: none; }
button.primaire, a.bouton.primaire {
  background: var(--bleu); border-color: var(--bleu); color: #fff; font-weight: 600;
}
button.primaire:hover, a.bouton.primaire:hover {
  background: var(--bleu-fonce); border-color: var(--bleu-fonce);
  box-shadow: var(--ombre-1);
}
button.danger { color: var(--rouge); border-color: var(--rouge); }
button.danger:hover { background: #fdf3f3; }
button.discret {
  border: none; background: none; color: var(--texte-3);
  padding: 3px 8px; font-size: 12.5px;
}
button.discret:hover { background: var(--bleu-pale); color: var(--bleu-fonce); }

/* --- cartes -------------------------------------------------------------- */
.carte {
  background: var(--carte);
  border: 1px solid var(--bord-leger);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-1);
  padding: 20px 24px;
}

/* --- puces d'état --------------------------------------------------------- */
.puce {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--carte);
  border: 1px solid var(--bord-leger);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--texte-2);
  box-shadow: var(--ombre-1);
}
.puce .rond {
  width: 9px; height: 9px; border-radius: 50%;
  background: #b5b5b5; flex: none;
  transition: background .3s;
}
.puce.ok .rond { background: var(--vert); }
.puce.ko .rond { background: var(--rouge); }

/* --- pages de chat -------------------------------------------------------- */
.page-chat { height: 100%; display: flex; flex-direction: column; }
.page-chat main { flex: 1; overflow-y: auto; }
.conversation { max-width: 880px; margin: 0 auto; padding: 20px 22px 10px; }

.intro {
  background: var(--carte);
  border: 1px solid var(--bord-leger);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-1);
  padding: 16px 20px;
  color: var(--texte-2);
  font-size: 13.5px;
}
.intro b { color: var(--encre); }

.msg { margin: 14px 0; display: flex; }
.msg .bulle {
  position: relative;
  max-width: 85%;
  padding: 11px 16px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.msg.moi { justify-content: flex-end; }
.msg.moi .bulle { background: var(--bleu); color: #fff; border-bottom-right-radius: 3px; }
.msg.ia .bulle {
  background: var(--carte);
  border: 1px solid var(--bord-leger);
  border-bottom-left-radius: 3px;
  box-shadow: var(--ombre-1);
}
.msg.ia .bulle.erreur { border-color: var(--rouge); color: var(--rouge); }

/* bouton « copier » au survol d'une réponse IA */
.btn-copier {
  position: absolute; top: 6px; right: 6px;
  opacity: 0;
  font-size: 12px; padding: 2px 9px;
  background: var(--carte);
  transition: opacity .15s, background .15s;
}
.msg.ia .bulle:hover .btn-copier, .btn-copier:focus-visible { opacity: 1; }

/* indicateur d'attente animé */
.attente { color: var(--texte-3); font-style: italic; }
.attente .pts span {
  display: inline-block; width: 5px; height: 5px; margin-left: 3px;
  border-radius: 50%; background: var(--bleu);
  animation: zs-pulse 1.2s infinite ease-in-out;
}
.attente .pts span:nth-child(2) { animation-delay: .2s; }
.attente .pts span:nth-child(3) { animation-delay: .4s; }
@keyframes zs-pulse {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* zone de saisie */
.saisie { background: var(--carte); border-top: 1px solid var(--bord); padding: 12px 22px 14px; }
.saisie .ligne { max-width: 880px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
.saisie textarea {
  flex: 1; resize: none;
  padding: 10px 12px;
  border-radius: 8px;
  max-height: 170px;
  transition: border-color .15s;
}
.saisie textarea:focus { border-color: var(--bleu); outline: none; }
.saisie .note {
  max-width: 880px; margin: 7px auto 0;
  color: var(--texte-3); font-size: 12px;
  display: flex; gap: 14px; flex-wrap: wrap;
}
.saisie .note .usage { margin-left: auto; }

/* --- toast de notification ------------------------------------------------ */
.toast {
  position: fixed; bottom: 18px; right: 18px;
  max-width: 460px;
  padding: 11px 16px;
  border-radius: 8px;
  color: #fff;
  display: none;
  z-index: 40;
  white-space: pre-wrap;
  box-shadow: var(--ombre-2);
}
.toast.ok { background: var(--vert); display: block; }
.toast.erreur { background: var(--rouge); display: block; }

/* --- pied de page ---------------------------------------------------------- */
.pied { text-align: center; color: var(--texte-3); font-size: 12.5px; margin: 28px 0; }

/* --- écrans étroits -------------------------------------------------------- */
@media (max-width: 720px) {
  .entete { padding: 10px 14px; gap: 10px; }
  .entete .sous { display: none; }
  .entete .droite { margin-left: 0; width: 100%; }
  .conversation { padding: 14px 12px 8px; }
  .msg .bulle { max-width: 94%; }
  .saisie { padding: 10px 12px 12px; }
}
