/* ============================================================
   MIKSO — Chatbot Mascotte
   Widget flottant glassmorphism midnight indigo
   ============================================================ */

/* ---------- Variables locales ---------- */
:root {
  --cb-bg:    rgba(8, 13, 42, 0.97);
  --cb-glass: rgba(48, 42, 108, 0.55);
  --cb-border: rgba(91, 143, 255, 0.18);
  --cb-cyan:  #4DD9F0;
  --cb-blue:  #5B8FFF;
  --cb-w100:  #ffffff;
  --cb-w60:   rgba(255,255,255,.60);
  --cb-w40:   rgba(255,255,255,.40);
  --cb-r: 18px;
}

/* ---------- Bouton flottant ---------- */
#chatbot-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 8000;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  background: transparent;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  filter: drop-shadow(0 0 18px rgba(77,217,240,.45));
}

#chatbot-trigger:hover {
  transform: scale(1.10) rotate(-4deg);
  filter: drop-shadow(0 0 28px rgba(77,217,240,.70));
}

#chatbot-trigger img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Bulle de notification */
#chatbot-trigger .cb-notif {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cb-cyan);
  border: 2.5px solid #060A1E;
  animation: cb-ping 2s ease-in-out infinite;
}

@keyframes cb-ping {
  0%, 100% { box-shadow: 0 0 0 0 rgba(77,217,240,.6); }
  50%       { box-shadow: 0 0 0 7px rgba(77,217,240,0); }
}

/* ---------- Fenêtre chatbot ---------- */
#chatbot-window {
  position: fixed;
  bottom: 112px;
  right: 28px;
  z-index: 8001;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 130px);
  border-radius: var(--cb-r);
  background: var(--cb-bg);
  border: 1px solid var(--cb-border);
  box-shadow:
    0 24px 80px rgba(0,0,0,.65),
    0 0 0 1px rgba(77,217,240,.06),
    inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(.95);
  pointer-events: none;
  transition:
    opacity .3s cubic-bezier(.4,0,.2,1),
    transform .3s cubic-bezier(.34,1.56,.64,1);
}

#chatbot-window.cb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Glow streak bas */
#chatbot-window::after {
  content: '';
  position: absolute;
  bottom: 0; left: 8%; right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(70,150,255,.7), transparent);
  box-shadow: 0 0 12px rgba(77,217,240,.25);
}

/* ---------- Header ---------- */
.cb-header {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--cb-border);
  background: rgba(13,21,64,.7);
  flex-shrink: 0;
}

.cb-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(91,143,255,.12);
  border: 2px solid rgba(77,217,240,.3);
  flex-shrink: 0;
}

.cb-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
}

.cb-header-info { flex: 1; }

.cb-header-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--cb-w100);
  letter-spacing: .01em;
}

.cb-header-status {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .72rem;
  color: var(--cb-w60);
  margin-top: .15rem;
}

.cb-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: cb-ping 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

.cb-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cb-w40);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background .2s, color .2s;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.cb-close:hover {
  background: rgba(255,255,255,.06);
  color: var(--cb-w100);
}

/* ---------- Messages ---------- */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.1rem 0;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar { width: 3px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb { background: rgba(77,217,240,.2); border-radius: 3px; }

/* Message générique */
.cb-msg {
  display: flex;
  gap: .6rem;
  align-items: flex-end;
  animation: cb-msg-in .3s ease both;
}

@keyframes cb-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bot (gauche) */
.cb-msg.cb-bot .cb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(91,143,255,.15);
  border: 1.5px solid rgba(77,217,240,.25);
  flex-shrink: 0;
  overflow: hidden;
}

.cb-msg.cb-bot .cb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 1px;
}

.cb-msg.cb-bot .cb-bubble {
  background: var(--cb-glass);
  border: 1px solid var(--cb-border);
  color: var(--cb-w100);
  border-radius: 16px 16px 16px 4px;
  max-width: 82%;
}

/* User (droite) */
.cb-msg.cb-user {
  flex-direction: row-reverse;
}

.cb-msg.cb-user .cb-bubble {
  background: linear-gradient(135deg, rgba(77,217,240,.18), rgba(91,143,255,.22));
  border: 1px solid rgba(77,217,240,.25);
  color: var(--cb-w100);
  border-radius: 16px 16px 4px 16px;
  max-width: 82%;
}

.cb-bubble {
  padding: .65rem .9rem;
  font-size: .84rem;
  line-height: 1.55;
}

.cb-bubble a {
  color: var(--cb-cyan);
  text-decoration: none;
}

.cb-bubble a:hover { text-decoration: underline; }

/* Typing indicator */
.cb-typing {
  display: flex;
  gap: .3rem;
  padding: .75rem .9rem;
  align-items: center;
}

.cb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(77,217,240,.6);
  animation: cb-type-bounce .9s ease-in-out infinite both;
}

.cb-typing span:nth-child(2) { animation-delay: .15s; }
.cb-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes cb-type-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Quick replies ---------- */
.cb-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  padding: .75rem 1.1rem .25rem;
  flex-shrink: 0;
}

.cb-qr {
  background: rgba(91,143,255,.12);
  border: 1px solid rgba(91,143,255,.3);
  color: rgba(255,255,255,.82);
  font-size: .76rem;
  padding: .4rem .75rem;
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .15s;
  font-family: inherit;
  line-height: 1.3;
}

.cb-qr:hover {
  background: rgba(77,217,240,.18);
  border-color: rgba(77,217,240,.5);
  color: #fff;
  transform: translateY(-1px);
}

/* ---------- Input ---------- */
.cb-input-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem 1rem;
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
  margin-top: .5rem;
}

.cb-input {
  flex: 1;
  background: rgba(48,42,108,.35);
  border: 1px solid rgba(91,143,255,.22);
  border-radius: 12px;
  color: #fff;
  font-size: .84rem;
  padding: .6rem .85rem;
  outline: none;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
}

.cb-input::placeholder { color: rgba(255,255,255,.35); }

.cb-input:focus {
  border-color: rgba(77,217,240,.45);
  box-shadow: 0 0 0 3px rgba(77,217,240,.08);
}

.cb-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cb-cyan), var(--cb-blue));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .2s, transform .15s;
  box-shadow: 0 2px 12px rgba(77,217,240,.3);
}

.cb-send:hover { opacity: .88; transform: scale(1.06); }
.cb-send:active { transform: scale(.95); }

.cb-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* ---------- Responsive mobile ---------- */
@media (max-width: 480px) {
  #chatbot-trigger {
    bottom: 20px;
    right: 16px;
    width: 62px;
    height: 62px;
  }

  #chatbot-window {
    bottom: 98px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
}
