/* ============================================================================
   Baroud'O — Widget chat en direct (côté site public)
   Bulle bas-gauche + panneau de discussion moderne.
   ============================================================================ */

#bdo-chat {
  position: fixed; left: 20px; bottom: 20px; z-index: 99999;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Bulle déclencheur ────────────────────────────────────────────────── */
#bdo-chat .bdo-chat-trigger {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #059669, #10b981);
  border: 0; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 25px -5px rgba(5, 150, 105, .45);
  font-size: 26px;
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
#bdo-chat .bdo-chat-trigger:hover { transform: scale(1.06); box-shadow: 0 14px 30px -5px rgba(5,150,105,.55); }
#bdo-chat .bdo-chat-trigger .bdo-icon-close { display: none; }
#bdo-chat.is-open .bdo-chat-trigger .bdo-icon-open  { display: none; }
#bdo-chat.is-open .bdo-chat-trigger .bdo-icon-close { display: block; }

/* Pastille messages non lus */
#bdo-chat .bdo-chat-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 22px; text-align: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15);
  display: none;
}
#bdo-chat .bdo-chat-badge.is-on { display: block; animation: bdo-pop .35s ease-out; }
@keyframes bdo-pop { 0% { transform: scale(0); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* ── Panneau ─────────────────────────────────────────────────────────── */
#bdo-chat .bdo-chat-panel {
  position: absolute; left: 0; bottom: 78px;
  width: 360px; max-width: calc(100vw - 40px);
  height: 520px; max-height: calc(100vh - 130px);
  background: #fff; border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; overflow: hidden;
  /* État fermé : invisible + non-cliquable */
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(20px) scale(.92);
  transform-origin: left bottom;
  transition: opacity .25s cubic-bezier(.4,0,.2,1),
              transform .35s cubic-bezier(.34,1.56,.64,1),
              visibility 0s linear .35s;
}
#bdo-chat.is-open .bdo-chat-panel {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity .25s cubic-bezier(.4,0,.2,1),
              transform .4s cubic-bezier(.34,1.56,.64,1),
              visibility 0s linear 0s;
}

/* Petite secousse de la bulle au moment du clic d'ouverture */
@keyframes bdo-bounce {
  0%, 100% { transform: scale(1); }
  40%      { transform: scale(.88); }
  70%      { transform: scale(1.08); }
}
#bdo-chat .bdo-chat-trigger.is-clicked { animation: bdo-bounce .35s ease-out; }

/* Rotation de l'icône au passage ouvert/fermé */
#bdo-chat .bdo-chat-trigger .bdo-icon-open,
#bdo-chat .bdo-chat-trigger .bdo-icon-close {
  transition: transform .25s ease, opacity .2s ease;
}
#bdo-chat.is-open .bdo-chat-trigger .bdo-icon-open { transform: rotate(90deg) scale(.4); opacity: 0; }
#bdo-chat .bdo-chat-trigger .bdo-icon-close { transform: rotate(-90deg) scale(.4); opacity: 0; }
#bdo-chat.is-open .bdo-chat-trigger .bdo-icon-close { transform: rotate(0) scale(1); opacity: 1; }
#bdo-chat:not(.is-open) .bdo-chat-trigger .bdo-icon-open { transform: rotate(0) scale(1); opacity: 1; }

/* Animation cascade des messages à l'ouverture */
@keyframes bdo-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#bdo-chat.is-open .bdo-chat-panel .bdo-msg,
#bdo-chat.is-open .bdo-chat-panel .bdo-intro {
  animation: bdo-fade-up .35s ease-out both;
}
/* Stagger via delay sur les 5 premiers éléments */
#bdo-chat.is-open .bdo-chat-panel > .bdo-panel-body > :nth-child(1) { animation-delay: .15s; }
#bdo-chat.is-open .bdo-chat-panel > .bdo-panel-body > :nth-child(2) { animation-delay: .22s; }
#bdo-chat.is-open .bdo-chat-panel > .bdo-panel-body > :nth-child(3) { animation-delay: .29s; }
#bdo-chat.is-open .bdo-chat-panel > .bdo-panel-body > :nth-child(4) { animation-delay: .36s; }
#bdo-chat.is-open .bdo-chat-panel > .bdo-panel-body > :nth-child(5) { animation-delay: .43s; }

