/* ── Stra BURO Agent IA — Widget CSS ─────────────────────────────────────── */

:root {
  --sbai-primary: #c21e1e;
  --sbai-primary-h: #a11818;
  --sbai-bg: #ffffff;
  --sbai-surface: #f9f9f9;
  --sbai-border: #e5e1e1;
  --sbai-text: #111827;
  --sbai-text-muted: #6b7280;
  --sbai-radius: 16px;
  --sbai-shadow: 0 8px 32px rgba(0,0,0,.14);
}

/* Bouton flottant */
#sbai-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--sbai-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(194,30,30,.35);
  transition: transform .2s, box-shadow .2s, background .15s;
  white-space: nowrap;
}
#sbai-toggle:hover { background: var(--sbai-primary-h); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(194,30,30,.4); }
#sbai-toggle svg  { flex-shrink: 0; }

#sbai-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  display: none;
}
#sbai-badge.show { display: flex; }

/* Panneau */
#sbai-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 99999;
  width: min(420px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 112px));
  background: var(--sbai-bg);
  border: 1px solid var(--sbai-border);
  border-radius: var(--sbai-radius);
  box-shadow: var(--sbai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity .18s, transform .18s;
}
#sbai-panel.hidden { opacity: 0; transform: scale(.94) translateY(8px); pointer-events: none; }

/* Header */
#sbai-header {
  background: var(--sbai-text);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#sbai-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sbai-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
  position: relative;
}
#sbai-avatar::after {
  content: '';
  position: absolute; bottom: -1px; right: -1px;
  width: 11px; height: 11px;
  background: #4ade80;
  border: 2px solid var(--sbai-text);
  border-radius: 50%;
}
#sbai-header-info { flex: 1; min-width: 0; }
#sbai-header-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
#sbai-header-sub  { font-size: 11px; opacity: .55; }
#sbai-close {
  width: 28px; height: 28px;
  border: none; background: transparent; color: #fff;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: .7; transition: opacity .15s, background .15s;
}
#sbai-close:hover { opacity: 1; background: rgba(255,255,255,.12); }

/* Messages */
#sbai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scroll-behavior: smooth;
}

.sbai-bubble {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.sbai-bubble.user { justify-content: flex-end; }

.sbai-bubble-inner {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.5;
}
.sbai-bubble.assistant .sbai-bubble-inner {
  background: var(--sbai-surface);
  border: 1px solid var(--sbai-border);
  border-top-left-radius: 4px;
  color: var(--sbai-text);
}
.sbai-bubble.user .sbai-bubble-inner {
  background: var(--sbai-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.sbai-bubble-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--sbai-text);
  color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  outline: 2px solid rgba(194,30,30,.2);
}

/* Markdown dans les bulles */
.sbai-bubble-inner p  { margin: 0 0 6px; }
.sbai-bubble-inner p:last-child { margin-bottom: 0; }
.sbai-bubble-inner strong { font-weight: 600; }
.sbai-bubble-inner ul, .sbai-bubble-inner ol { margin: 6px 0; padding-left: 18px; }
.sbai-bubble-inner li { margin-bottom: 3px; }
.sbai-bubble-inner code {
  background: rgba(194,30,30,.08);
  color: var(--sbai-primary);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .85em;
  font-family: monospace;
}

/* Typing dots */
.sbai-typing { display: flex; gap: 4px; padding: 4px 0; }
.sbai-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--sbai-text-muted);
  opacity: .4;
  animation: sbai-bounce .9s infinite;
}
.sbai-typing span:nth-child(2) { animation-delay: .18s; }
.sbai-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes sbai-bounce {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* Cartes produits */
.sbai-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
  width: 100%;
}
.sbai-product-card {
  border: 1px solid var(--sbai-border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  font-size: 12px;
  text-decoration: none;
  color: var(--sbai-text);
  display: flex;
  flex-direction: column;
}
.sbai-product-card:hover { border-color: var(--sbai-primary); box-shadow: 0 2px 10px rgba(194,30,30,.12); }
.sbai-product-card img  { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f3f4f6; }
.sbai-product-card-body { padding: 8px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sbai-product-name  { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sbai-product-price { color: var(--sbai-primary); font-weight: 700; margin-top: auto; }
.sbai-product-cat   { color: var(--sbai-text-muted); font-size: 10.5px; }
.sbai-product-add   {
  margin: 6px 8px 8px;
  padding: 5px 8px;
  background: var(--sbai-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.sbai-product-add:hover { background: var(--sbai-primary-h); }

/* Résumé panier inline */
.sbai-cart-summary {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
  color: #166534;
}
.sbai-cart-summary strong { font-weight: 700; }

/* Actions rapides */
#sbai-quick {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--sbai-border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  background: rgba(255,255,255,.9);
}
.sbai-quick-btn {
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--sbai-border);
  border-radius: 999px;
  background: var(--sbai-surface);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  color: var(--sbai-text-muted);
  font-weight: 500;
  font-family: inherit;
}
.sbai-quick-btn:hover { border-color: var(--sbai-primary); background: rgba(194,30,30,.05); color: var(--sbai-primary); }

/* Zone de saisie */
#sbai-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--sbai-border);
  flex-shrink: 0;
}
#sbai-input {
  flex: 1;
  padding: 9px 14px;
  font-size: 13.5px;
  border: 1px solid var(--sbai-border);
  border-radius: 12px;
  background: var(--sbai-surface);
  color: var(--sbai-text);
  outline: none;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
#sbai-input:focus { border-color: var(--sbai-primary); box-shadow: 0 0 0 3px rgba(194,30,30,.1); background: #fff; }
#sbai-input::placeholder { color: var(--sbai-text-muted); opacity: .6; }
#sbai-send {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--sbai-primary);
  color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#sbai-send:hover   { background: var(--sbai-primary-h); }
#sbai-send:active  { transform: scale(.93); }
#sbai-send:disabled { opacity: .4; pointer-events: none; }

/* Message d'erreur */
.sbai-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #dc2626;
  margin-bottom: 12px;
}

@media (max-width: 480px) {
  #sbai-panel { right: 12px; bottom: 80px; width: calc(100vw - 24px); }
  #sbai-toggle { right: 12px; bottom: 16px; }
}
