/* HEL Chatbot v3.5 - Styles */
:root {
  --hel-bd: #2a2a9d;
  --hel-bl: #5656ba;
  --hel-gd: #01b680;
  --hel-gl: #1bc997;
  --hel-ye: #ffa000;
  --hel-text: #1a1a4e;
  --hel-gray: #6b7280;
  --hel-radius: 18px;
  --hel-shadow: 0 20px 60px rgba(42,42,157,.2);
  --hel-bubble-bg: #ffffff;
  --hel-bubble-border: rgba(42,42,157,.06);
  --hel-msgs-bg: #f4f5fb;
  --hel-input-bg: #f7f8ff;
  --hel-foot-bg: #ffffff;
  --hel-ftr-bg: #ffffff;
  --hel-card-bg: #f0f0fa;
  --hel-card-border: rgba(42,42,157,.1);
}

/* MODE SOMBRE */
@media (prefers-color-scheme: dark) {
  :root {
    --hel-bubble-bg: #5560cc;
    --hel-bubble-border: rgba(86,86,186,.2);
    --hel-msgs-bg: #3d4490;
    --hel-input-bg: #3a40a0;
    --hel-foot-bg: #363c90;
    --hel-ftr-bg: #363c90;
    --hel-text: #eaeaf8;
    --hel-gray: #a8b0c0;
    --hel-card-bg: #2b2b4e;
    --hel-card-border: rgba(86,86,186,.3);
    --hel-shadow: 0 20px 60px rgba(0,0,0,.4);
  }
  /* Liens lisibles sur fond sombre */
  .hel-msg.hel-b .hel-bubble a,
  .hel-msg.hel-b .hel-bubble .hel-link {
    color: #7ec8ff;
  }
  .hel-msg.hel-b .hel-bubble strong {
    color: #d0d8ff;
  }
  /* Avatar visiteur : gradient bleu dans les deux modes, pas d'override nécessaire */
}

/* TRIGGER BUTTON — ouverture en bulle depuis le bouton */
#hel-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  background: linear-gradient(135deg, var(--hel-bd), var(--hel-bl));
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(42,42,157,.45);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;
  z-index: 99998;
  border: none;
}
#hel-trigger:hover {
  transform: scale(1.12);
  box-shadow: 0 12px 40px rgba(42,42,157,.6);
}
#hel-trigger.hel-open { transform: scale(0.9); }

.hel-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 20px; height: 20px;
  background: var(--hel-ye);
  border-radius: 50%;
  border: 2px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--hel-text);
  animation: hel-bounce 2s infinite;
}
@keyframes hel-bounce { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }

/* CHAT WINDOW — transition depuis le bouton */
#hel-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 390px;
  height: 620px;
  background: var(--hel-bubble-bg);
  border-radius: var(--hel-radius);
  box-shadow: var(--hel-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  opacity: 0;
  transform: translateY(16px) scale(.92);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .28s ease, transform .32s cubic-bezier(.34,1.4,.64,1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#hel-window.hel-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* HEADER */
.hel-header {
  background: linear-gradient(135deg, var(--hel-bd) 0%, var(--hel-bl) 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}
.hel-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--hel-gd), var(--hel-gl), var(--hel-ye));
}
.hel-logo {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.hel-logo img {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block;
}
.hel-hinfo h3 {
  color: white;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}
.hel-hinfo p {
  color: rgba(255,255,255,.7);
  font-size: 11px;
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.hel-dot {
  width: 7px; height: 7px;
  background: var(--hel-gl);
  border-radius: 50%;
  animation: hel-pulse 2s infinite;
  box-shadow: 0 0 6px rgba(27,201,151,.6);
}
@keyframes hel-pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.7;transform:scale(1.2)} }
.hel-close, .hel-new {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: 50%;
  width: 30px; height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
  transition: background .15s, transform .15s;
}
.hel-close { margin-left: auto; }
/* Bouton "Nouvelle conversation" : style pill distinct du bouton fermer */
.hel-new {
  margin-left: auto;
  margin-right: 6px;
  border-radius: 14px;   /* pill, pas cercle */
  width: auto;
  padding: 0 11px;
  height: 28px;
  font-size: 17px;
  font-weight: 700;
  background: rgba(255,255,255,.22);
  border: 1.5px solid rgba(255,255,255,.45);
  letter-spacing: 0;
}
.hel-close:hover {
  background: rgba(255,255,255,.32);
  transform: scale(1.1);
}
.hel-new:hover {
  background: rgba(27,201,151,.45); /* vert HEL au hover */
  border-color: rgba(27,201,151,.7);
  transform: scale(1.05);
}

