/* ============================================================
   IgoTech — Chatbot Widget CSS
   ============================================================ */

:root {
  --cb-primary:   #053067;
  --cb-accent:    #e63946;
  --cb-white:     #ffffff;
  --cb-light:     #f0f4ff;
  --cb-gray:      #f4f6fb;
  --cb-border:    #e2e8f0;
  --cb-text:      #1a2c4e;
  --cb-muted:     #6c7a91;
  --cb-shadow:    0 8px 32px rgba(5,48,103,.22);
  --cb-radius:    16px;
  --cb-width:     370px;
  --cb-height:    520px;
}

/* ─── BOUTON FLOTTANT ────────────────────────────────────────── */
.chatbot-trigger {
  position: fixed;
  bottom: 88px;
  right: 22px;
  z-index: 8000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--cb-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(5,48,103,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .25s ease, background .25s ease, box-shadow .25s ease;
  outline: none;
}
.chatbot-trigger:hover {
  background: #0a2559;
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(5,48,103,.55);
}
.chatbot-trigger.open {
  background: var(--cb-accent);
}
.chatbot-trigger svg,
.chatbot-trigger i {
  font-size: 1.5rem;
  transition: transform .3s ease, opacity .25s ease;
}
.chatbot-trigger .icon-chat   { position: absolute; }
.chatbot-trigger .icon-close  { position: absolute; opacity: 0; transform: rotate(-90deg); }
.chatbot-trigger.open .icon-chat  { opacity: 0; transform: rotate(90deg); }
.chatbot-trigger.open .icon-close { opacity: 1; transform: rotate(0); }

/* Badge non-lus */
.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--cb-accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: badgePulse 1.8s ease infinite;
}
@keyframes badgePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(230,57,70,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(230,57,70,0); }
}

/* ─── FENÊTRE CHAT ───────────────────────────────────────────── */
.chatbot-window {
  position: fixed;
  bottom: 160px;
  right: 22px;
  z-index: 7999;
  width: var(--cb-width);
  max-height: var(--cb-height);
  background: var(--cb-white);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1),
              opacity .25s ease,
              visibility .25s ease;
}
.chatbot-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* ─── HEADER ─────────────────────────────────────────────────── */
.cb-header {
  background: linear-gradient(135deg, var(--cb-primary) 0%, #0d4fa0 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
.cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  overflow: hidden;
  flex-shrink: 0;
}
.cb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cb-header-info { flex: 1; }
.cb-header-name {
  color: #fff;
  font-weight: 700;
  font-size: .96rem;
  font-family: var(--font-head, 'Montserrat', sans-serif);
}
.cb-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,.8);
  font-size: .75rem;
  margin-top: 1px;
}
.cb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: statusPulse 2s ease infinite;
}
@keyframes statusPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}
.cb-header-actions {
  display: flex;
  gap: 6px;
}
.cb-header-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  transition: background .2s;
}
.cb-header-btn:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ─── CORPS MESSAGES ─────────────────────────────────────────── */
.cb-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--cb-gray);
}
.cb-body::-webkit-scrollbar { width: 4px; }
.cb-body::-webkit-scrollbar-track { background: transparent; }
.cb-body::-webkit-scrollbar-thumb { background: var(--cb-border); border-radius: 4px; }

/* ─── MESSAGES ───────────────────────────────────────────────── */
.cb-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: msgIn .3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-msg.bot  { flex-direction: row; }
.cb-msg.user { flex-direction: row-reverse; }

.cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cb-primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.cb-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.cb-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .875rem;
  line-height: 1.55;
  word-break: break-word;
}
.cb-msg.bot .cb-bubble {
  background: var(--cb-white);
  color: var(--cb-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.cb-msg.user .cb-bubble {
  background: var(--cb-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Markdown léger dans les bulles bot */
.cb-bubble strong { font-weight: 700; }
.cb-bubble em     { font-style: italic; }
.cb-bubble a      { color: var(--cb-primary); text-decoration: underline; font-weight: 600; }
.cb-msg.user .cb-bubble a { color: rgba(255,255,255,.9); }
.cb-bubble br     { content: ''; display: block; margin: 3px 0; }

/* Timestamp */
.cb-msg-time {
  font-size: .65rem;
  color: var(--cb-muted);
  margin-top: 3px;
  text-align: center;
  align-self: flex-end;
  padding: 0 4px;
  white-space: nowrap;
}

/* ─── INDICATEUR DE FRAPPE ───────────────────────────────────── */
.cb-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.cb-typing-dots {
  background: var(--cb-white);
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex;
  gap: 4px;
  align-items: center;
}
.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-muted);
  animation: dotBounce 1.2s ease infinite;
}
.cb-dot:nth-child(2) { animation-delay: .15s; }
.cb-dot:nth-child(3) { animation-delay: .3s; }
@keyframes dotBounce {
  0%,60%,100% { transform: translateY(0); }
  30%         { transform: translateY(-6px); background: var(--cb-primary); }
}

/* ─── QUICK REPLIES ──────────────────────────────────────────── */
.cb-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
  background: var(--cb-gray);
}
.cb-qr-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--cb-primary);
  background: transparent;
  color: var(--cb-primary);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
  white-space: nowrap;
  font-family: inherit;
}
.cb-qr-btn:hover {
  background: var(--cb-primary);
  color: #fff;
}

/* ─── INPUT ZONE ─────────────────────────────────────────────── */
.cb-footer {
  padding: 12px 14px;
  background: var(--cb-white);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}
.cb-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--cb-gray);
  border: 1.5px solid var(--cb-border);
  border-radius: 24px;
  padding: 6px 8px 6px 14px;
  transition: border-color .2s;
}
.cb-input-wrap:focus-within {
  border-color: var(--cb-primary);
  box-shadow: 0 0 0 3px rgba(5,48,103,.08);
}
.cb-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: .875rem;
  color: var(--cb-text);
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.5;
  font-family: inherit;
  padding: 3px 0;
}
.cb-input::placeholder { color: var(--cb-muted); }
.cb-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cb-primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  transition: background .2s, transform .15s;
  flex-shrink: 0;
}
.cb-send-btn:hover { background: #0a2559; transform: scale(1.05); }
.cb-send-btn:disabled { background: var(--cb-border); cursor: not-allowed; transform: none; }

.cb-footer-note {
  text-align: center;
  font-size: .65rem;
  color: var(--cb-muted);
  margin-top: 6px;
}

/* ─── MESSAGE DE NOTIFICATION (popup avant ouverture) ────────── */
.chatbot-notification {
  position: fixed;
  bottom: 160px;
  right: 90px;
  z-index: 7998;
  background: var(--cb-white);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--cb-shadow);
  max-width: 230px;
  font-size: .84rem;
  color: var(--cb-text);
  line-height: 1.5;
  animation: notifIn .4s ease;
  cursor: pointer;
}
.chatbot-notification::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--cb-white);
}
.chatbot-notification .notif-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--cb-muted);
  cursor: pointer;
  font-size: .8rem;
  padding: 2px;
}
@keyframes notifIn {
  from { opacity: 0; transform: translateY(10px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 80px;
    max-height: 75vh;
    border-radius: 12px;
  }
  .chatbot-trigger { bottom: 18px; right: 16px; }
  .chatbot-notification { display: none; }
}
