/* ==========================================================================
   PGM Urgence Dépannage — assistant
   S'appuie exclusivement sur les jetons de assets/css/style.css (--ink,
   --gold, --cream, --font-body…). Les valeurs de repli ne servent que si la
   feuille du site n'est pas chargée.
   ========================================================================== */

.pgm-as {
  --a-ink: var(--ink, #16150F);
  --a-ink-deep: var(--ink-deep, #0E0D0A);
  --a-gold: var(--gold, #C3A177);
  --a-gold-lt: var(--gold-lt, #D9BE95);
  --a-gold-ink: var(--gold-ink, #7A6034);
  --a-cream: var(--cream, #F5F1E8);
  --a-cream-2: var(--cream-2, #EDE6D8);
  --a-paper: var(--paper, #FFFDF9);
  --a-line: var(--line-lt, #E0D8C8);
  --a-line-dk: var(--line-dk, #2E2A22);
  --a-text: var(--text, #2A2822);
  --a-text-2: var(--text-2, #6F6659);
  --a-radius: var(--radius, 3px);
  --a-err: #A3402E;

  position: fixed; inset: 0; z-index: 1000;
  font-family: var(--font-body, system-ui, sans-serif);
  color: var(--a-text);
  pointer-events: none;           /* widget : la page reste utilisable autour du panneau */
}
.pgm-as[hidden] { display: none; }
.pgm-as-sheet { pointer-events: auto; }

/* Mobile : panneau plein écran, la page derrière ne défile pas. */
@media (max-width: 719px) {
  html.pgm-as-lock, html.pgm-as-lock body { overflow: hidden; }
}

/* Mobile : plein écran, calé sur le viewport visible (clavier compris). */
.pgm-as-sheet {
  position: fixed; left: 0; right: 0;
  top: var(--pgm-top, 0px);
  height: var(--pgm-vh, 100dvh);
  display: flex; flex-direction: column;
  background: var(--a-cream);
  overflow: hidden;
}

/* Desktop : panneau compact ancré en bas à droite, à la place du lanceur. */
@media (min-width: 720px) {
  .pgm-as-sheet {
    left: auto; right: 24px; top: auto; bottom: 24px;
    width: 400px; height: min(680px, calc(100vh - 48px));
    border: 1px solid var(--a-line-dk); border-radius: 10px;
    box-shadow: 0 18px 50px rgba(14, 13, 10, .28);
  }
}

/* ---- En-tête -------------------------------------------------------------- */
.pgm-as-hdr {
  position: relative; flex: none;
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .6rem .55rem .75rem;
  padding-top: max(.55rem, env(safe-area-inset-top));
  background: var(--a-ink); color: var(--a-cream);
}
.pgm-as-hdr :focus-visible { outline-color: var(--a-gold-lt); }
.pgm-as-avatar {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--a-gold); color: var(--a-ink);
}
.pgm-as-avatar svg { width: 20px; height: 20px; }
.pgm-as-id { flex: 1; min-width: 0; line-height: 1.25; }
.pgm-as-title {
  margin: 0; font-size: .92rem; font-weight: 700; letter-spacing: .02em; color: var(--a-cream);
}
.pgm-as-title:focus { outline: none; }
.pgm-as-sub { margin: 0; font-size: .74rem; color: #B9AF9E; }
.pgm-as-title, .pgm-as-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 359px) { .pgm-as-avatar { display: none; } }

.pgm-as-call {
  display: inline-flex; align-items: center; gap: .4rem; flex: none;
  min-height: 44px; padding: 0 .85rem;
  background: var(--a-gold); color: var(--a-ink);
  border-radius: var(--a-radius);
  font-size: .85rem; font-weight: 700; text-decoration: none;
}
.pgm-as-call svg { width: 17px; height: 17px; }
.pgm-as-call:hover { background: var(--a-gold-lt); }

/* Appeler et Fermer : 16px d'écart + séparateur, pour éviter de fermer
   l'assistant en voulant appeler (usage à une main). */
.pgm-as-close {
  position: relative; margin-left: .5rem;
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: transparent; color: var(--a-cream);
  border: 1px solid var(--a-line-dk); border-radius: var(--a-radius); cursor: pointer;
}
.pgm-as-close:hover { border-color: var(--a-gold); }
.pgm-as-close::before {
  content: ""; position: absolute; left: calc(-.5rem - 1px); top: 8px; bottom: 8px;
  width: 1px; background: var(--a-line-dk);
}

/* Progression douce, non numérique : le nombre d'étapes varie. */
.pgm-as-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--a-line-dk); }
.pgm-as-progress span {
  display: block; height: 100%; background: var(--a-gold);
  transform-origin: left; transform: scaleX(.08);
  transition: transform .3s ease;
}

/* ---- Fil de la conversation ---------------------------------------------- */
.pgm-as-log {
  position: relative; flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: .55rem;
  padding: 1rem .85rem 1.1rem;
}
.pgm-as-log > :first-child { margin-top: auto; }

.pgm-msg { max-width: 88%; border-radius: var(--a-radius); font-size: .97rem; line-height: 1.5; }
.pgm-msg p { margin: 0; }
.pgm-msg p + p { margin-top: .35rem; }

.pgm-msg--bot {
  align-self: flex-start;
  background: var(--a-paper); color: var(--a-text);
  border: 1px solid var(--a-line); border-left: 2px solid var(--a-gold);
  padding: .6rem .85rem;
  animation: pgm-in .18s ease-out both;
}
.pgm-msg--user {
  align-self: flex-end;
  background: var(--a-ink); color: var(--a-cream);
  padding: .5rem .8rem;
  white-space: pre-wrap;
}

@keyframes pgm-in { from { opacity: 0; transform: translateY(4px); } }

.pgm-understood, .pgm-saved, .pgm-alert {
  display: flex; align-items: flex-start; gap: .55rem;
  border-radius: var(--a-radius); padding: .6rem .8rem;
  font-size: .92rem; line-height: 1.45;
  animation: pgm-in .18s ease-out both;
}
.pgm-understood p, .pgm-saved p, .pgm-alert p { margin: 0; }
.pgm-understood svg, .pgm-saved svg, .pgm-alert svg { flex: none; margin-top: .1rem; }
.pgm-understood { align-self: flex-start; max-width: 92%; background: var(--a-cream-2); color: var(--a-text); }
.pgm-understood svg { color: var(--a-gold-ink); }
.pgm-saved {
  align-self: stretch; background: #EAF0E4; border: 1px solid #B9CBA6; color: #33471F; font-weight: 700;
}
.pgm-saved-ref { margin-top: .15rem !important; font-weight: 500; }
.pgm-saved-ref strong { letter-spacing: .04em; }
.pgm-alert { align-self: stretch; background: #F6E7E4; border: 1px solid #DDB4AB; color: #7A2A1B; }
.pgm-alert p + p { margin-top: .3rem; }

/* Récapitulatif */
.pgm-card {
  align-self: stretch;
  background: var(--a-paper); border: 1px solid var(--a-line); border-radius: var(--a-radius);
  padding: .8rem .95rem .85rem;
}
.pgm-card-hd { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.pgm-card-ref {
  margin: 0; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  font-weight: 600; color: var(--a-gold-ink);
}
.pgm-card-ref strong { color: var(--a-text); letter-spacing: .08em; }
.pgm-card-list { list-style: none; margin: 0; padding: 0; font-size: .95rem; line-height: 1.45; }
.pgm-card-list li { margin: 0; padding: .12rem 0; }
.pgm-card-list li:first-child { font-weight: 700; }

.pgm-link {
  min-height: 44px; padding: 0 .25rem;
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .84rem; font-weight: 600;
  color: var(--a-gold-ink); text-decoration: underline; text-underline-offset: 3px;
}

.pgm-final { max-width: 100%; }
.pgm-final-title {
  font-family: var(--font-title, Georgia, serif); font-size: 1.3rem; line-height: 1.2;
  font-weight: 600; color: var(--a-ink);
}

/* ---- Zone d'action (bas d'écran, zone du pouce) -------------------------- */
.pgm-as-dock {
  flex: none; max-height: 62%;
  overflow-y: auto;
  background: var(--a-paper);
  border-top: 1px solid var(--a-line);
  padding: .7rem .75rem calc(.7rem + env(safe-area-inset-bottom));
}
.pgm-as-dock:empty { display: none; }

.pgm-chips { display: grid; gap: .45rem; }
.pgm-chips--2 { grid-template-columns: 1fr 1fr; }
.pgm-chips--1 { grid-template-columns: 1fr; }
.pgm-chips + .pgm-compose, .pgm-compose + .pgm-chips { margin-top: .55rem; }

.pgm-chip {
  min-height: 48px; padding: .55rem .7rem;
  background: var(--a-cream); color: var(--a-text);
  border: 1px solid var(--a-line); border-radius: var(--a-radius);
  font: inherit; font-size: .93rem; font-weight: 600; line-height: 1.25;
  cursor: pointer; text-align: center;
  transition: border-color .15s ease, background-color .15s ease;
}
.pgm-chip:hover { border-color: var(--a-gold-ink); }
.pgm-chip:active { background: var(--a-cream-2); }
.pgm-chip--quiet { background: transparent; color: var(--a-text-2); }

/* Saisie libre */
.pgm-compose { display: flex; align-items: flex-end; gap: .45rem; }
/* Bordure #8C8272 : 3,4:1 sur le fond — un champ se lit comme un champ,
   jamais comme un simple trait (WCAG 1.4.11). */
.pgm-compose textarea,
.pgm-field input {
  width: 100%; min-height: 50px;
  padding: .7rem .8rem;
  font: inherit; font-size: 16px; /* 16px : évite le zoom automatique d'iOS */
  line-height: 1.35;
  background: #fff; color: var(--a-text);
  border: 1.5px solid #8C8272; border-radius: var(--a-radius);
  -webkit-appearance: none; appearance: none;
}
.pgm-compose textarea { flex: 1; resize: none; display: block; }
.pgm-compose textarea:focus, .pgm-field input:focus {
  border-color: var(--a-gold-ink); outline: 2px solid var(--a-gold-ink); outline-offset: 1px;
}
.pgm-compose textarea::placeholder, .pgm-field input::placeholder { color: #7A7064; opacity: 1; }

.pgm-send {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  background: var(--a-ink); color: var(--a-gold-lt);
  border: 0; border-radius: var(--a-radius); cursor: pointer;
}
.pgm-send:disabled { opacity: .4; cursor: default; }

/* Boutons */
.pgm-stack { display: grid; gap: .5rem; }
.pgm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%; min-height: 52px; padding: .6rem 1rem;
  font: inherit; font-size: .95rem; font-weight: 700; letter-spacing: .01em;
  text-align: center; text-decoration: none;
  border: 1px solid transparent; border-radius: var(--a-radius);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.pgm-btn--primary { background: var(--a-gold); color: var(--a-ink); }
.pgm-btn--primary:hover { background: var(--a-gold-lt); }
.pgm-btn--outline { background: transparent; color: var(--a-gold-ink); border-color: var(--a-gold-ink); }
.pgm-btn--outline:hover { background: var(--a-cream); }
.pgm-btn--text {
  min-height: 44px; background: transparent; color: var(--a-text-2); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.pgm-btn--wa { gap: .45rem; padding-inline: .7rem; font-size: .92rem; letter-spacing: 0; }
.pgm-btn:disabled { opacity: .45; cursor: not-allowed; }
.pgm-btn svg { flex: none; }


/* Contact */
.pgm-fields { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.pgm-field label { display: block; margin-bottom: .25rem; font-size: .88rem; font-weight: 700; color: var(--a-text); }
.pgm-field input[aria-invalid="true"] { border-color: var(--a-err); border-width: 2px; background: #FDF6F4; }
.pgm-err { margin: .35rem 0 0; font-size: .86rem; font-weight: 700; color: var(--a-err); }
.pgm-err::before { content: "⚠ "; }
.pgm-err:empty { display: none; }
.pgm-privacy { margin: .5rem 0 .6rem; font-size: .8rem; line-height: 1.45; color: var(--a-text-2); }
.pgm-privacy details { display: inline; }
.pgm-privacy summary {
  display: inline; cursor: pointer; list-style: none;
  color: var(--a-gold-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.pgm-privacy summary::-webkit-details-marker { display: none; }
.pgm-privacy details p { margin: .35rem 0 0; }

.pgm-edit { display: grid; gap: .5rem; margin-top: .4rem; }
.pgm-edit-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: .5rem; margin-top: .2rem; }

/* Transmission */
.pgm-sending {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  min-height: 52px; font-weight: 700; font-size: .95rem; color: var(--a-text);
}
.pgm-spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--a-line); border-top-color: var(--a-gold-ink);
  animation: pgm-spin .7s linear infinite;
}
@keyframes pgm-spin { to { transform: rotate(360deg); } }

/* Aperçu WhatsApp (simulation) */
.pgm-ov {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: flex-end;
  background: rgba(14, 13, 10, .6);
}
.pgm-ov-box {
  width: 100%; display: grid; gap: .6rem;
  background: var(--a-paper);
  padding: 1.1rem .9rem calc(1rem + env(safe-area-inset-bottom));
  border-top: 2px solid var(--a-gold);
}
.pgm-ov-eyebrow {
  margin: 0; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; color: var(--a-gold-ink);
}
.pgm-ov-title { margin: 0; font-weight: 700; }
.pgm-wa-preview {
  background: #E7F3DF; border: 1px solid #C9DDB9; border-radius: var(--a-radius);
  padding: .7rem .85rem; font-size: .93rem; white-space: pre-wrap;
}
.pgm-wa-preview p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .pgm-msg--bot, .pgm-understood, .pgm-saved, .pgm-alert { animation: none; }
}

/* ==========================================================================
   Lanceur flottant « David — Assistant PGC »
   Au-dessus de la barre d'appel et du bandeau cookies (--pgc-david-bottom,
   mesuré en JS), sous le panneau ouvert. Aucune taille réservée dans la
   page : pas de décalage de mise en page (CLS nul).
   ========================================================================== */
.pgc-david {
  --pgc-david-bottom: 0px;
  position: fixed; z-index: 96;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(var(--pgc-david-bottom) + max(14px, env(safe-area-inset-bottom)));
  display: flex; align-items: center; gap: .6rem;
  max-width: calc(100vw - 28px);
  min-height: 56px; padding: .5rem 1rem .5rem .5rem;
  background: var(--ink, #16150F); color: var(--cream, #F5F1E8);
  border: 1px solid var(--gold, #C3A177); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(14, 13, 10, .35);
  font-family: var(--font-body, system-ui, sans-serif); text-align: left;
  cursor: pointer;
  opacity: 0; transform: translateY(12px);
  transition: opacity .45s ease, transform .45s ease, border-color .15s ease;
}
.pgc-david[hidden], .pgc-david.is-waiting { display: none; }
.pgc-david.is-in { opacity: 1; transform: none; }
.pgc-david.is-in.is-yielding { opacity: 0; transform: translateY(10px); pointer-events: none; }
.pgc-david:hover { border-color: var(--gold-lt, #D9BE95); }
.pgc-david:focus-visible { outline: 3px solid var(--gold-lt, #D9BE95); outline-offset: 3px; }

.pgc-david-ico {
  position: relative; flex: none;
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: var(--gold, #C3A177); color: var(--ink, #16150F);
}
.pgc-david-ico svg { width: 21px; height: 21px; }
.pgc-david-txt { display: grid; line-height: 1.2; min-width: 0; }
.pgc-david-name { font-weight: 700; font-size: .95rem; white-space: nowrap; }
.pgc-david-role { font-weight: 600; color: var(--gold-lt, #D9BE95); }
.pgc-david-hook { font-size: .8rem; color: #CFC7B8; white-space: nowrap; }
.pgc-david-hook-short { display: none; }

/* Mobile : compact (« David · Besoin d'aide ? »). */
@media (max-width: 519px) {
  .pgc-david { min-height: 52px; padding-right: .9rem; }
  .pgc-david-ico { width: 36px; height: 36px; }
  .pgc-david-role, .pgc-david-hook-long { display: none; }
  .pgc-david-hook-short { display: inline; }
}

/* Impulsion d'attention : une vague dorée autour de l'icône + léger saut. */
.pgc-david.is-nudge { animation: pgc-david-hop .9s ease-out 1; }
.pgc-david.is-nudge .pgc-david-ico::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(195, 161, 119, .7);
  animation: pgc-david-halo 1.4s ease-out 2;
}
@keyframes pgc-david-hop { 0%, 100% { transform: none; } 30% { transform: translateY(-6px); } 55% { transform: translateY(0); } 70% { transform: translateY(-2px); } }
@keyframes pgc-david-halo { to { box-shadow: 0 0 0 14px rgba(195, 161, 119, 0); } }

@media (prefers-reduced-motion: reduce) {
  .pgc-david { transition: none; transform: none; }
  .pgc-david.is-nudge, .pgc-david.is-nudge .pgc-david-ico::after { animation: none; }
}
