/* =========================================================
   Herbe du Dragon — Chatbot · Styles
   Palette : rouge #e02727 (thème), vert #2d5016 (nature),
             crème #fff8ee, charcoal #1a1a1a
   ========================================================= */
:root {
  --hdd-red: #e02727;
  --hdd-red-dark: #a81d1d;
  --hdd-green: #2d5016;
  --hdd-green-soft: #4a7a2a;
  --hdd-cream: #fff8ee;
  --hdd-ink: #1a1a1a;
  --hdd-gray: #6b7280;
  --hdd-border: #e5e7eb;
  --hdd-shadow: 0 20px 60px rgba(0,0,0,.22), 0 4px 12px rgba(0,0,0,.08);
  --hdd-radius: 18px;
}

#hdd-chatbot-root { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#hdd-chatbot-root *, #hdd-chatbot-root *::before, #hdd-chatbot-root *::after { box-sizing: border-box; }

/* -------- Bulle flottante -------- */
.hdd-toggle {
  position: fixed; right: 20px; bottom: 20px; z-index: 99998;
  width: 64px; height: 64px; border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--hdd-red) 0%, var(--hdd-red-dark) 100%);
  box-shadow: 0 12px 32px rgba(224,39,39,.42), 0 2px 8px rgba(0,0,0,.15);
  cursor: pointer; display: grid; place-items: center;
  transition: transform .25s ease, box-shadow .25s ease;
}
.hdd-toggle:hover { transform: translateY(-3px) scale(1.04); }
.hdd-toggle:active { transform: scale(.96); }
.hdd-toggle__icon { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.hdd-toggle__aura {
  position: absolute; inset: -4px; border-radius: 50%;
  background: radial-gradient(circle, rgba(74,122,42,.55), transparent 70%);
  animation: hdd-pulse 2.4s ease-in-out infinite; pointer-events: none;
}
.hdd-toggle__dot {
  position: absolute; top: 4px; right: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff;
  animation: hdd-blink 2s infinite;
}
@keyframes hdd-pulse { 0%,100%{ transform: scale(1); opacity: .6 } 50%{ transform: scale(1.15); opacity: .2 } }
@keyframes hdd-blink { 0%,100%{ opacity: 1 } 50%{ opacity: .55 } }

/* -------- Bulle BD d'accueil (teaser) -------- */
.hdd-teaser {
  position: fixed;
  right: 100px;
  bottom: 34px;
  z-index: 99997;
  max-width: 280px;
  animation: hdd-teaser-in .5s ease-out 1.2s both;
  pointer-events: auto;
}
.hdd-teaser.hdd-teaser--hidden { display: none !important; }
.hdd-teaser__bubble {
  position: relative;
  background: #fff;
  color: #1a2a1a;
  padding: 14px 36px 14px 16px;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.08);
  font-size: 14px;
  line-height: 1.45;
  border: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  animation: hdd-teaser-bob 2.6s ease-in-out 2s infinite;
  transition: transform .2s ease, box-shadow .2s ease;
}
.hdd-teaser__bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.08);
}
.hdd-teaser__bubble::after {
  content: '';
  position: absolute;
  right: -12px;
  bottom: 18px;
  width: 0; height: 0;
  border: 12px solid transparent;
  border-left-color: #fff;
  border-right: 0;
  filter: drop-shadow(2px 0 2px rgba(0,0,0,.06));
}
.hdd-teaser__text { display: block; }
.hdd-teaser__text strong { color: var(--hdd-red, #c4302b); font-weight: 700; }
.hdd-teaser__close {
  position: absolute;
  top: 4px; right: 8px;
  width: 20px; height: 20px;
  font-size: 18px; line-height: 1;
  color: #999; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background .15s, color .15s;
}
.hdd-teaser__close:hover { background: #f0f0f0; color: #333; }
@keyframes hdd-teaser-in {
  from { opacity: 0; transform: translateX(8px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes hdd-teaser-bob {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-5px); }
}
@media (max-width: 600px) {
  .hdd-teaser { right: 80px; bottom: 28px; max-width: calc(100vw - 100px); }
  .hdd-teaser__bubble { font-size: 13px; padding: 12px 32px 12px 14px; }
}

/* -------- Panneau -------- */
.hdd-panel {
  position: fixed; right: 20px; bottom: 100px; z-index: 99999;
  width: 380px; max-width: calc(100vw - 40px);
  height: min(620px, calc(100vh - 140px));
  background: #fff; border-radius: var(--hdd-radius);
  box-shadow: var(--hdd-shadow);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: bottom right;
  animation: hdd-open .32s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes hdd-open { from { opacity: 0; transform: translateY(20px) scale(.92); } to { opacity: 1; transform: none; } }

/* Header */
.hdd-panel__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--hdd-red) 0%, var(--hdd-red-dark) 100%);
  color: #fff;
}
.hdd-panel__title { display: flex; align-items: center; gap: 12px; }
.hdd-panel__avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; object-fit: cover;
  border: 2px solid rgba(255,255,255,.4);
}
.hdd-panel__name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.hdd-panel__badge {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.22);
  letter-spacing: .5px;
}
.hdd-panel__status { font-size: 12px; opacity: .92; display: flex; align-items: center; gap: 6px; }
.hdd-dot-live {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: hdd-live 1.6s infinite;
}
@keyframes hdd-live { 0%{ box-shadow: 0 0 0 0 rgba(34,197,94,.55) } 70%{ box-shadow: 0 0 0 8px rgba(34,197,94,0) } 100%{ box-shadow: 0 0 0 0 rgba(34,197,94,0) } }
.hdd-panel__actions { display: flex; gap: 4px; }
.hdd-icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 0;
  background: rgba(255,255,255,.14); color: #fff; font-size: 18px;
  cursor: pointer; transition: background .15s;
}
.hdd-icon-btn:hover { background: rgba(255,255,255,.28); }

