/* Empire Chat Widget — guided lead capture, no AI, direct to CRM */

/* ── Floating trigger button ─────────────────────────────────────────────── */
.empire-chat-btn {
  touch-action: manipulation;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999; /* au-dessus du panel (9997) pour rester cliquable en coin */
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--empire-accent, #E85D04);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Transition synchro avec le panel (0.32s cubic-bezier) : la bulle suit le coin */
  transition:
    top    0.32s cubic-bezier(.25,.8,.25,1),
    right  0.32s cubic-bezier(.25,.8,.25,1),
    bottom 0.32s cubic-bezier(.25,.8,.25,1),
    width  0.24s ease,
    height 0.24s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
  outline: none;
}
.empire-chat-btn:hover,
.empire-chat-btn:focus { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,0.28); }
.empire-chat-btn svg { width: 24px; height: 24px; pointer-events: none; }
/* Pulse ring — draws eye subtly */
.empire-chat-btn::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--empire-accent, #E85D04);
  opacity: 0;
  animation: empire-chat-pulse 2.8s ease-out 2s infinite;
}
@keyframes empire-chat-pulse {
  0%   { inset:-6px; opacity:.5; }
  100% { inset:-18px; opacity:0; }
}
/* Notification dot */
.empire-chat-btn__dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 12px; height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
}
/* X icon when panel open */
.empire-chat-btn.is-open .empire-chat-btn__icon-chat { display: none; }
.empire-chat-btn.is-open .empire-chat-btn__icon-close { display: block; }
.empire-chat-btn__icon-close { display: none; }

/* Quand panel ouvert : bulle ancrée sur le coin supérieur droit du panel.
   Les valeurs top/right sont injectées par JS au moment de l'ouverture
   (mesure dynamique de la hauteur réelle du panel via offsetHeight). */
.empire-chat-btn.is-open {
  bottom: auto;
  width: 40px;
  height: 40px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.22);
}
.empire-chat-btn.is-open::after { display: none; } /* pas de pulse sur close btn */
.empire-chat-btn.is-open svg { width: 18px; height: 18px; }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.empire-chat-panel {
  position: fixed;
  z-index: 9997;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
  overflow: hidden;
  transform: translateY(110%);
  transition: transform 0.32s cubic-bezier(.25,.8,.25,1), visibility 0s linear 0.32s, opacity 0.32s;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  /* Mobile: bottom sheet détaché des 4 bords, arrondis complets visibles.
     Largeur calculée explicitement + centrée via left + transform (évite tout
     clipping dû à un conteneur transformé ou à un debordement horizontal). */
  bottom: 12px !important;
  left: 50% !important;
  right: auto !important;
  width: calc(100vw - 24px) !important;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  box-sizing: border-box;
  transform: translateX(-50%) translateY(110%);
}
.empire-chat-panel.is-open {
  transform: translateX(-50%) translateY(0) !important;
}
@media (min-width: 560px) {
  .empire-chat-panel {
    bottom: 90px !important;
    left: auto !important;
    right: 24px !important;
    width: 360px !important;
    max-width: 360px;
    border-radius: 16px;
    max-height: 540px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    transform: translateY(110%);
  }
  .empire-chat-panel.is-open {
    transform: translateY(0) !important;
  }
}
.empire-chat-panel.is-open { transform: translateY(0); visibility: visible; opacity: 1; pointer-events: auto; transition: transform 0.32s cubic-bezier(.25,.8,.25,1), visibility 0s, opacity 0.18s; }

/* Header */
.empire-chat-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--empire-accent, #E85D04);
  color: #fff;
  flex-shrink: 0;
}
.empire-chat-panel__avatar {
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.empire-chat-panel__avatar svg { width: 20px; height: 20px; }
.empire-chat-panel__title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.empire-chat-panel__sub { font-size: 11px; opacity: 0.85; margin-top: 1px; }
.empire-chat-panel__online {
  display: inline-block;
  width: 7px; height: 7px;
  background: #22c55e;
  border-radius: 50%;
  margin-right: 4px;
}

/* Messages area */
.empire-chat-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
/* Bot bubble */
.empire-chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
}
.empire-chat-msg__bubble {
  background: #f4f4f5;
  color: #111;
  border-radius: 16px 16px 16px 4px;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.45;
  max-width: 82%;
}
/* Typing indicator */
.empire-chat-typing .empire-chat-msg__bubble {
  display: flex; gap: 4px; align-items: center; padding: 14px;
}
.empire-chat-typing span {
  display: inline-block;
  width: 7px; height: 7px;
  background: #aaa;
  border-radius: 50%;
  animation: empire-chat-bounce 1.1s infinite;
}
.empire-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.empire-chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes empire-chat-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-6px); }
}

/* Choice buttons */
.empire-chat-choices {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-left: 0;
}
.empire-chat-choice {
  background: #fff;
  border: 1.5px solid #e4e4e7;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #111;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.3;
}
.empire-chat-choice:hover,
.empire-chat-choice:focus {
  border-color: var(--empire-accent, #E85D04);
  background: #fdf6f2;
  outline: none;
}
/* User reply bubble */
.empire-chat-msg--user {
  justify-content: flex-end;
}
.empire-chat-msg--user .empire-chat-msg__bubble {
  background: var(--empire-accent, #E85D04);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

/* Input row */
.empire-chat-panel__footer {
  padding: 12px 16px 16px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.empire-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.empire-chat-input {
  flex: 1;
  border: 1.5px solid #e4e4e7;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  color: #111;
  outline: none;
  transition: border-color 0.15s;
  background: #fafafa;
  -webkit-appearance: none;
}
.empire-chat-input:focus { border-color: var(--empire-accent, #E85D04); background: #fff; }
.empire-chat-send {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--empire-accent, #E85D04);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.empire-chat-send:disabled { opacity: 0.4; cursor: default; }
.empire-chat-send svg { width: 18px; height: 18px; }
/* Honeypot — must be hidden from all users */
.empire-chat-hp { position:absolute; left:-9999px; opacity:0; pointer-events:none; tabindex:-1; }

/* Step progress dots */
.empire-chat-progress {
  display: flex;
  gap: 5px;
  justify-content: center;
  padding: 8px 0 0;
}
.empire-chat-progress__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #e4e4e7;
  transition: background 0.2s;
}
.empire-chat-progress__dot.active { background: var(--empire-accent, #E85D04); }
.empire-chat-progress__dot.done   { background: #22c55e; }

/* Success state */
.empire-chat-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px 24px;
  text-align: center;
  flex: 1;
}
.empire-chat-success svg { color: #22c55e; }
.empire-chat-success__title { font-size: 18px; font-weight: 700; color: #111; }
.empire-chat-success__sub   { font-size: 13px; color: #777; line-height: 1.5; }
