/* ===============================
   IMPORT FONT
================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ===============================
   RESET ANTI-CONFLIT
================================ */
#askbot-button,
#askbot-box {
  all: unset;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  box-sizing: border-box;
}

/* ===============================
   VARIABLES
================================ */
:root {
  --askbot-primary:    #2563eb;
  --askbot-bot-bubble: #2563eb;
  --askbot-user-bubble:#f0f0f0;
  --askbot-radius:     24px;
  --askbot-shadow:     0 32px 80px rgba(0,0,0,0.22), 0 8px 24px rgba(0,0,0,0.10);
}

/* ===============================
   BOUTON FLOTTANT
================================ */
#askbot-button {
  position: fixed !important;
  bottom: 24px;
  right: 24px !important;
  left: auto !important;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--askbot-primary);
  cursor: pointer;
  z-index: 2147483647;
  display: flex !important;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(37,99,235,0.45), 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s ease;
  animation: askbotFloat 3s ease-in-out infinite;
}

#askbot-button::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--askbot-primary);
  opacity: 0.2;
  animation: askbotRipple 3s ease-in-out infinite;
  z-index: -1;
}

#askbot-button:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 40px rgba(37,99,235,0.55), 0 4px 12px rgba(0,0,0,0.2);
  animation: none;
}

#askbot-button:hover::before {
  animation: none;
  opacity: 0;
}

#askbot-button img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}

@keyframes askbotFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

@keyframes askbotRipple {
  0%, 100% { transform: scale(1);    opacity: 0.2; }
  50%       { transform: scale(1.15); opacity: 0.08; }
}

/* ===============================
   FENÊTRE CHAT — ANIMATION OUVERTURE
================================ */
#askbot-box {
  position: fixed !important;
  bottom: 100px;
  right: 24px !important;
  left: auto !important;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: var(--askbot-radius);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483646;
  box-shadow: var(--askbot-shadow);
  transform-origin: bottom right;
  animation: askbotOpen 0.35s cubic-bezier(.34,1.56,.64,1) forwards;
}

@keyframes askbotOpen {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ===============================
   HEADER GRADIENT
================================ */
#askbot-header {
  background: linear-gradient(135deg, var(--askbot-primary) 0%, color-mix(in srgb, var(--askbot-primary) 70%, #7c3aed) 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

#askbot-header::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

#askbot-header::before {
  content: '';
  position: absolute;
  bottom: -40px;
  left: 20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}

#askbot-header img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#askbot-close-btn {
  all: unset;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 16px;
  opacity: 0.75;
  transition: background 0.2s, opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}

#askbot-close-btn:hover {
  background: rgba(255,255,255,0.18);
  opacity: 1;
  transform: rotate(90deg);
}

/* Indicateur statut en ligne */
.askbot-status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
  animation: askbotStatusPulse 2s ease-in-out infinite;
}

@keyframes askbotStatusPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(74,222,128,0.3); }
  50%       { box-shadow: 0 0 0 4px rgba(74,222,128,0.15); }
}

/* ===============================
   ZONE MESSAGES
================================ */
#askbot-messages {
  flex: 1;
  padding: 16px 14px;
  overflow-y: auto;
  background: #f8f9fc;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#askbot-messages::-webkit-scrollbar { width: 3px; }
#askbot-messages::-webkit-scrollbar-track { background: transparent; }
#askbot-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

/* ===============================
   MESSAGES
================================ */
.askbot-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 4px;
  animation: askbotMsgIn 0.25s cubic-bezier(.34,1.56,.64,1) forwards;
  opacity: 0;
}

@keyframes askbotMsgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

.askbot-msg.user { justify-content: flex-end; }
.askbot-msg.user img { order: 2; }

.askbot-msg img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.askbot-msg.bot img {
  width: 34px;
  height: 34px;
}

/* ===============================
   BULLES
================================ */
.askbot-bubble {
  max-width: 75%;
  padding: 11px 15px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  position: relative;
}

.askbot-msg.bot .askbot-bubble {
  background: var(--askbot-bot-bubble);
  color: #fff;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 4px 16px rgba(37,99,235,0.25);
}

.askbot-msg.user .askbot-bubble {
  background: var(--askbot-user-bubble);
  color: #1f2937;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.06);
}

.askbot-bubble a {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}

