/* Ma-Clé.fr — Assistant de choix
   Identité du site : Inter, bleu #2563eb, coins arrondis, ombres douces.
   Tout est préfixé .macle-as, rien ne peut percuter le thème.

   COHABITATION AVEC L'EXISTANT (mesurée sur le site) :
   - #sticky-bar  : barre d'achat, fixed bottom-0, pleine largeur, z-50
   - #back-to-top : bouton rond, fixed bottom-8 right-8 (32 px), z-50
   La bulle se cale AU-DESSUS de la barre d'achat et À GAUCHE du bouton
   « remonter », via deux variables recalculées en direct par le script. */

/* ---------------------------------------------------------------------------
   GARDE — à conserver en tête de fichier.
   L'attribut hidden du HTML masque un élément grâce à « display: none » de la
   feuille du navigateur. Or TOUTE déclaration display d'une feuille d'auteur
   l'emporte sur celle-là. Comme la fenêtre est en « display: flex » et la
   bulle en « inline-flex », hidden n'avait plus aucun effet : la fenêtre
   restait ouverte en permanence et le bouton fermer ne fermait rien.
   Cette règle rend son autorité à hidden pour tout le widget.
--------------------------------------------------------------------------- */
/* Le fil de discussion doit rester sélectionnable : un client copie une clé,
   un code promo ou une référence produit. Seuls les boutons sont protégés
   contre la sélection accidentelle pendant un appui long. */
.macle-as-fil, .macle-as-fil * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.macle-as[hidden],
.macle-as [hidden] {
  display: none !important;
}

.macle-as, .macle-as * { box-sizing: border-box; }

.macle-as {
  position: fixed;
  right: var(--mas-droite, 18px);
  bottom: var(--mas-bas, 18px);
  z-index: 9990;                 /* sous le voile jeu-concours, au-dessus du reste */
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: bottom .25s ease, right .25s ease;
}

/* ---------- la bulle ---------- */
.macle-as-bulle {
  display: inline-flex; align-items: center; gap: 9px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff; border: none; border-radius: 999px;
  padding: 12px 19px 12px 14px; cursor: pointer;
  font-size: 14.5px; font-weight: 700; font-family: inherit; line-height: 1;
  box-shadow: 0 8px 26px rgba(37, 99, 235, .34);
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
}
.macle-as-bulle:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(37,99,235,.42); }
.macle-as-bulle:active { transform: translateY(0) scale(.97); }
.macle-as-bulle:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
.macle-as-bulle-ic {
  width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}