/* MESSAGES */
#hel-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--hel-msgs-bg);
  scroll-behavior: smooth;
}
#hel-msgs::-webkit-scrollbar { width: 3px; }
#hel-msgs::-webkit-scrollbar-thumb { background: var(--hel-bl); border-radius: 2px; opacity: .4; }

.hel-msg {
  display: flex;
  gap: 8px;
  animation: hel-in .22s cubic-bezier(.34,1.4,.64,1);
}
@keyframes hel-in { from{opacity:0;transform:translateY(8px) scale(.97)} to{opacity:1;transform:translateY(0) scale(1)} }
.hel-msg.hel-u { flex-direction: row-reverse; margin-left: auto; max-width: 80%; }
.hel-msg.hel-b { max-width: 88%; }

.hel-av {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
}
.hel-av.bot {
  background: #2b2b9e;
  overflow: hidden;
  padding: 0;
  box-shadow: 0 2px 8px rgba(42,42,157,.25);
}
.hel-av.bot img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  object-position: center 10%;
  border-radius: 50%;
  transform: scale(1.15);
  display: block;
}
.hel-av.usr {
  background: linear-gradient(135deg, #017a55, #01b680);
  color: white;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(1,182,128,.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hel-av.usr svg { display: block; }

.hel-bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
}
.hel-msg.hel-b .hel-bubble {
  background: #5565d5 !important;
  color: #ffffff !important;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 2px 16px rgba(0,0,100,.3);
}
.hel-msg.hel-u .hel-bubble {
  background: linear-gradient(135deg, #017a55, #01b680);
  color: #ffffff !important;
  border-radius: 14px 4px 14px 14px;
  box-shadow: 0 2px 12px rgba(1,182,128,.3);
}
.hel-bubble a, .hel-bubble .hel-link {
  color: var(--hel-bd);
  font-weight: 500;
  text-decoration: underline;
  word-break: break-all;
}
.hel-msg.hel-b .hel-bubble a,
.hel-msg.hel-b .hel-bubble .hel-link {
  color: #4dffbb !important;
}
.hel-msg.hel-b .hel-bubble strong {
  color: #ffffff !important;
}
.hel-msg.hel-u .hel-bubble a,
.hel-msg.hel-u .hel-bubble .hel-link { color: rgba(255,255,255,.9); }

.hel-ts {
  font-size: 10px;
  color: var(--hel-gray);
  margin-top: 3px;
  padding: 0 3px;
}
.hel-msg.hel-u .hel-ts { text-align: right; }

/* QUICK REPLIES */
.hel-qrs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.hel-qr {
  background: var(--hel-bd);
  border: none;
  color: white;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s, transform .15s;
}
.hel-qr:hover { background: var(--hel-bl); transform: translateY(-1px); }
.hel-qr:active { transform: scale(.97); }

/* CARTES SERVICES */
.hel-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--hel-card-bg);
  border: 1px solid var(--hel-card-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  animation: hel-in .25s ease;
}
.hel-card-icon { font-size: 20px; flex-shrink: 0; }
.hel-card-body { flex: 1; min-width: 0; }
.hel-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hel-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hel-card-meta {
  font-size: 11px;
  color: var(--hel-gray);
  margin-top: 2px;
}
.hel-card-btn {
  background: var(--hel-gd);
  color: white !important;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none !important;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}
.hel-card-btn:hover { background: var(--hel-gl); transform: translateY(-1px); }

/* TYPING — animation améliorée */
.hel-typing {
  display: flex;
  gap: 6px;
  padding: 14px 18px;
  background: #5560cc;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 2px 12px rgba(0,0,80,.25);
  width: fit-content;
  align-items: center;
}
.hel-td {
  width: 9px; height: 9px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: hel-ty 1.2s ease-in-out infinite;
}
.hel-td:nth-child(2) { animation-delay: .18s; }
.hel-td:nth-child(3) { animation-delay: .36s; }
@keyframes hel-ty {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* INPUT */
.hel-foot {
  padding: 11px 13px;
  background: var(--hel-foot-bg);
  border-top: 1px solid rgba(42,42,157,.07);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#hel-inp {
  flex: 1;
  border: 1.5px solid rgba(42,42,157,.15);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--hel-text);
  resize: none;
  outline: none;
  max-height: 90px;
  transition: border-color .2s, box-shadow .2s;
  background: var(--hel-input-bg);
  line-height: 1.5;
  font-family: inherit;
}
#hel-inp:focus {
  border-color: var(--hel-bl);
  box-shadow: 0 0 0 3px rgba(86,86,186,.1);
}
#hel-inp::placeholder { color: #9ca3af; }
#hel-send {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--hel-bd), var(--hel-bl));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(42,42,157,.3);
  transition: all .2s;
}
#hel-send:hover { transform: scale(1.07); box-shadow: 0 6px 16px rgba(42,42,157,.4); }
#hel-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.hel-ftr {
  text-align: center;
  padding: 8px 12px;
  font-size: 11px;
  color: #4a5070;
  background: var(--hel-ftr-bg);
  border-top: 1px solid rgba(0,0,0,.08);
  flex-shrink: 0;
  line-height: 1.6;
}
.hel-ftr a, .hel-ftr strong {
  color: var(--hel-gd);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hel-ftr span {
  display: block;
  font-style: italic;
  margin-top: 2px;
}
@media (prefers-color-scheme: dark) {
  .hel-ftr {
    color: #e8ecff !important;
    background: #3a3a6a !important;
    border-top-color: rgba(255,255,255,.2) !important;
  }
  .hel-ftr a, .hel-ftr strong {
    color: #00d09a !important;
    font-weight: 700;
  }
  .hel-ftr span {
    color: #c8d0f0 !important;
    opacity: 1 !important;
  }
}

@media (max-width: 480px) {
  #hel-window {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 88px;
    height: 72vh;
    border-radius: 16px;
  }
}

