/*
 * YOORshop AI Chat — habillage du widget public.
 *
 * Dessiné le 2026-09-03 après observation d'Intercom Fin, de l'agent Hostinger
 * et de la documentation Stripe. Trois choix en découlent : l'entrée est une
 * pilule libellée posée en haut à droite sous le bandeau du site, le panneau
 * s'ancre sous elle, et il ne s'ouvre jamais sur du vide.
 *
 * Toutes les couleurs de texte sont posées en propre. Le thème du site avait
 * repeint le titre du panneau en gris #505050 sur navy, soit un contraste de
 * 2,1:1 : aucune couleur n'est laissée à l'héritage.
 */

#ys-ai-chat-root {
  --ysai-accent: #c79a3f;
  --ysai-accent-soft: #e0bc72;
  --ysai-navy: #0f2337;
  --ysai-navy-2: #16324c;
  --ysai-paper: #ffffff;
  --ysai-paper-2: #f7f8fa;
  --ysai-paper-3: #eef1f5;
  --ysai-edge: #e1e6ed;
  --ysai-edge-2: #d3dae4;
  --ysai-ink: #101a24;
  --ysai-ink-2: #46566a;
  --ysai-ink-3: #6e7f93;
  --ysai-live: #2fa36b;
  --ysai-alert: #b4362a;
  --ysai-alert-bg: #fdf1ef;
  --ysai-font: "Plus Jakarta Sans", "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  position: fixed;
  /* Mesuré sur les deux domaines le 2026-09-03 : la barre de navigation
     s'arrête à 102 px sur la boutique et à 108 px sur le support. La pilule est
     posée en dessous, avec de l'air, pour ne jamais mordre l'en-tête. */
  top: 132px;
  right: 0;
  z-index: 2147483000;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: var(--ysai-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ysai-ink);
  text-align: left;
  pointer-events: none;
}

#ys-ai-chat-root.is-ready { display: flex; }
#ys-ai-chat-root.is-left { right: auto; left: 0; align-items: flex-start; }

#ys-ai-chat-root *,
#ys-ai-chat-root *::before,
#ys-ai-chat-root *::after { box-sizing: border-box; }

.ysai-launcher,
.ysai-panel { pointer-events: auto; }

/* ============================================================
   L'entrée : une pilule claire, libellée, sous le bandeau
   ============================================================ */

.ysai-launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 14px;
  padding: 7px 15px 7px 8px;
  border: 1px solid #ffffff;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f4f6f9);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .4), 0 8px 22px -10px rgba(6, 14, 24, .55);
  color: var(--ysai-navy);
  font-family: var(--ysai-font);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: box-shadow .18s ease, transform .18s ease;
}

.ysai-launcher:hover,
.ysai-launcher:focus-visible {
  outline: none;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(199, 154, 63, .35), 0 10px 26px -10px rgba(6, 14, 24, .6);
}

.ysai-launcher:active { transform: translateY(1px); }

.ysai-launcher-icon {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--ysai-navy);
  display: grid;
  place-items: center;
}

.ysai-launcher-icon svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--ysai-accent-soft);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.ysai-launcher-text { color: var(--ysai-navy); white-space: nowrap; }

.ysai-launcher-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--ysai-live);
}

/* ============================================================
   Le panneau
   ============================================================ */

.ysai-panel {
  width: 384px;
  max-width: calc(100vw - 24px);
  margin: 0 14px;
  background: var(--ysai-paper);
  border: 1px solid var(--ysai-edge-2);
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(6, 14, 24, .1), 0 30px 60px -28px rgba(6, 14, 24, .55);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(620px, calc(100vh - 168px));
}

.ysai-panel[aria-hidden="true"] { display: none; }

.ysai-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: var(--ysai-paper);
  border-bottom: 1px solid var(--ysai-edge);
  flex: none;
}

.ysai-mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: var(--ysai-navy);
  display: grid;
  place-items: center;
}

