/* ================================================================
   DIGITPILOTE — Bot Assistant Widget v1.0
   Bulle flottante universelle — thème brand DigitPilote
   ================================================================ */

/* ── Variables brand ─────────────────────────────────────────── */
:root {
  --bot-gold:        #C8A96B;
  --bot-gold-light:  rgba(200,169,107,.18);
  --bot-green:       #4a7c59;
  --bot-green-dark:  #2F4F3E;
  /* Fond beige crème DigitPilote */
  --bot-bg:          #F5EFE4;
  --bot-bg2:         #EDE5D6;
  --bot-bg3:         #E8DFC9;
  --bot-border:      rgba(200,169,107,.35);
  --bot-text:        #2C2416;
  --bot-text2:       rgba(44,36,22,.55);
  --bot-radius:      16px;
  --bot-shadow:      0 8px 40px rgba(0,0,0,.22), 0 2px 12px rgba(200,169,107,.18);
  --bot-w:           360px;
  --bot-h:           520px;
}

/* ── Bouton bulle flottante ──────────────────────────────────── */
#dp-bot-bubble {
  position:         fixed;
  bottom:           24px;
  right:            24px;
  z-index:          99999;
  width:            56px;
  height:           56px;
  border-radius:    50%;
  background:       linear-gradient(135deg, #2F4F3E, #4a7c59);
  border:           2px solid var(--bot-gold);
  box-shadow:       0 4px 20px rgba(0,0,0,.4), 0 0 0 0 rgba(200,169,107,.4);
  cursor:           pointer;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  transition:       transform .2s ease, box-shadow .2s ease;
  animation:        bot-pulse 3s infinite;
}
#dp-bot-bubble:hover {
  transform:   scale(1.08);
  box-shadow:  0 6px 28px rgba(0,0,0,.5), 0 0 0 6px rgba(200,169,107,.15);
}
/* Image robot dans la bulle */
#dp-bot-bubble .bot-robot-img {
  width:      40px;
  height:     40px;
  object-fit: contain;
  transition: opacity .2s;
  filter:     drop-shadow(0 1px 3px rgba(0,0,0,.3));
}
#dp-bot-bubble svg {
  width:  26px;
  height: 26px;
  fill:   #fff;
  transition: opacity .2s;
}
/* Cacher le robot quand ouvert, montrer X */
#dp-bot-bubble.open .bot-robot-img { display: none; }
#dp-bot-bubble:not(.open) svg.icon-close { display: none; }
#dp-bot-bubble.open svg.icon-close { display: block; }
#dp-bot-bubble.open svg.icon-chat { display: none; }
#dp-bot-bubble:not(.open) svg.icon-close { display: none; }
#dp-bot-bubble:not(.open) svg.icon-chat { display: none; }

/* Badge notification non-lus */
#dp-bot-badge {
  position:      absolute;
  top:           -4px;
  right:         -4px;
  width:         18px;
  height:        18px;
  background:    #e53e3e;
  border-radius: 50%;
  border:        2px solid var(--bot-bg);
  font-size:     .6rem;
  font-weight:   700;
  color:         #fff;
  display:       flex;
  align-items:   center;
  justify-content: center;
  display:       none;
}
#dp-bot-badge.visible { display: flex; }

@keyframes bot-pulse {
  0%,100% { box-shadow: 0 4px 20px rgba(0,0,0,.4), 0 0 0 0 rgba(200,169,107,.4); }
  50%      { box-shadow: 0 4px 20px rgba(0,0,0,.4), 0 0 0 8px rgba(200,169,107,0); }
}

/* ── Fenêtre de chat ─────────────────────────────────────────── */
#dp-bot-window {
  position:      fixed;
  bottom:        92px;
  right:         24px;
  z-index:       99998;
  width:         var(--bot-w);
  height:        var(--bot-h);
  max-height:    calc(100vh - 110px);
  background:    var(--bot-bg);
  border:        1px solid var(--bot-border);
  border-radius: var(--bot-radius);
  box-shadow:    var(--bot-shadow);
  display:       flex;
  flex-direction:column;
  overflow:      hidden;
  font-family:   'Inter', -apple-system, sans-serif;
  /* Animé */
  opacity:       0;
  transform:     translateY(16px) scale(.97);
  pointer-events:none;
  transition:    opacity .25s ease, transform .25s ease;
}
#dp-bot-window.open {
  opacity:       1;
  transform:     translateY(0) scale(1);
  pointer-events:all;
}