/* ACTIONS (copier / feedback) */
.hel-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 3px;
  padding: 0 3px;
}
.hel-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .2s;
}
.hel-msg.hel-b:hover .hel-actions { opacity: 1; }
.hel-act {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: .6;
  transition: opacity .15s, transform .15s;
}
.hel-act:hover { opacity: 1; transform: scale(1.1); }
.hel-act:disabled { cursor: default; }
.hel-thumb:disabled { opacity: .35; }
.hel-thumb { transition: opacity .15s, transform .3s; }


/* R8 — Bouton scroll to bottom */
#hel-scroll-btn {
  position: absolute;
  bottom: 110px;
  right: 18px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--hel-bd);
  border: none;
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(42,42,157,.3);
  z-index: 10;
  transition: opacity .2s, transform .2s;
}
#hel-scroll-btn:hover { transform: scale(1.1); }

/* R9 — Bouton retry */
.hel-retry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  padding: 5px 12px;
  background: none;
  border: 1.5px solid var(--hel-bd);
  border-radius: 16px;
  color: var(--hel-bd);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.hel-retry:hover { background: var(--hel-bd); color: white; }

/* ── FEAT 2 — Teaser proactif ── */
#hel-teaser {
  position: fixed;
  bottom: 98px;
  right: 24px;
  background: var(--hel-bd);
  color: white;
  padding: 10px 16px;
  border-radius: 12px 12px 4px 12px;
  font-size: 13px;
  line-height: 1.45;
  max-width: 240px;
  box-shadow: 0 6px 24px rgba(42,42,157,.35);
  cursor: pointer;
  z-index: 99997;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: hel-in .3s cubic-bezier(.34,1.4,.64,1);
}
#hel-teaser::after {
  content: '';
  position: absolute;
  bottom: -8px; right: 16px;
  border: 5px solid transparent;
  border-top-color: var(--hel-bd);
  border-bottom: none;
}