.ysai-mark svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--ysai-accent-soft);
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.ysai-identity { flex: 1; min-width: 0; }

.ysai-title {
  margin: 0;
  padding: 0;
  font-family: var(--ysai-font);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.01em;
  color: var(--ysai-ink);
  text-transform: none;
}

.ysai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 1px 0 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--ysai-ink-3);
}

.ysai-status::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--ysai-live);
}

.ysai-panel.is-down .ysai-status { color: var(--ysai-alert); }
.ysai-panel.is-down .ysai-status::before { background: var(--ysai-alert); }

.ysai-icon-btn {
  width: 30px;
  height: 30px;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ysai-ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.ysai-icon-btn:hover,
.ysai-icon-btn:focus-visible { background: var(--ysai-paper-3); color: var(--ysai-ink-2); outline: none; }

.ysai-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ---------- Corps ---------- */

.ysai-messages {
  flex: 1;
  min-height: 132px;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--ysai-paper);
  overscroll-behavior: contain;
}

/* ---------- Accueil : jamais vide ---------- */

.ysai-greeting { padding: 10px 4px 2px; text-align: center; }

.ysai-greeting-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  border-radius: 13px;
  background: linear-gradient(160deg, var(--ysai-navy), var(--ysai-navy-2));
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px -10px rgba(15, 35, 55, .8);
}

.ysai-greeting-mark svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--ysai-accent-soft);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.ysai-greeting h3 {
  margin: 0 0 6px;
  padding: 0;
  font-family: var(--ysai-font);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
  color: var(--ysai-ink);
  text-transform: none;
}

.ysai-greeting p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ysai-ink-3);
}

.ysai-suggest-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ysai-ink-3);
}

.ysai-suggest-label::before,
.ysai-suggest-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ysai-edge);
}

.ysai-suggestions { display: flex; flex-direction: column; gap: 8px; }

.ysai-suggestion {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--ysai-edge);
  border-radius: 10px;
  background: var(--ysai-paper);
  font-family: var(--ysai-font);
  text-align: left;
  cursor: pointer;
}

.ysai-suggestion:hover,
.ysai-suggestion:focus-visible {
  border-color: var(--ysai-accent);
  background: #fffcf6;
  outline: none;
}

.ysai-suggestion-icon {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--ysai-paper-3);
  display: grid;
  place-items: center;
}

.ysai-suggestion-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--ysai-navy-2);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ysai-suggestion-text { flex: 1; min-width: 0; }

.ysai-suggestion-text b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ysai-ink);
}

.ysai-suggestion-text span { font-size: 11.5px; color: var(--ysai-ink-3); }
.ysai-suggestion-go { color: var(--ysai-ink-3); font-size: 15px; line-height: 1; }

/* ---------- Messages ---------- */

.ysai-message { margin: 0; }

.ysai-message.is-user {
  align-self: flex-end;
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  background: var(--ysai-navy);
}

.ysai-message.is-user p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #ffffff;
}

.ysai-message.is-assistant { display: flex; gap: 10px; }

.ysai-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  margin-top: 2px;
  border-radius: 7px;
  background: var(--ysai-navy);
  display: grid;
  place-items: center;
}

.ysai-avatar svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--ysai-accent-soft);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.ysai-body { flex: 1; min-width: 0; }

.ysai-body p {
  margin: 0 0 9px;
  font-size: 13.8px;
  line-height: 1.62;
  color: var(--ysai-ink);
}

.ysai-body p:last-of-type { margin-bottom: 0; }

.ysai-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.ysai-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 5px 11px 5px 7px;
  border: 1px solid var(--ysai-edge);
  border-radius: 999px;
  background: var(--ysai-paper-2);
  color: var(--ysai-ink-2);
  font-size: 11.5px;
  text-decoration: none;
}

