/* ============================================================
   chat.css — Widget assistant IA électricien
   ============================================================ */

/* ── Bouton toggle ── */
/* position: fixed + coordonnées gérées par #elec-chat dans shared.css (render-blocking)
   → pas de redéclaration ici pour éviter tout shift quand chat.css charge async */

.echat-toggle {
  position: relative;
  width: 54px !important; height: 54px !important;
  border-radius: 50% !important;
  background: var(--bleu) !important;
  border: none !important; cursor: pointer;
  display: flex !important; align-items: center !important; justify-content: center !important;
  padding: 0 !important;
  box-shadow: 0 4px 18px rgba(27,58,107,0.38);
  transition: transform 0.2s;
  color: #fff !important;
}
.echat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(27,58,107,0.48);
}

/* Icônes — forcées visibles, taille fixe, résistantes aux resets Astra */
.echat-icon-chat {
  display: block !important;
  width: 22px !important; height: 22px !important;
  stroke: #fff !important; fill: none !important;
}
.echat-icon-close {
  display: none !important;
  width: 20px !important; height: 20px !important;
  stroke: #fff !important; fill: none !important;
}
.echat.is-open .echat-icon-chat  { display: none  !important; }
.echat.is-open .echat-icon-close { display: block !important; }

.echat-notif {
  position: absolute; top: -3px; right: -3px;
  background: var(--rouge); color: #fff;
  font-size: 10px; font-weight: 700;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  transition: opacity 0.2s, transform 0.2s;
  animation: notifPop 0.4s ease 1.5s both;
}
.echat.is-open .echat-notif { opacity: 0; transform: scale(0); }

/* Pulse discret sur le toggle */
.echat-toggle.pulse::before {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--bleu);
  animation: pulseRing 1.2s ease-out 3;
}

/* ── Panel ── */
.echat-panel {
  position: absolute;
  bottom: 66px; right: 0;
  width: 320px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 44px rgba(27,58,107,0.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  transform-origin: bottom right;
}
.echat.is-open .echat-panel {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */
.echat-header {
  background: var(--bleu);
  padding: 13px 14px;
  display: flex; align-items: center; gap: 11px;
  flex-shrink: 0;
}
.echat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.echat-header-text { flex: 1; min-width: 0; }
.echat-header-text strong { display: block; color: #fff; font-size: 0.86rem; }
.echat-status { font-size: 0.7rem; color: rgba(255,255,255,0.65); }
.echat-close {
  background: none; border: none; cursor: pointer;
  color: #fff; opacity: 0.65; padding: 4px;
  border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.echat-close:hover { opacity: 1; }

/* ── Zone messages ── */
.echat-messages {
  flex: 1; overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 160px; max-height: 270px;
  scroll-behavior: smooth;
}
.echat-messages::-webkit-scrollbar { width: 4px; }
.echat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Bulles */
.echat-msg { display: flex; flex-direction: column; max-width: 88%; animation: chatIn 0.2s ease; }
.echat-msg.bot  { align-self: flex-start; }
.echat-msg.user { align-self: flex-end; }

.echat-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.83rem; line-height: 1.58;
}
.bot  .echat-bubble { background: var(--bleu-clair); color: var(--texte); border-bottom-left-radius: 4px; }
.user .echat-bubble { background: var(--bleu); color: #fff; border-bottom-right-radius: 4px; }

/* Bulle urgente */
.echat-bubble--urgent {
  background: #FEF2F4;
  border-left: 3px solid var(--rouge);
  padding-left: 11px;
}
.echat-badge-urgent {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--rouge); color: #fff;
  font-size: 0.7rem; font-weight: 700; letter-spacing: .3px;
  padding: 3px 8px; border-radius: 4px;
  margin-bottom: 7px;
}

/* Tableau de prix inline */
.echat-prix-table {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex; flex-direction: column; gap: 5px;
}
.echat-prix-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 0.78rem;
}
.echat-prix-nom { color: var(--texte-doux); flex: 1; }
.echat-prix-val { font-weight: 700; color: var(--bleu); white-space: nowrap; }
.echat-bubble--urgent .echat-prix-val { color: var(--rouge); }
.echat-prix-majore {
  margin-top: 4px;
  font-size: 0.72rem; font-weight: 600;
  color: var(--rouge);
  background: #FEF2F4; border-radius: 4px;
  padding: 4px 8px;
}

/* Indicateur de frappe */
.echat-typing {
  display: flex; gap: 5px; align-items: center;
  padding: 12px 14px;
  background: var(--bleu-clair);
  border-radius: 14px; border-bottom-left-radius: 4px;
  align-self: flex-start; width: fit-content;
  animation: chatIn 0.2s ease;
}
.echat-typing span {
  width: 7px; height: 7px;
  background: var(--muted); border-radius: 50%;
  animation: typingDot 1.3s infinite;
}
.echat-typing span:nth-child(2) { animation-delay: 0.22s; }
.echat-typing span:nth-child(3) { animation-delay: 0.44s; }

/* CTA dans les bulles */
.echat-cta-group { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.echat-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 8px;
  font-size: 0.8rem; font-weight: 600;
  text-decoration: none; white-space: nowrap;
  transition: filter 0.15s;
}
.echat-cta:hover { filter: brightness(0.9); }
.echat-cta.tel { background: var(--bleu); color: #fff !important; }
.echat-cta.tel svg { stroke: #fff; }
.echat-cta.wa  { background: var(--wa-green); color: #fff !important; }
.echat-cta.wa  svg { fill: #fff; }

/* ── Chips suggestions ── */
.echat-chips {
  padding: 2px 12px 10px;
  display: flex; flex-wrap: wrap; gap: 6px;
  flex-shrink: 0;
}
.echat-chip {
  background: var(--bleu-clair);
  color: var(--bleu);
  border: 1px solid #C8D8F0;
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 0.76rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font-b);
}
.echat-chip:hover { background: var(--bleu); color: #fff; border-color: var(--bleu); }

/* ── Barre de saisie ── */
.echat-input-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.echat-input {
  flex: 1;
  border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.82rem; font-family: var(--font-b);
  color: var(--texte); background: #fff;
  outline: none;
}
.echat-input:focus { border-color: var(--bleu-mid); }
.echat-input:disabled { opacity: 0.5; }

.echat-send {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bleu); color: #fff;
  border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.echat-send:hover { background: var(--bleu-mid); }
.echat-send:disabled { opacity: 0.4; cursor: default; }

/* ── Animations ── */
@keyframes chatIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-5px); opacity: 1; }
}
@keyframes notifPop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
@keyframes pulseRing {
  from { opacity: 0.6; transform: scale(0.9); }
  to   { opacity: 0; transform: scale(1.5); }
}

/* ── Mobile ── */
@media (max-width: 767px) {
  .echat-panel { width: calc(100vw - 54px); max-width: 340px; right: 0; left: auto; }
}