/* ── Header ──────────────────────────────────────────────────── */
#dp-bot-header {
  background:     linear-gradient(135deg, var(--bot-green-dark), var(--bot-green));
  padding:        14px 16px;
  display:        flex;
  align-items:    center;
  gap:            10px;
  flex-shrink:    0;
  border-bottom:  1px solid var(--bot-border);
}
.dp-bot-avatar {
  width:          36px;
  height:         36px;
  border-radius:  50%;
  background:     rgba(200,169,107,.2);
  border:         1.5px solid var(--bot-gold);
  display:        flex;
  align-items:    center;
  justify-content:center;
  font-size:      1.1rem;
  flex-shrink:    0;
}
.dp-bot-header-info { flex: 1; min-width: 0; }
.dp-bot-header-name {
  font-size:   .82rem;
  font-weight: 700;
  color:       #fff;
  line-height: 1.2;
}
.dp-bot-header-status {
  font-size:   .68rem;
  color:       rgba(255,255,255,.65);
  display:     flex;
  align-items: center;
  gap:         4px;
  margin-top:  2px;
}
.dp-bot-status-dot {
  width:         6px;
  height:        6px;
  border-radius: 50%;
  background:    #4ade80;
  animation:     status-blink 2s infinite;
}
@keyframes status-blink {
  0%,100% { opacity: 1; }
  50%     { opacity: .4; }
}
#dp-bot-close {
  background:  none;
  border:      none;
  cursor:      pointer;
  padding:     4px;
  color:       rgba(255,255,255,.7);
  border-radius: 6px;
  transition:  background .15s;
  flex-shrink: 0;
  display:     flex;
  align-items: center;
}
#dp-bot-close:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Zone messages ───────────────────────────────────────────── */
#dp-bot-messages {
  flex:           1;
  overflow-y:     auto;
  padding:        14px 14px 8px;
  display:        flex;
  flex-direction: column;
  gap:            10px;
  scroll-behavior:smooth;
}
#dp-bot-messages::-webkit-scrollbar { width: 4px; }
#dp-bot-messages::-webkit-scrollbar-track { background: transparent; }
#dp-bot-messages::-webkit-scrollbar-thumb { background: rgba(200,169,107,.45); border-radius: 2px; }

