/* Assistant de la mairie — page des habitants et page « Confidentialité ».
   Aussi chargée par l'administration (avec admin/admin.css). Version 2.1. */

:root {
  --texte: #1b2430;
  --discret: #5b6675;
  --bordure: #dde2ea;
  --bleu: #1f4e79;
  --bleu-fonce: #173b5c;
  --bulle: #eef2f7;
  --saisie: #f3f5f8;
  --avertissement: #fff7e0;
  --avertissement-bord: #f0d68a;
  --erreur: #fdecec;
  --erreur-bord: #f4c7c7;
  --erreur-texte: #8a1f1f;
}

*, *::before, *::after { box-sizing: border-box; }

/* Les éléments masqués par le script (attribut hidden) restent masqués quel que soit leur style. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: #fff;
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--bleu); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Page de discussion ---------- */

.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
}

.chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bordure);
  flex: none;
}
.chat__logo { width: 38px; height: 48px; flex: none; }
.chat__title { margin: 0; font-size: 18px; line-height: 1.3; font-weight: 700; }
.chat__subtitle { margin: 2px 0 0; font-size: 15px; line-height: 1.3; color: var(--discret); }

.notice {
  flex: none;
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: var(--avertissement);
  border: 1px solid var(--avertissement-bord);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}
.notice--compact { padding: 8px 14px; }
.notice--compact .notice__more { display: none; }

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overscroll-behavior: contain;
}

.msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--bot {
  align-self: flex-start;
  background: var(--bulle);
  border-bottom-left-radius: 4px;
}
.msg--user {
  align-self: flex-end;
  background: var(--bleu);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg--user a { color: #fff; }
.msg--error {
  background: var(--erreur);
  border: 1px solid var(--erreur-bord);
  color: var(--erreur-texte);
}

/* Trois points pendant que l'assistant rédige */
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #8a94a3;
  animation: typing 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.suggestions {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 0 16px 12px;
}
.suggestions button {
  max-width: 100%;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  color: var(--bleu);
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
}
.suggestions button:hover { background: #f5f8fb; border-color: #c8d0db; }

.composer {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--bordure);
}
.composer input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  background: var(--saisie);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  font-size: 16px; /* 16 px au moins : évite le zoom automatique sur iPhone */
}
.composer input::placeholder { color: #757575; }
.composer input:focus { border-color: var(--bleu); background: #fff; }
.composer input:focus-visible { outline: 2px solid var(--bleu); outline-offset: 1px; }
.composer button {
  flex: none;
  height: 48px;
  padding: 0 18px;
  background: var(--bleu);
  color: #fff;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
}
.composer button:hover { background: var(--bleu-fonce); }
.composer button:disabled { opacity: .6; cursor: wait; }

.privacy {
  flex: none;
  padding: 0 16px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--discret);
}
.privacy summary { cursor: pointer; width: max-content; }
.privacy p { margin: 6px 0 0; }

/* Écran large : colonne centrée et bordée */
@media (min-width: 760px) {
  body { background: #f6f8fb; }
  .chat { border-left: 1px solid var(--bordure); border-right: 1px solid var(--bordure); }
}

/* ---------- Page « Confidentialité » ---------- */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 48px;
  background: #fff;
}
.page .chat__header { margin: 0 -16px 8px; }
.page h1 { font-size: 24px; line-height: 1.25; margin: 24px 0 12px; }
.page h2 { font-size: 18px; line-height: 1.3; margin: 28px 0 8px; }
.page p, .page li { line-height: 1.6; }
.page ul { padding-left: 1.2em; }
.page__retour { display: inline-block; margin-top: 16px; font-weight: 600; }
.page__maj { margin-top: 32px; color: var(--discret); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; opacity: .6; }
}