/* ── FEAT 3 — Actions visibles sur mobile (hover: none) ── */
@media (hover: none) {
  .hel-actions { opacity: 1; }
  .hel-actions.hel-visible { opacity: 1; }
}

/* ── FEAT 6 — Stepper commande ── */
/* STEPPER DÉSACTIVÉ
.hel-stepper {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--hel-card-bg);
  border: 1px solid var(--hel-card-border);
  border-radius: 10px;
  font-size: 12px;
}
*/
/* STEPPER DÉSACTIVÉ
.hel-stepper-num {
  font-weight: 600;
  color: var(--hel-text);
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: .3px;
}
*/
/* STEPPER DÉSACTIVÉ
.hel-stepper-cancelled { color: #e24b4a; font-size: 12px; }
*/
.hel-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
}
.hel-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 4px;
}
.hel-step-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--hel-card-bg);
  border: 2px solid rgba(42,42,157,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--hel-gray);
  transition: all .2s;
}
.hel-step.done .hel-step-dot {
  background: var(--hel-gd);
  border-color: var(--hel-gd);
  color: white;
}
.hel-step.active .hel-step-dot {
  background: var(--hel-bd);
  border-color: var(--hel-bd);
  color: white;
  box-shadow: 0 0 0 3px rgba(42,42,157,.15);
}
.hel-step-name {
  font-size: 9px;
  color: var(--hel-gray);
  text-align: center;
  line-height: 1.2;
}
.hel-step.done .hel-step-name,
.hel-step.active .hel-step-name { color: var(--hel-text); font-weight: 600; }
.hel-step-line {
  flex: 2;
  height: 2px;
  background: rgba(42,42,157,.15);
  margin-top: 12px;
  border-radius: 2px;
}
.hel-progress-track {
  height: 4px;
  background: rgba(42,42,157,.12);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}
.hel-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--hel-bd), var(--hel-bl));
  border-radius: 4px;
  transition: width .6s ease;
}
.hel-progress-fill.overdue { background: linear-gradient(90deg, #ffa000, #e24b4a); }
.hel-step-date {
  font-size: 10px;
  color: var(--hel-gray);
  margin-top: 5px;
  text-align: right;
}
.hel-step-date.overdue { color: #e24b4a; font-weight: 600; }

@media (min-width: 768px) {
  #hel-window {
    height: min(700px, 85vh);
    width: 400px;
  }
  #hel-msgs {
    min-height: 300px;
  }
}


/* ========== ENGAGEMENT PROACTIF ========== */
@keyframes hel-bounce {
  0%,100% { transform: translateY(0) scale(1); }
  20%      { transform: translateY(-12px) scale(1.08); }
  40%      { transform: translateY(-6px) scale(1.04); }
  60%      { transform: translateY(-10px) scale(1.06); }
  80%      { transform: translateY(-3px) scale(1.02); }
}
@keyframes hel-pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(1,182,128,.6); }
  70%  { box-shadow: 0 0 0 18px rgba(1,182,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(1,182,128,0); }
}
@keyframes hel-tooltip-in {
  from { opacity:0; transform: translateY(8px) scale(.95); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

#hel-trigger.hel-bounce {
  animation: hel-bounce .8s ease, hel-pulse-ring 1.2s ease 0s 3;
}

/* Tooltip proactif au-dessus du bouton */
#hel-proactive-tooltip {
  position: fixed;
  bottom: 88px;
  right: 24px;
  background: #5560cc;
  color: white;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,50,.4);
  border: 1px solid rgba(1,182,128,.3);
  animation: hel-tooltip-in .3s ease forwards;
  cursor: pointer;
  z-index: 9998;
  max-width: 220px;
  white-space: normal;
  line-height: 1.4;
}
#hel-proactive-tooltip::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 20px;
  border: 7px solid transparent;
  border-top-color: #5560cc;
  border-bottom: 0;
}
#hel-proactive-tooltip .hel-pt-close {
  display: inline-block;
  margin-left: 8px;
  opacity: .6;
  cursor: pointer;
  font-size: 11px;
  vertical-align: middle;
}
#hel-proactive-tooltip .hel-pt-close:hover { opacity: 1; }
