/* Assistant clients : charte du site (DESIGN.md). Encre et gris studio, rouge réservé au bouton Envoyer,
   coins de 2 px, aucune ombre, Inter. Bas à droite (place de la bulle Crisp, que le module remplace) :
   WhatsApp occupe le bas à gauche. Remonté au-dessus de la barre d'achat collante (fiche, panier, ≤ 1024 px). */
#us-assistant { --ink: #111111; --steel: #151515; --studio: #F4F4F5; --hair: #E4E4E7; --hair-fort: #D4D4D8; --mute: #52525B;
  --rouge: #C8102E; --rouge-survol: #A00D25; --bas: 24px;
  position: fixed; right: 24px; bottom: var(--bas); z-index: 899; font: 400 16px/1.5 "Inter", system-ui, sans-serif; color: var(--ink); }
#us-assistant *, #us-assistant *::before, #us-assistant *::after { box-sizing: border-box; }
#us-assistant button { font: inherit; }
/* icônes au trait : le thème remplit les svg (fill: currentColor) */
#us-assistant svg[fill="none"], #us-assistant svg[fill="none"] path { fill: none !important; }

/* bulle */
#us-assistant-bulle { display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 20px 0 16px; background: var(--ink); color: #fff;
  border: 0; border-radius: 2px; cursor: pointer; font-weight: 700; font-size: 16px; }
#us-assistant-bulle:hover { background: #282828; }
#us-assistant-bulle svg { width: 22px; height: 22px; flex: none; }
#us-assistant-bulle[aria-expanded="true"] { display: none; }
/* le bouton de contact du thème (.us-contact, à droite) ouvre l'assistant : pas de seconde bulle ; fenêtre au-dessus de lui */
body:has(.us-contact) #us-assistant-bulle { display: none; }
body:has(#us-assistant-fenetre:not([hidden])) .us-contact { display: none !important; }
#us-assistant :focus-visible { outline: 2px solid var(--rouge); outline-offset: 2px; }

/* fenêtre */
#us-assistant-fenetre { position: absolute; right: 0; bottom: 0; width: 400px; height: min(620px, calc(100vh - var(--bas) - 24px));
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--hair-fort); }
#us-assistant-fenetre[hidden] { display: none; }
.us-assistant-tete { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 4px 0 20px; background: var(--steel); color: #fff; flex: none; }
.us-assistant-tete strong { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.us-assistant-tete button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  background: none; border: 0; border-radius: 2px; color: #fff; cursor: pointer; }
.us-assistant-tete button:hover { background: #282828; }
.us-assistant-tete svg { width: 20px; height: 20px; }

#us-assistant-messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
#us-assistant-messages p { margin: 0; padding: 12px 14px; border-radius: 2px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 88%; }
#us-assistant-messages .moi { align-self: flex-end; background: var(--ink); color: #fff; }
#us-assistant-messages .bot { align-self: flex-start; background: var(--studio); }
#us-assistant-messages .bot a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
#us-assistant-messages .bot a:hover { color: var(--rouge); }
#us-assistant-messages .erreur { border-left: 3px solid var(--mute); }

/* points d'attente */
#us-assistant-messages .attente { display: inline-flex; gap: 6px; padding: 16px 14px; }
.attente i { width: 7px; height: 7px; background: var(--mute); border-radius: 50%; animation: us-assistant-point 1.2s infinite ease-in-out; }
.attente i:nth-child(2) { animation-delay: .15s; }
.attente i:nth-child(3) { animation-delay: .3s; }
@keyframes us-assistant-point { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .attente i { animation: none; opacity: .6; } }

/* pied : note, champ, bouton */
.us-assistant-pied { flex: none; border-top: 1px solid var(--hair); padding: 12px 20px 16px; }
.us-assistant-note { margin: 0 0 10px; font-size: 13px; line-height: 1.4; color: var(--mute); }
.us-assistant-info { margin: 0 0 8px; font-size: 13px; color: var(--mute); }
.us-assistant-info:empty { display: none; }
#us-assistant-form { display: flex; gap: 8px; align-items: flex-end; }
#us-assistant-champ { flex: 1; min-width: 0; min-height: 48px; max-height: 128px; padding: 12px 14px; resize: none; font: inherit; font-size: 16px; line-height: 1.4;
  color: var(--ink); background: #fff; border: 1px solid var(--hair-fort); border-radius: 2px; }
#us-assistant-champ:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 2px rgba(200, 16, 46, .2); }
#us-assistant-champ:disabled { background: var(--studio); }
#us-assistant-envoyer { flex: none; height: 48px; padding: 0 20px; background: var(--rouge); color: #fff; border: 0; border-radius: 2px;
  cursor: pointer; font-weight: 700; font-size: 16px; }
#us-assistant-envoyer:hover { background: var(--rouge-survol); }
#us-assistant-envoyer:disabled { background: var(--hair-fort); color: var(--mute); cursor: default; }

/* barre d'achat collante en bas (fiche hors configurateur 437, panier) : la bulle passe au-dessus */
@media (max-width: 1024px) {
  body#product:not(.product-id-437) #us-assistant, body#cart #us-assistant { --bas: 92px; }
}
/* bulle jamais pendant le tunnel de commande ; rien par-dessus le menu, le tiroir panier ou le bandeau cookies */
/* (tunnel : la fenêtre reste possible, ouverte depuis le bouton de contact du thème, qui y est affiché) */
body#checkout #us-assistant-bulle, body.us-menu-ouvert #us-assistant, body.us-panier-ouvert #us-assistant,
body:has(#us-consent:not([hidden])) #us-assistant-bulle { display: none; }

@media (max-width: 767px) {
  #us-assistant { right: 16px; --bas: 16px; }
  body#product:not(.product-id-437) #us-assistant, body#cart #us-assistant { --bas: 88px; }
  /* bulle réduite à l'icône : elle ne masque ni prix ni bouton */
  #us-assistant-bulle { width: 52px; padding: 0; justify-content: center; }
  #us-assistant-bulle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* fenêtre plein écran, champ au-dessus du clavier */
  #us-assistant-fenetre { position: fixed; inset: 0; width: auto; height: 100%; height: 100dvh; border: 0; }
  #us-assistant-messages { padding: 16px; }
  .us-assistant-pied { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
}