.macle-as-pastille {
  position: absolute; top: -5px; right: -3px; min-width: 19px; height: 19px;
  background: #ef4444; color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 800; line-height: 19px; text-align: center;
  border: 2px solid #fff; padding: 0 4px;
  animation: mas-pop .45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes mas-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* Sur mobile : pastille ronde compacte, le texte disparaît.
   Elle n'obstrue rien — 46 px, calée au-dessus de la barre d'achat. */
@media (max-width: 767px) {
  .macle-as-bulle { padding: 0; width: 46px; height: 46px; justify-content: center;
                    box-shadow: 0 5px 16px rgba(37,99,235,.34); }
  .macle-as-bulle-tx { display: none; }
  .macle-as-bulle-ic { width: 100%; height: 100%; background: none; font-size: 18px; }
}

/* ---------- la fenêtre ---------- */
.macle-as-fen {
  width: 372px; max-width: calc(100vw - 24px);
  height: 596px; max-height: calc(100vh - 130px);
  background: #fff; border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(17, 24, 39, .26);
  border: 1px solid #e5e7eb;
  transform-origin: bottom right;
  animation: mas-ouvre .26s cubic-bezier(.22,1,.36,1);
}
@keyframes mas-ouvre {
  from { opacity: 0; transform: translateY(16px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
.macle-as-fen.mas-ferme { animation: mas-ferme .18s ease forwards; }
@keyframes mas-ferme {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(12px) scale(.95); }
}

/* Mobile : plein écran, mais sous la barre d'achat pour ne rien recouvrir. */
@media (max-width: 520px) {
  /* Panneau bas, PAS plein écran : le site reste visible et cliquable
     au-dessus, et la barre d'adresse du téléphone n'est jamais recouverte. */
  .macle-as-fen {
    position: fixed; left: 0; right: 0; top: auto;
    bottom: var(--mas-barre, 0px);
    width: 100%; max-width: 100%;
    height: 78vh; max-height: 78vh;
    border-radius: 18px 18px 0 0;
    border: none; border-top: 1px solid #e5e7eb;
    transform-origin: center bottom;
  }
}

.macle-as-tete {
  display: flex; align-items: center; gap: 10px; padding: 12px 13px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; flex-shrink: 0;
  padding-top: max(12px, env(safe-area-inset-top));
}
.macle-as-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.macle-as-ident { flex: 1; min-width: 0; line-height: 1.25; }
.macle-as-ident strong { display: block; font-size: 14.5px; font-weight: 700; }
.macle-as-ident em {
  font-style: normal; font-size: 11.5px; opacity: .92;
  display: flex; align-items: center; gap: 5px;
}
.macle-as-pt {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  animation: mas-bat 2s infinite;
}
@keyframes mas-bat {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.6); }
  70%  { box-shadow: 0 0 0 7px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
.macle-as-icone {
  background: rgba(255,255,255,.16); border: none; color: #fff;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s;
}
.macle-as-icone:hover { background: rgba(255,255,255,.3); }
.macle-as-icone:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ---------- le fil ---------- */
.macle-as-fil {
  flex: 1;
  overflow-y: auto;
  padding: 15px 13px 6px;
  background: #f9fafb;
  scroll-behavior: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.macle-as-msg { display: flex; margin-bottom: 10px; animation: mas-fade .28s ease; }
@keyframes mas-fade { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.macle-as-msg.bot { justify-content: flex-start; }
.macle-as-msg.moi { justify-content: flex-end; }
.macle-as-bul {
  max-width: 85%; padding: 10px 13px; border-radius: 15px;
  font-size: 14.5px; line-height: 1.5; word-break: break-word;
}
.macle-as-msg.bot .macle-as-bul {
  background: #fff; color: #1f2937; border: 1px solid #e5e7eb; border-bottom-left-radius: 5px;
}
.macle-as-msg.moi .macle-as-bul {
  background: #2563eb; color: #fff; border-bottom-right-radius: 5px; font-weight: 600;
}
.macle-as-aide { font-size: 12.5px; color: #6b7280; margin-top: 5px; display: block; }

.macle-as-tape { display: inline-flex; gap: 4px; padding: 3px 2px; }
.macle-as-tape i { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af;
                   animation: mas-saut 1.1s infinite; }
.macle-as-tape i:nth-child(2) { animation-delay: .18s; }
.macle-as-tape i:nth-child(3) { animation-delay: .36s; }
@keyframes mas-saut {
  0%,60%,100% { transform: translateY(0); opacity: .45; }
  30%         { transform: translateY(-5px); opacity: 1; }
}

/* ---------- carte produit ---------- */
.macle-as-prod {
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 10px 11px;
  margin: 2px 0 9px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .08);
  animation: mas-carte .32s cubic-bezier(.22,1,.36,1);
}
@keyframes mas-carte { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.macle-as-prod-h { display: flex; gap: 9px; align-items: center; }
.macle-as-prod img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 8px;
  background: #f3f4f6;
  flex-shrink: 0;
}
.macle-as-prod-n {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  line-height: 1.28;
}
.macle-as-prod-p {
  font-size: 16.5px;
  font-weight: 800;
  color: #2563eb;
  margin-top: 1px;
  line-height: 1.2;
}
.macle-as-prod-p small { font-size: 11px; font-weight: 600; color: #6b7280; }
.macle-as-badge {
  display: inline-block;
  background: #dcfce7;
  color: #15803d;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.macle-as-prod-a {
  display: block;
  width: 100%;
  margin-top: 9px;
  padding: 9px 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.macle-as-prod-a:hover { background: #1d4ed8; color: #fff; transform: translateY(-1px); }
.macle-as-prod-a:active { transform: translateY(0); }
.macle-as-rassure {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 10px;
  color: #9ca3af;
  flex-wrap: nowrap;
}
.macle-as-rassure span { display: inline-flex; align-items: center; gap: 4px; }
.macle-as-rassure i { color: #2563eb; }

/* code promo sur la carte produit : le prix final avant le clic */
.macle-as-codeprod {
  margin-top: 7px;
  padding: 6px 9px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px dashed #f0b429;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: #92400e;
}
.macle-as-codeprod-t { color: #92400e; }
.macle-as-codeprod b {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 900; letter-spacing: .6px; color: #92400e;
}
.macle-as-codeprod-p { font-weight: 800; color: #15803d; font-size: 12.5px; }
.macle-as-codeprod-b {
  margin-left: auto;
  background: #92400e;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.macle-as-codeprod-b:hover { background: #78350f; }

.macle-as-alt { margin-top: 7px; padding-top: 7px; border-top: 1px dashed #e5e7eb; }
.macle-as-alt-t { font-size: 10.5px; color: #6b7280; margin-bottom: 4px; font-weight: 600; }
.macle-as-alt a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 4px;
  text-decoration: none;
  color: #1f2937;
  font-size: 12px;
  line-height: 1.3;
}
/* Le nom tient sur une ligne : deux alternatives sur deux lignes chacune
   faisaient enfler la carte de pres de 50 px. */
.macle-as-alt a > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.macle-as-alt a:hover { border-color: #2563eb; background: #f8fafc; color: #1f2937; }
.macle-as-alt b { color: #2563eb; white-space: nowrap; font-weight: 800; }

/* ---------- code promo ---------- */
.macle-as-promo {
  background: linear-gradient(135deg, #fef3c7, #fde68a); border: 1px dashed #d97706;
  border-radius: 12px; padding: 12px; margin: 2px 0 10px; text-align: center;
  animation: mas-carte .32s cubic-bezier(.22,1,.36,1);
}
.macle-as-promo-c {
  font-size: 21px; font-weight: 900; color: #92400e; letter-spacing: 1.6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin: 4px 0;
}
.macle-as-promo button {
  margin-top: 6px; background: #92400e; color: #fff; border: none;
  border-radius: 8px; padding: 7px 15px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}

/* ---------- les choix ---------- */
.macle-as-choix {
  padding: 10px 13px 11px; background: #fff; border-top: 1px solid #f3f4f6;
  display: flex; flex-direction: column; gap: 7px; flex-shrink: 0;
  max-height: 46%; overflow-y: auto; overscroll-behavior: contain;
}
.macle-as-btn {
  width: 100%; text-align: left; padding: 11px 13px;
  background: #fff; border: 1.5px solid #dbeafe; border-radius: 11px;
  color: #1e40af; font-size: 14px; font-weight: 650; cursor: pointer;
  font-family: inherit; line-height: 1.35;
  display: flex; align-items: center; gap: 10px;
  transition: background .15s, border-color .15s, transform .12s;
  animation: mas-fade .24s ease backwards;
}
.macle-as-btn:nth-child(1) { animation-delay: .02s; }
.macle-as-btn:nth-child(2) { animation-delay: .06s; }
.macle-as-btn:nth-child(3) { animation-delay: .10s; }
.macle-as-btn:nth-child(4) { animation-delay: .14s; }
.macle-as-btn:nth-child(5) { animation-delay: .18s; }
.macle-as-btn:hover { background: #eff6ff; border-color: #2563eb; transform: translateX(2px); }
.macle-as-btn:active { transform: translateX(0) scale(.99); }
.macle-as-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.macle-as-btn i { color: #2563eb; width: 17px; text-align: center; flex-shrink: 0; }
.macle-as-btn.sec { border-color: #e5e7eb; color: #4b5563; font-weight: 600; }
.macle-as-btn.sec:hover { background: #f9fafb; border-color: #d1d5db; }

/* ---------- pied ---------- */
.macle-as-pied {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 13px; background: #f9fafb; border-top: 1px solid #f3f4f6;
  flex-shrink: 0; padding-bottom: max(7px, env(safe-area-inset-bottom));
}
.macle-as-lien {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; color: #6b7280; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px; padding: 3px;
}
.macle-as-lien:hover { color: #2563eb; }

@media (prefers-reduced-motion: reduce) {
  .macle-as *, .macle-as *::before, .macle-as *::after {
    animation-duration: .001ms !important; transition-duration: .001ms !important;
  }
}

/* ----- profil de l'assistante ------------------------------------------- */
.macle-as-avatar {
  font-weight: 700;
  letter-spacing: .2px;
}
.macle-as-ident em {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Icônes dessinées en SVG dans la page : le widget ne dépend d'aucune
   police externe. Si Font Awesome ne se chargeait pas, le bouton fermer
   resterait invisible et le visiteur serait coincé dans la fenêtre. */
.macle-as-svg { display: block; width: 1em; height: 1em; flex: 0 0 auto; }

/* Empêche le site de défiler quand on fait glisser une partie non défilante
   de la fenêtre (en-tête, pied, marges). Sans cela le geste traverse le
   widget et emporte la page derrière lui. */
.macle-as-tete,
.macle-as-pied {
  touch-action: none;
}
.macle-as-fil,
.macle-as-choix {
  touch-action: pan-y;
  overscroll-behavior: contain;
}