/* Timestamp optionnel */
.askbot-bubble::after {
  content: attr(data-time);
  display: block;
  font-size: 10px;
  opacity: 0.5;
  margin-top: 4px;
  text-align: right;
}

/* ===============================
   TYPING INDICATOR
================================ */
.askbot-typing .askbot-bubble {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.askbot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  animation: askbotTyping 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

.askbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.askbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes askbotTyping {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ===============================
   INPUT ZONE
================================ */
#askbot-input {
  display: flex;
  align-items: center;
  border-top: 1px solid rgba(0,0,0,0.06);
  background: #fff;
  flex-shrink: 0;
  padding: 8px 10px;
  gap: 6px;
}

#askbot-input input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  background: #f9fafb;
  outline: none;
  color: #1f2937;
  border-radius: 20px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#askbot-input input:focus {
  border-color: var(--askbot-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

#askbot-input input::placeholder { color: #9ca3af; }

/* Bouton micro — caché par défaut, affiché uniquement par JS si navigateur supporté */
#askbot-input button#askbot-mic-btn {
  display: none;
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

#askbot-input button#askbot-mic-btn:hover {
  color: var(--askbot-primary);
  background: rgba(37,99,235,0.08);
}

#askbot-input button#askbot-mic-btn.listening {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
  animation: askbotMicPulse 1s ease-in-out infinite;
}

@keyframes askbotMicPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

#askbot-mic-btn.hidden { display: none; }

/* Bouton envoyer */
#askbot-input button:not(#askbot-mic-btn) {
  background: var(--askbot-primary);
  color: #fff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.35);
  font-weight: 700;
  font-family: inherit;
  font-size: 13px;
  padding: 0 14px;
  width: auto;
  border-radius: 20px;
  height: 36px;
}

#askbot-input button:not(#askbot-mic-btn):hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 6px 16px rgba(37,99,235,0.45);
}

#askbot-input button:not(#askbot-mic-btn):active {
  transform: scale(0.97);
}

#askbot-input button:not(#askbot-mic-btn):disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===============================
   BRANDING
================================ */
#askbot-branding {
  text-align: center;
  font-size: 10.5px;
  color: #9ca3af;
  padding: 5px 8px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.04);
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

#askbot-branding a {
  color: var(--askbot-primary);
  text-decoration: none;
  font-weight: 600;
}

/* ===============================
   SUGGESTIONS RAPIDES
================================ */
#askbot-suggestions {
  padding: 2px 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#askbot-suggestions button {
  background: #fff;
  border: 1.5px solid var(--askbot-primary);
  color: var(--askbot-primary);
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(37,99,235,0.1);
}

#askbot-suggestions button:hover {
  background: var(--askbot-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

/* ===============================
   LEAD FORM
================================ */
.askbot-lead-form {
  background: linear-gradient(135deg, #f8f9fc 0%, #eff6ff 100%);
  border-radius: 16px;
  padding: 16px;
  margin: 4px 0 8px;
  border: 1px solid rgba(37,99,235,0.1);
  animation: askbotMsgIn 0.3s cubic-bezier(.34,1.56,.64,1) forwards;
}

.askbot-lead-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  color: #1f2937;
}

.askbot-lead-form input:focus {
  border-color: var(--askbot-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.askbot-lead-form button {
  background: linear-gradient(135deg, var(--askbot-primary), color-mix(in srgb, var(--askbot-primary) 70%, #7c3aed));
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.askbot-lead-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37,99,235,0.4);
}

/* ===============================
   RESPONSIVE
================================ */
@media (max-width: 480px) {
  #askbot-box {
    width: calc(100vw - 16px) !important;
    right: 8px !important;
    left: 8px !important;
    bottom: 84px !important;
    height: 65vh !important;
    max-height: 480px !important;
    border-radius: 20px;
  }

  #askbot-button {
    bottom: 16px !important;
    right: 16px !important;
    width: 54px;
    height: 54px;
  }

  #askbot-button img {
    width: 50px;
    height: 50px;
  }

  .askbot-bubble {
    max-width: 82%;
    font-size: 13px;
  }

  #askbot-input {
    padding: 6px 6px;
  }

  #askbot-input input {
    font-size: 13px;
    padding: 9px 10px;
  }

  #askbot-input button:not(#askbot-mic-btn) {
    padding: 0 12px;
    font-size: 12px;
  }
}