/* Bulle message */
.dp-bot-msg {
  display:        flex;
  gap:            8px;
  align-items:    flex-end;
  animation:      msg-in .2s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dp-bot-msg.user { flex-direction: row-reverse; }

.dp-bot-msg-avatar {
  width:          26px;
  height:         26px;
  border-radius:  50%;
  background:     rgba(200,169,107,.15);
  border:         1px solid var(--bot-border);
  font-size:      .75rem;
  display:        flex;
  align-items:    center;
  justify-content:center;
  flex-shrink:    0;
}
.dp-bot-msg.user .dp-bot-msg-avatar {
  background: rgba(74,124,89,.2);
  border-color: rgba(74,124,89,.4);
}

.dp-bot-msg-bubble {
  max-width:     78%;
  padding:       9px 12px;
  border-radius: 14px 14px 14px 4px;
  background:    #fff;
  border:        1px solid rgba(200,169,107,.25);
  font-size:     .8rem;
  line-height:   1.55;
  color:         var(--bot-text);
  box-shadow:    0 1px 4px rgba(0,0,0,.07);
}
.dp-bot-msg.user .dp-bot-msg-bubble {
  background:    linear-gradient(135deg, var(--bot-green-dark), #4a7c59);
  border-color:  rgba(74,124,89,.4);
  border-radius: 14px 14px 4px 14px;
  color:         #fff;
  box-shadow:    0 1px 4px rgba(0,0,0,.12);
}

/* Markdown dans les bulles */
.dp-bot-msg-bubble strong { color: #8B5E1A; font-weight: 600; }
.dp-bot-msg-bubble ul { margin: 6px 0 0 12px; padding: 0; }
.dp-bot-msg-bubble li { margin-bottom: 3px; }
.dp-bot-msg-bubble a { color: var(--bot-gold); text-decoration: underline; }
.dp-bot-msg.user .dp-bot-msg-bubble strong { color: #fff; }

/* Indicateur de frappe */
.dp-bot-typing .dp-bot-msg-bubble {
  background: #fff;
  border:     1px solid rgba(200,169,107,.25);
  padding:    10px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.dp-bot-typing-dots {
  display: flex;
  gap:     4px;
  align-items: center;
  height: 14px;
}
.dp-bot-typing-dots span {
  width:         6px;
  height:        6px;
  border-radius: 50%;
  background:    var(--bot-gold);
  opacity:       .4;
  animation:     typing-dot 1.2s infinite;
}
.dp-bot-typing-dots span:nth-child(2) { animation-delay: .2s; }
.dp-bot-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-dot {
  0%,80%,100% { opacity: .2; transform: scale(.8); }
  40%         { opacity: 1;  transform: scale(1); }
}

/* ── Chips section suggérée ──────────────────────────────────── */
.dp-bot-section-chip {
  display:       inline-flex;
  align-items:   center;
  gap:           5px;
  margin-top:    7px;
  padding:       5px 10px;
  background:    var(--bot-gold-light);
  border:        1px solid rgba(200,169,107,.35);
  border-radius: 20px;
  font-size:     .73rem;
  color:         var(--bot-gold);
  cursor:        pointer;
  font-weight:   500;
  transition:    background .15s;
  white-space:   nowrap;
}
.dp-bot-section-chip:hover { background: rgba(200,169,107,.25); }

/* ── Quick replies ───────────────────────────────────────────── */
.dp-bot-quick-replies {
  display:        flex;
  flex-wrap:      wrap;
  gap:            6px;
  padding:        0 14px 10px;
}
.dp-bot-qr {
  padding:       6px 12px;
  background:    #fff;
  border:        1px solid rgba(200,169,107,.3);
  border-radius: 20px;
  font-size:     .74rem;
  color:         var(--bot-text2);
  cursor:        pointer;
  transition:    all .15s;
  font-family:   inherit;
  white-space:   nowrap;
}
.dp-bot-qr:hover {
  background:  var(--bot-gold-light);
  border-color:var(--bot-gold);
  color:       #8B5E1A;
}

/* ── Chips de démarrage ──────────────────────────────────────── */
.dp-bot-starters {
  display:        flex;
  flex-direction: column;
  gap:            7px;
  padding:        4px 0 6px;
}
.dp-bot-starter {
  display:       flex;
  align-items:   center;
  gap:           8px;
  padding:       9px 12px;
  background:    #fff;
  border:        1px solid rgba(200,169,107,.3);
  border-radius: 10px;
  font-size:     .78rem;
  color:         var(--bot-text);
  cursor:        pointer;
  transition:    all .15s;
  font-family:   inherit;
  text-align:    left;
  box-shadow:    0 1px 3px rgba(0,0,0,.06);
}
.dp-bot-starter:hover {
  background:   var(--bot-gold-light);
  border-color: var(--bot-gold);
  color:        #8B5E1A;
}
.dp-bot-starter-icon { font-size: .95rem; flex-shrink: 0; }

/* Chip support */
.dp-bot-support-chip {
  display:       inline-flex;
  align-items:   center;
  gap:           5px;
  margin-top:    7px;
  padding:       5px 10px;
  background:    rgba(229,62,62,.1);
  border:        1px solid rgba(229,62,62,.3);
  border-radius: 20px;
  font-size:     .73rem;
  color:         #fc8181;
  text-decoration:none;
  font-weight:   500;
  transition:    background .15s;
}
.dp-bot-support-chip:hover { background: rgba(229,62,62,.18); }

/* ── Quota bar ───────────────────────────────────────────────── */
#dp-bot-quota {
  padding:     5px 14px;
  font-size:   .65rem;
  color:       var(--bot-text2);
  display:     flex;
  align-items: center;
  gap:         6px;
  flex-shrink: 0;
  border-top:  1px solid rgba(200,169,107,.2);
  background:  var(--bot-bg2);
}
.dp-bot-quota-bar {
  flex:          1;
  height:        3px;
  background:    rgba(255,255,255,.08);
  border-radius: 2px;
  overflow:      hidden;
}
.dp-bot-quota-fill {
  height:        100%;
  background:    var(--bot-gold);
  border-radius: 2px;
  transition:    width .4s ease;
}

/* ── Zone de saisie ──────────────────────────────────────────── */
#dp-bot-input-area {
  padding:       10px 12px;
  border-top:    1px solid rgba(255,255,255,.06);
  display:       flex;
  gap:           8px;
  align-items:   flex-end;
  flex-shrink:   0;
  background:    var(--bot-bg2);
}
#dp-bot-input {
  flex:          1;
  background:    #fff;
  border:        1px solid rgba(200,169,107,.35);
  border-radius: 12px;
  padding:       9px 12px;
  font-size:     .8rem;
  font-family:   inherit;
  color:         var(--bot-text);
  resize:        none;
  min-height:    38px;
  max-height:    100px;
  line-height:   1.4;
  outline:       none;
  transition:    border-color .2s;
  box-shadow:    inset 0 1px 3px rgba(0,0,0,.05);
}
#dp-bot-input::placeholder { color: rgba(44,36,22,.4); }
#dp-bot-input:focus { border-color: var(--bot-gold); box-shadow: 0 0 0 3px rgba(200,169,107,.12); }

#dp-bot-send {
  width:          36px;
  height:         36px;
  background:     linear-gradient(135deg, var(--bot-green-dark), var(--bot-green));
  border:         1px solid rgba(74,124,89,.4);
  border-radius:  10px;
  cursor:         pointer;
  display:        flex;
  align-items:    center;
  justify-content:center;
  flex-shrink:    0;
  transition:     all .15s;
  color:          #fff;
}
#dp-bot-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #3d6b52, #5a9c70);
  transform:  scale(1.05);
}
#dp-bot-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
#dp-bot-send svg { width: 16px; height: 16px; fill: #fff; }

/* ── Responsive mobile ───────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --bot-w: calc(100vw - 20px);
    --bot-h: calc(100vh - 110px);
  }
  #dp-bot-window {
    bottom:      90px;
    right:       10px;
    left:        10px;
    width:       auto;
  }
  #dp-bot-bubble {
    bottom: 16px;
    right:  16px;
  }
}