/* Body */
.hdd-panel__body {
  flex: 1; overflow-y: auto; padding: 16px;
  background:
    radial-gradient(ellipse at top right, rgba(74,122,42,.06), transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(224,39,39,.05), transparent 60%),
    var(--hdd-cream);
  scroll-behavior: smooth;
}
.hdd-panel__body::-webkit-scrollbar { width: 6px; }
.hdd-panel__body::-webkit-scrollbar-thumb { background: #0002; border-radius: 3px; }

/* Messages */
.hdd-msg { display: flex; margin-bottom: 12px; animation: hdd-slide .25s ease; }
@keyframes hdd-slide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.hdd-msg--bot    { justify-content: flex-start; }
.hdd-msg--user   { justify-content: flex-end; }
.hdd-msg--system { justify-content: center; }

.hdd-bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.5; word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.hdd-msg--bot .hdd-bubble  {
  background: #fff; color: var(--hdd-ink);
  border: 1px solid var(--hdd-border);
  border-bottom-left-radius: 4px;
}
.hdd-msg--user .hdd-bubble {
  background: linear-gradient(135deg, var(--hdd-green) 0%, var(--hdd-green-soft) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.hdd-msg--system .hdd-bubble {
  background: #fff8ee; color: var(--hdd-gray); font-size: 12px;
  border: 1px dashed #e0c9a1; font-style: italic;
}

.hdd-bubble strong { color: var(--hdd-red); }
.hdd-msg--user .hdd-bubble strong { color: #fff; font-weight: 700; }
.hdd-bubble p { margin: 0 0 6px; }
.hdd-bubble p:last-child { margin: 0; }
.hdd-bubble a { color: var(--hdd-red); text-decoration: underline; }
.hdd-msg--user .hdd-bubble a { color: #fff; }

/* Typing dots */
.hdd-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.hdd-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--hdd-green-soft); animation: hdd-bounce 1.2s infinite ease-in-out;
}
.hdd-typing span:nth-child(2) { animation-delay: .15s; }
.hdd-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes hdd-bounce { 0%,80%,100%{ transform: scale(.6); opacity: .4 } 40%{ transform: scale(1); opacity: 1 } }

/* Cartes produit */
.hdd-products { display: grid; gap: 10px; margin: 8px 0 4px; }
.hdd-products__see-all {
  display: block; text-align: center; padding: 10px 16px;
  background: var(--hdd-green, #0f4f3a); color: #fff !important; font-weight: 700;
  font-size: 13px; border-radius: 24px; text-decoration: none;
  transition: background .15s, transform .15s;
}
.hdd-products__see-all:hover { background: #0a3d2c; transform: translateY(-1px); }
.hdd-product {
  display: flex; gap: 10px; padding: 10px;
  background: #fff; border: 1px solid var(--hdd-border); border-radius: 12px;
  transition: transform .15s, box-shadow .15s;
}
.hdd-product:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.hdd-product__img {
  width: 72px; height: 72px; border-radius: 8px; object-fit: cover;
  background: var(--hdd-cream); flex: 0 0 72px;
}
.hdd-product__body { flex: 1; min-width: 0; }
.hdd-product__name { font-weight: 700; font-size: 13px; color: var(--hdd-ink); margin: 0 0 2px; }
.hdd-product__meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--hdd-gray); margin-bottom: 4px; flex-wrap: wrap; }
.hdd-product__price { color: var(--hdd-red); font-weight: 700; font-size: 14px; }
.hdd-product__price del { color: var(--hdd-gray); font-weight: 400; margin-right: 4px; font-size: 12px; }
.hdd-product__badge {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--hdd-red); color: #fff; text-transform: uppercase; font-weight: 700; letter-spacing: .4px;
}
.hdd-product__badge--nouveau { background: var(--hdd-green); }
.hdd-product__stock--outofstock { color: #b91c1c; }
.hdd-product__stock--low { color: #d97706; }
.hdd-product__actions { display: flex; gap: 6px; margin-top: 6px; }
.hdd-product__btn {
  flex: 1; padding: 6px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--hdd-border); background: #fff; color: var(--hdd-ink);
  cursor: pointer; text-decoration: none; text-align: center; transition: all .15s;
}
.hdd-product__btn:hover { background: var(--hdd-cream); border-color: var(--hdd-green-soft); }
.hdd-product__btn--cart { background: var(--hdd-green); color: #fff; border-color: var(--hdd-green); }
.hdd-product__btn--cart:hover { background: var(--hdd-green-soft); }
.hdd-product__variation {
  width: 100%; margin-bottom: 6px; padding: 5px 8px; border-radius: 6px;
  border: 1px solid var(--hdd-border); font-size: 11px; color: var(--hdd-ink);
  background: #fff; cursor: pointer; outline: none;
}
.hdd-product__variation:focus { border-color: var(--hdd-green); }

/* Quick actions */
.hdd-quick-actions {
  display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto;
  background: #fff; border-top: 1px solid var(--hdd-border);
  scrollbar-width: none; flex-wrap: wrap; justify-content: center;
}
.hdd-quick-actions::-webkit-scrollbar { display: none; }
.hdd-chip {
  flex-shrink: 0; padding: 6px 10px; border-radius: 100px;
  border: 1px solid var(--hdd-border); background: var(--hdd-cream);
  font-size: 11px; color: var(--hdd-ink); cursor: pointer; white-space: nowrap;
  transition: all .15s;
}
.hdd-chip:hover { background: #fff; border-color: var(--hdd-red); color: var(--hdd-red); transform: translateY(-1px); }
.hdd-chip[disabled], .hdd-chip--loading { opacity: .55; cursor: wait; pointer-events: none; transform: none; }

/* FAQ suggestions bloc */
.hdd-faq-list { display: grid; gap: 6px; margin: 6px 0 2px; }
.hdd-faq-item {
  text-align: left; padding: 8px 12px; background: #fff;
  border: 1px solid var(--hdd-border); border-radius: 10px;
  font-size: 13px; color: var(--hdd-ink); cursor: pointer;
  transition: all .15s;
}
.hdd-faq-item:hover { background: var(--hdd-cream); border-color: var(--hdd-green-soft); transform: translateX(2px); }

/* Form */
.hdd-panel__form {
  display: flex; gap: 8px; padding: 10px 12px;
  background: #fff; border-top: 1px solid var(--hdd-border);
}
#hdd-input {
  flex: 1; padding: 10px 14px; border-radius: 100px;
  border: 1px solid var(--hdd-border); font-size: 14px; background: var(--hdd-cream);
  transition: border-color .15s, background .15s;
}
#hdd-input:focus { outline: 0; border-color: var(--hdd-red); background: #fff; }
.hdd-send {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, var(--hdd-red) 0%, var(--hdd-red-dark) 100%);
  color: #fff; cursor: pointer; display: grid; place-items: center;
  transition: transform .15s;
}
.hdd-send:hover { transform: scale(1.08); }
.hdd-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* Footer */
.hdd-panel__footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 14px; font-size: 10px; color: var(--hdd-gray);
  background: var(--hdd-cream); border-top: 1px solid var(--hdd-border);
}
.hdd-panel__footer a { color: var(--hdd-gray); text-decoration: none; }
.hdd-panel__footer a:hover { color: var(--hdd-red); }

/* RGPD modal */
.hdd-rgpd {
  padding: 14px; background: #fff;
  border: 1px solid var(--hdd-border); border-radius: 12px;
  margin: 0 16px 12px; font-size: 13px; line-height: 1.5;
}
.hdd-rgpd__actions { display: flex; gap: 8px; margin-top: 10px; }
.hdd-btn {
  padding: 8px 14px; border-radius: 8px; border: 0;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.hdd-btn--primary { background: var(--hdd-red); color: #fff; }
.hdd-btn--primary:hover { background: var(--hdd-red-dark); }
.hdd-btn--ghost { background: transparent; color: var(--hdd-gray); border: 1px solid var(--hdd-border); }
.hdd-btn--ghost:hover { background: var(--hdd-cream); }

/* Escalade form */
.hdd-escalate { padding: 12px; background: #fff; border: 1px solid var(--hdd-border); border-radius: 12px; margin: 4px 0; }
.hdd-escalate h4 { margin: 0 0 8px; font-size: 14px; color: var(--hdd-ink); }
.hdd-escalate input, .hdd-escalate textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--hdd-border);
  border-radius: 8px; font-size: 13px; margin-bottom: 8px; font-family: inherit;
}
.hdd-escalate textarea { resize: vertical; min-height: 60px; }

/* Toast */
.hdd-toast {
  position: fixed; bottom: 100px; right: 20px; z-index: 100000;
  padding: 10px 16px; background: var(--hdd-green); color: #fff;
  border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: hdd-toast-in .3s ease, hdd-toast-out .3s ease 2.7s forwards;
}
@keyframes hdd-toast-in  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes hdd-toast-out { to   { opacity: 0; transform: translateY(10px); } }

/* Mobile */
@media (max-width: 480px) {
  .hdd-panel {
    right: 10px; left: 10px; bottom: 86px;
    width: auto; max-width: none;
    height: calc(100vh - 110px);
    border-radius: 14px;
  }
  .hdd-toggle { right: 14px; bottom: 14px; width: 56px; height: 56px; }
  .hdd-toggle__icon { width: 48px; height: 48px; }
}

/* Dark mode respect */
@media (prefers-color-scheme: dark) {
  .hdd-panel { background: #1e1b18; }
  .hdd-panel__body {
    background: linear-gradient(180deg, #24201c 0%, #1a1714 100%);
  }
  .hdd-msg--bot .hdd-bubble { background: #2a2521; color: #f5efe6; border-color: #3a332d; }
  .hdd-msg--system .hdd-bubble { background: #2a2521; color: #a89d91; border-color: #4a3e34; }
  .hdd-product, .hdd-chip, #hdd-input, .hdd-rgpd, .hdd-escalate {
    background: #2a2521; color: #f5efe6; border-color: #3a332d;
  }
  .hdd-product__name { color: #f5efe6; }
  .hdd-panel__form, .hdd-quick-actions { background: #1e1b18; border-color: #3a332d; }
  .hdd-panel__footer { background: #1a1714; border-color: #3a332d; }
}