/* En-tête du panneau */
#bdo-chat .bdo-panel-head {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; padding: 16px 18px;
}
#bdo-chat .bdo-panel-head h4 { margin: 0 0 2px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
#bdo-chat .bdo-panel-head p  { margin: 0; font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; }
#bdo-chat .bdo-panel-head .bdo-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 0 rgba(255,255,255,.6); animation: bdo-pulse 1.6s infinite;
}
@keyframes bdo-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,.6); }
  70%  { box-shadow: 0 0 0 8px rgba(255,255,255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255, 0); }
}

/* Corps : messages */
#bdo-chat .bdo-panel-body {
  flex: 1; overflow-y: auto; padding: 16px;
  background: #f7f8fa;
  display: flex; flex-direction: column; gap: 10px;
}
#bdo-chat .bdo-msg {
  max-width: 80%; padding: 9px 13px; border-radius: 16px;
  font-size: 14px; line-height: 1.4; word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
#bdo-chat .bdo-msg.visitor {
  background: linear-gradient(135deg, #059669, #10b981); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
#bdo-chat .bdo-msg.admin {
  background: #fff; color: #0f172a;
  align-self: flex-start; border-bottom-left-radius: 4px;
}
#bdo-chat .bdo-msg-time {
  font-size: 10px; opacity: .55; margin-top: 4px;
  text-align: right;
}
#bdo-chat .bdo-msg.admin .bdo-msg-time { text-align: left; }

#bdo-chat .bdo-msg-name {
  font-size: 11px; font-weight: 600; opacity: .8; margin-bottom: 3px;
}
#bdo-chat .bdo-msg.visitor .bdo-msg-name { color: rgba(255,255,255,.85); }
#bdo-chat .bdo-msg.admin   .bdo-msg-name { color: #059669; }

/* Intro / welcome */
#bdo-chat .bdo-intro {
  text-align: center; color: #475569; font-size: 13px;
  padding: 10px 14px; background: #fff; border-radius: 12px;
  align-self: stretch; margin: 4px 0; line-height: 1.45;
}
#bdo-chat .bdo-intro strong { color: #059669; }

/* Pied : input */
#bdo-chat .bdo-panel-foot {
  border-top: 1px solid #eaecef; padding: 10px 12px;
  background: #fff; display: flex; gap: 8px; align-items: flex-end;
}
#bdo-chat .bdo-input {
  flex: 1; border: 1px solid #eaecef; background: #fafbfc; outline: none;
  border-radius: 12px; padding: 10px 12px;
  font-size: 14px; color: #0f172a; resize: none; max-height: 110px;
  font-family: inherit; line-height: 1.4;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
#bdo-chat .bdo-input:focus { border-color: #059669; background: #fff;
  box-shadow: 0 0 0 3px rgba(5,150,105,.10); }
#bdo-chat .bdo-send {
  background: #059669; color: #fff; border: 0; cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .12s;
  flex-shrink: 0;
}
#bdo-chat .bdo-send:hover:not(:disabled) { background: #047857; transform: translateY(-1px); }
#bdo-chat .bdo-send:disabled { opacity: .5; cursor: not-allowed; }

#bdo-chat .bdo-typing {
  font-size: 12px; color: #94a3b8; padding: 6px 12px;
  display: none; align-items: center; gap: 4px;
}
#bdo-chat .bdo-typing.on { display: inline-flex; }
#bdo-chat .bdo-typing span {
  width: 5px; height: 5px; border-radius: 50%; background: #94a3b8;
  animation: bdo-bounce 1.2s infinite;
}
#bdo-chat .bdo-typing span:nth-child(2) { animation-delay: .15s; }
#bdo-chat .bdo-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes bdo-bounce { 0%,80%,100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Sur petit écran : le panneau prend toute la largeur */
@media (max-width: 460px) {
  #bdo-chat { left: 12px; bottom: 12px; }
  #bdo-chat .bdo-chat-panel {
    width: calc(100vw - 24px); height: calc(100vh - 100px); left: 0; bottom: 70px;
  }
}