.ysai-chip:hover,
.ysai-chip:focus-visible { border-color: var(--ysai-accent); background: #fffcf6; outline: none; }

.ysai-chip-n {
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  background: var(--ysai-navy);
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.ysai-chip-t {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 190px;
}

.ysai-stamp {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  font-size: 10.5px;
  color: var(--ysai-ink-3);
}

.ysai-stamp b { font-weight: 600; color: var(--ysai-ink-2); }

.ysai-stamp i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ysai-edge-2);
  display: block;
}

.ysai-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 15px;
  border-radius: 9px;
  background: var(--ysai-navy);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.ysai-cta:hover,
.ysai-cta:focus-visible { background: var(--ysai-navy-2); color: #ffffff; outline: none; }

.ysai-cta svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ysai-accent-soft);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ysai-feedback { display: flex; align-items: center; gap: 4px; margin-top: 10px; }

.ysai-feedback button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ysai-ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ysai-feedback button:hover:not(:disabled),
.ysai-feedback button:focus-visible:not(:disabled) { background: var(--ysai-paper-3); color: var(--ysai-ink-2); outline: none; }
.ysai-feedback button:disabled { opacity: .35; cursor: default; }

.ysai-feedback button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.ysai-feedback .ysai-done {
  width: auto;
  gap: 6px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  height: 28px;
  border-radius: 7px;
  background: #eff9f3;
  color: #1d7a4f;
  font-family: var(--ysai-font);
  font-size: 11.5px;
  font-weight: 600;
  opacity: 1;
}

.ysai-error {
  padding: 11px 13px;
  border: 1px solid #f0d4cf;
  border-radius: 10px;
  background: var(--ysai-alert-bg);
  color: #7c2419;
  font-size: 13.2px;
  line-height: 1.5;
}

.ysai-typing { display: inline-flex; gap: 4px; padding: 9px 2px; }

.ysai-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ysai-edge-2);
  display: block;
  animation: ysai-pulse 1.1s ease-in-out infinite;
}

.ysai-typing i:nth-child(2) { animation-delay: .18s; }
.ysai-typing i:nth-child(3) { animation-delay: .36s; }

@keyframes ysai-pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

/* ---------- Composition ---------- */

.ysai-footer {
  flex: none;
  padding: 11px 12px 9px;
  border-top: 1px solid var(--ysai-edge);
  background: var(--ysai-paper);
}

.ysai-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 13px;
  border: 1px solid var(--ysai-edge-2);
  border-radius: 11px;
  background: var(--ysai-paper);
}

.ysai-compose:focus-within {
  border-color: var(--ysai-accent);
  box-shadow: 0 0 0 3px rgba(199, 154, 63, .15);
}

.ysai-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  resize: none;
  padding: 6px 0;
  background: transparent;
  color: var(--ysai-ink);
  font-family: var(--ysai-font);
  font-size: 13.5px;
  line-height: 1.5;
  max-height: 96px;
}

.ysai-input::placeholder { color: var(--ysai-ink-3); opacity: 1; }

.ysai-send {
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--ysai-navy);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ysai-send:hover:not(:disabled) { background: var(--ysai-navy-2); }
.ysai-send:disabled { background: var(--ysai-paper-3); cursor: default; }

.ysai-send svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ysai-send:disabled svg { stroke: #a9b4c2; }

.ysai-legal {
  margin: 8px 0 0;
  text-align: center;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--ysai-ink-3);
}

/* ---------- Écrans étroits ---------- */

@media (max-width: 560px) {
  #ys-ai-chat-root { top: 110px; }
  .ysai-launcher { padding: 7px; gap: 0; }
  .ysai-launcher-text, .ysai-launcher-dot { display: none; }
  .ysai-panel { width: calc(100vw - 20px); margin: 0 10px; max-height: calc(100vh - 140px); }
}

@media (prefers-reduced-motion: reduce) {
  #ys-ai-chat-root * { transition: none !important; animation: none !important; }
}
