/* Assistant IA : chat du site, aux couleurs de la boutique (--aic-brand, par défaut la couleur principale du thème). */
/* Keep the storefront stationary behind the full-screen mobile conversation. */
html.aic-chat-mobile-open, html.aic-chat-mobile-open body { overflow: hidden !important; overscroll-behavior: none; }
html.aic-chat-mobile-open body { position: fixed; top: var(--aic-page-scroll-offset, 0px); left: 0; right: 0; width: 100%; }
#aic-chat-bubble, #aic-chat-widget {
  --aic-brand: var(--sp-primary, #E1251B);
  --aic-accent: var(--aic-brand);
  --aic-brand-dark: color-mix(in srgb, var(--aic-brand) 80%, #000);
  --aic-ink: #16191D;
  --aic-cream: #f6f7f9;
  --aic-border: #e2e5ea;
  --aic-text: #14171a;
  --aic-muted: #5a626c;
  --aic-font: var(--sp-font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  --aic-heading: var(--sp-font-heading, var(--aic-font));
  box-sizing: border-box;
  font-family: var(--aic-font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  color: var(--aic-text);
}
#aic-chat-widget *, #aic-chat-bubble * { box-sizing: border-box; }
#aic-chat-widget [hidden] { display: none !important; }
#aic-chat-widget[aria-hidden="true"] { display: none; }
#aic-chat-widget button, #aic-chat-widget input, #aic-chat-widget textarea { font: inherit; letter-spacing: normal; text-transform: none; margin: 0; }
#aic-chat-widget button, #aic-chat-bubble { appearance: none; -webkit-appearance: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#aic-chat-widget button:focus-visible, #aic-chat-widget a:focus-visible, #aic-chat-widget summary:focus-visible, #aic-chat-bubble:focus-visible { outline: 3px solid color-mix(in srgb, var(--aic-brand) 55%, #fff); outline-offset: 3px; }
#aic-chat-widget button:disabled { cursor: wait; opacity: .65; }
#aic-chat-widget svg, #aic-chat-bubble svg { display: block; flex-shrink: 0; }
.aic-sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

#aic-chat-bubble {
  position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 9998;
  display: flex; align-items: center; gap: 10px; min-width: 172px; height: 58px; padding: 7px 18px 7px 8px;
  background: var(--aic-ink); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 18px;
  box-shadow: 0 8px 24px rgba(11,13,15,.28); transition: background .15s, transform .15s;
}
#aic-chat-bubble:hover { background: #0b0d0f; transform: translateY(-2px); }
#aic-chat-bubble .aic-bubble-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--aic-brand); }
#aic-chat-bubble .aic-bubble-copy { display: flex; flex-direction: column; align-items: flex-start; white-space: nowrap; }
#aic-chat-bubble .aic-bubble-copy strong { color: #fff; font-size: 14px; font-family: var(--aic-heading); font-weight: 700; line-height: 1.3; }
#aic-chat-bubble .aic-bubble-copy small { color: #fff; font-size: 11px; line-height: 1.5; opacity: .92; }
#aic-chat-bubble .aic-bubble-badge { position: absolute; right: -3px; top: -4px; width: 20px; height: 20px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 50%; background: var(--aic-ink); color: #fff; font-size: 11px; }

#aic-chat-widget {
  position: fixed; right: 24px; bottom: env(safe-area-inset-bottom, 0px); z-index: 9999;
  display: flex; flex-direction: column; width: 392px; max-width: calc(100vw - 32px); height: 620px;
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  background: #fff; border: 1px solid var(--aic-border); border-radius: 22px;
  box-shadow: 0 16px 60px rgba(11,13,15,.18), 0 3px 12px rgba(11,13,15,.06); overflow: hidden; isolation: isolate;
  animation: aicChatIn .18s ease-out both;
}
@keyframes aicChatIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
#aic-chat-widget .aic-chat-header { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 10px; min-height: 80px; padding: 16px; border-bottom: 1px solid var(--aic-border); background: #fff; }
#aic-chat-widget .aic-chat-header-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
#aic-chat-widget .aic-chat-avatar { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 14px; background: color-mix(in srgb, var(--aic-brand) 12%, #fff); color: var(--aic-accent); }
#aic-chat-widget .aic-chat-title { font-family: var(--aic-heading); font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--aic-text); }
#aic-chat-widget .aic-chat-status { margin-top: 3px; color: var(--aic-muted); font-size: 12px; line-height: 1.4; }
#aic-chat-widget .aic-chat-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 1px solid transparent; border-radius: 12px; color: #3a414a; background: #f1f3f5; box-shadow: none; }
#aic-chat-widget .aic-chat-close:hover { background: #e6e9ee; color: var(--aic-brand-dark); }

#aic-chat-widget .aic-lead-screen { flex: 1; min-height: 0; display: flex; padding: 20px 24px; overflow-y: auto; overscroll-behavior: contain; background: var(--aic-cream); }
#aic-chat-widget .aic-lead-body { width: 100%; margin: auto 0; }
#aic-chat-widget .aic-lead-eyebrow { margin: 0 0 8px; color: var(--aic-brand-dark); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
#aic-chat-widget .aic-lead-title { margin: 0 0 8px; font-family: var(--aic-heading); color: var(--aic-text); font-size: 22px; font-weight: 700; line-height: 1.25; }
#aic-chat-widget .aic-lead-subtitle { margin: 0 0 16px; font-size: 13.5px; line-height: 1.55; color: var(--aic-muted); }
#aic-chat-widget .aic-lead-submit { display: block; width: 100%; min-height: 46px; padding: 11px 14px; border: 1px solid var(--aic-accent); border-radius: 11px; background: var(--aic-accent); color: #fff; font-size: 14px; font-weight: 700; line-height: 1.45; box-shadow: none; }
#aic-chat-widget .aic-lead-submit:hover { background: var(--aic-brand-dark); }
#aic-chat-widget .aic-lead-fields { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 14px; }
#aic-chat-widget .aic-lead-fields label { display: block; margin: 0 0 4px; font-size: 12px; color: #2a3038; font-weight: 700; line-height: 1.5; }
#aic-chat-widget .aic-optional { font-weight: 400; color: var(--aic-muted); }
#aic-chat-widget .aic-lead-fields input { display: block; width: 100%; height: 44px; min-height: 44px; padding: 9px 12px; border: 1px solid #cbd0d8; border-radius: 9px; background: #fff; color: var(--aic-text); font-size: 16px; box-shadow: none; outline: none; }
#aic-chat-widget .aic-lead-fields input:focus { border-color: var(--aic-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--aic-brand) 16%, transparent); }
#aic-chat-widget input::placeholder, #aic-chat-widget textarea::placeholder { color: #7a828c; opacity: 1; }
#aic-chat-widget .aic-lead-error { padding: 10px 12px; margin: 0 0 12px; background: #fff1ed; border: 1px solid #eed0c7; border-radius: 8px; color: #863b2a; font-size: 13px; }
#aic-chat-widget .aic-lead-privacy { margin: 16px 0 0; color: var(--aic-muted); font-size: 11px; line-height: 1.65; }
#aic-chat-widget .aic-lead-privacy a { margin-inline-start: .25em; color: var(--aic-brand-dark); text-decoration: underline; }

#aic-chat-widget .aic-chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 16px 16px; display: flex; flex-direction: column; gap: 12px; background: var(--aic-cream); scrollbar-width: thin; scrollbar-color: #cbd0d8 transparent; }
#aic-chat-widget .aic-msg { display: flex; flex-shrink: 0; }
#aic-chat-widget .aic-msg-bot { justify-content: flex-start; }
#aic-chat-widget .aic-msg-agent { flex-direction: column; align-items: flex-start; }
#aic-chat-widget .aic-msg-agent .aic-msg-bubble { border-color: #c7d2fe; background: #eef2ff; }
#aic-chat-widget .aic-msg-who { font-size: 11px; color: #4338ca; margin: 0 0 3px 4px; font-weight: 600; }
#aic-chat-widget .aic-msg-note { align-self: center; text-align: center; font-size: 12px; color: #4338ca; background: #eef2ff; border-radius: 999px; padding: 5px 12px; margin: 4px auto; }
#aic-chat-widget .aic-msg-user { justify-content: flex-end; }
#aic-chat-widget .aic-msg-bubble { max-width: 91%; min-width: 0; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; text-align: start; }
#aic-chat-widget .aic-msg-bot .aic-msg-bubble { border: 1px solid #e2e5ea; border-bottom-left-radius: 4px; background: #fff; color: var(--aic-text); }
#aic-chat-widget .aic-msg-user .aic-msg-bubble { border-bottom-right-radius: 4px; background: var(--aic-ink); color: #fff; }
#aic-chat-widget .aic-msg-link { color: var(--aic-brand-dark); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; font-weight: 700; }
#aic-chat-widget .aic-msg-user .aic-msg-link { color: #fff; }
#aic-chat-widget .aic-msg-link:hover { text-decoration-thickness: 2px; }
#aic-chat-widget .aic-suggestions { display: flex; flex-wrap: wrap; gap: 7px; }
#aic-chat-widget .aic-suggestion-btn { padding: 9px 12px; min-height: 40px; border: 1px solid color-mix(in srgb, var(--aic-brand) 35%, #fff); border-radius: 10px; color: var(--aic-brand-dark); background: #fff; font-size: 12px; line-height: 1.4; box-shadow: none; white-space: normal; }
#aic-chat-widget .aic-suggestion-btn:hover { background: color-mix(in srgb, var(--aic-brand) 8%, #fff); border-color: var(--aic-accent); }
#aic-chat-widget .aic-typing { display: flex; align-items: center; gap: 5px; min-height: 44px; padding: 12px 15px; background: #fff; border: 1px solid var(--aic-border); border-radius: 14px 14px 14px 4px; }
#aic-chat-widget .aic-typing span { display: block; width: 6px; height: 6px; border-radius: 50%; background: #7a828c; animation: aicTyping 1.3s infinite ease-in-out; }
#aic-chat-widget .aic-typing span:nth-child(2) { animation-delay: .15s; }
#aic-chat-widget .aic-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes aicTyping { 0%,65%,100% { opacity: .4; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

#aic-chat-widget .aic-chat-preview { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; padding: 10px 14px 0; background: #fff; }
#aic-chat-widget .aic-preview-thumb { position: relative; width: 64px; height: 64px; border: 1px solid var(--aic-border); border-radius: 10px; overflow: hidden; }
#aic-chat-widget .aic-preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#aic-chat-widget .aic-preview-remove { position: absolute; top: 0; right: 0; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 0 0 0 9px; background: var(--aic-ink); color: #fff; line-height: 1; }
#aic-chat-widget .aic-chat-error { flex-shrink: 0; margin: 0; padding: 10px 14px; background: #fff5ed; color: #793e23; font-size: 12px; line-height: 1.5; border-top: 1px solid #efddce; }
#aic-chat-widget .aic-chat-error button { display: inline; width: auto; padding: 2px 0; min-height: 30px; margin-left: 5px; color: #713718; border: 0; background: transparent; font-size: 12px; font-weight: 700; text-decoration: underline; box-shadow: none; }
#aic-chat-widget .aic-chat-input-row { display: flex; flex-shrink: 0; align-items: center; gap: 7px; padding: 12px 12px 8px; background: #fff; border-top: 1px solid var(--aic-border); }
#aic-chat-widget .aic-chat-attach, #aic-chat-widget #aic-chat-send { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px !important; min-height: 44px !important; max-height: 44px !important; padding: 0 !important; border-radius: 11px; border: 0; box-shadow: none; }
#aic-chat-widget .aic-chat-attach { background: #f1f3f5; color: var(--aic-brand-dark); }
#aic-chat-widget .aic-chat-attach:hover { background: #e6e9ee; }
#aic-chat-widget #aic-chat-send { background: var(--aic-accent); color: #fff; }
#aic-chat-widget #aic-chat-send:hover { background: var(--aic-brand-dark); }
#aic-chat-widget #aic-chat-send:disabled { opacity: .45; cursor: default; }
/* The storefront imposes !important textarea dimensions; keep the composer scoped and compact. */
#aic-chat-widget #aic-chat-input { display: block; flex: 1; min-width: 0; width: 100%; box-sizing: border-box !important; height: var(--aic-composer-height, 44px) !important; min-height: 44px !important; max-height: 88px !important; margin: 0 !important; padding: 10px 11px !important; border: 1px solid #cbd0d8 !important; border-radius: 11px !important; background: #fff; color: var(--aic-text); font-size: 16px !important; line-height: 22px !important; resize: none !important; overflow-y: auto; overscroll-behavior: contain; box-shadow: none !important; outline: none; }
#aic-chat-widget #aic-chat-input:focus { border-color: var(--aic-accent) !important; box-shadow: 0 0 0 2px color-mix(in srgb, var(--aic-brand) 14%, transparent) !important; }
#aic-chat-widget .aic-chat-footer { flex-shrink: 0; margin: 0; padding: 0 14px calc(10px + env(safe-area-inset-bottom, 0px)); background: #fff; color: #6b737d; font-size: 10px; line-height: 1.5; text-align: center; }

@media (max-width: 600px) {
  #aic-chat-bubble { right: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); min-width: 0; width: 56px; height: 56px; padding: 6px; border-radius: 18px; justify-content: center; }
  #aic-chat-bubble .aic-bubble-copy { display: none; }
  #aic-chat-widget {
    right: 0; left: 0; bottom: 0; top: var(--aic-viewport-top, auto); width: 100%; max-width: 100%;
    height: 100vh; height: 100dvh; height: var(--aic-viewport-height, 100dvh); max-height: 100vh; max-height: 100dvh; max-height: var(--aic-viewport-height, 100dvh);
    border-radius: 0; border: 0;
  }
  #aic-chat-widget .aic-chat-header { min-height: 76px; padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px; }
  #aic-chat-widget .aic-lead-screen { padding: 28px 24px 22px; }
  #aic-chat-widget .aic-lead-body { max-width: 360px; margin: auto; }
  #aic-chat-widget .aic-chat-messages { padding: 18px 12px 14px; }
  #aic-chat-widget .aic-msg-bubble { font-size: 14px; }
  #aic-chat-widget .aic-chat-input-row { padding: 10px 10px 8px; }
  #aic-chat-widget .aic-suggestion-btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  #aic-chat-widget, #aic-chat-widget *, #aic-chat-bubble { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Fiches produit sous la réponse (23/09/2026) */
#aic-chat-widget .aic-msg-col { display: flex; flex-direction: column; gap: 8px; max-width: 91%; min-width: 0; }
#aic-chat-widget .aic-msg-col .aic-msg-bubble { max-width: 100%; }
#aic-chat-widget .aic-cards { display: flex; flex-direction: column; gap: 8px; }
#aic-chat-widget .aic-card { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--aic-border); border-radius: 12px; background: #fff; color: var(--aic-text); text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
#aic-chat-widget .aic-card:hover, #aic-chat-widget .aic-card:focus-visible { border-color: var(--aic-accent); box-shadow: 0 2px 10px rgba(11,13,15,.08); }
#aic-chat-widget .aic-card-img { flex: 0 0 64px; width: 64px; height: 64px; object-fit: contain; border-radius: 8px; background: var(--aic-cream); }
#aic-chat-widget .aic-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#aic-chat-widget .aic-card-name { font-size: 13px; line-height: 1.35; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#aic-chat-widget .aic-card-meta { font-size: 12px; color: var(--aic-muted); }
#aic-chat-widget .aic-card-cta { font-size: 12px; font-weight: 700; color: var(--aic-brand-dark); }

/* Arabe : fenêtre de droite à gauche */
#aic-chat-widget[dir="rtl"], #aic-chat-bubble[dir="rtl"] { text-align: right; }
#aic-chat-widget[dir="rtl"] .aic-msg-bot .aic-msg-bubble { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
#aic-chat-widget[dir="rtl"] .aic-msg-user .aic-msg-bubble { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
#aic-chat-widget[dir="rtl"] #aic-chat-send svg { transform: scaleX(-1); }
