:root {
  --jlw-bg: #ffffff;
  --jlw-border: #e5e7eb;
  --jlw-text: #111827;
  --jlw-muted: #6b7280;
  --jlw-primary: #2563eb;      /* bleu JLWeb */
  --jlw-primary-soft: #eff6ff;
  --jlw-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  --jlw-radius-lg: 18px;
  --jlw-radius-full: 999px;
}

#jlw-chatbot-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Bulle flottante */
.jlw-chat-bubble {
  width: 64px;
  height: 64px;
  border-radius: var(--jlw-radius-full);
  border: none;
  background: var(--jlw-primary);
  color: #ffffff;
  box-shadow: var(--jlw-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  position: relative;
}

.jlw-chat-bubble:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 26px 60px rgba(37, 99, 235, 0.35);
  background: #1d4ed8;
}

.jlw-chat-bubble-icon {
  font-size: 26px;
  color: #ffffff;     /* icône blanche */
  line-height: 1;
}

/* Badge notification */
.jlw-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.15);
}

/* Infobulle */
.jlw-chat-tooltip {
  position: absolute;
  right: 78px;
  bottom: 20px;
  background: var(--jlw-primary);
  color: #f9fafb;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--jlw-shadow);
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.jlw-chat-tooltip::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 14px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent var(--jlw-primary);
}

#jlw-chatbot-widget.jlw-tooltip-visible .jlw-chat-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* Fenêtre de chat */
.jlw-chat-window {
  position: absolute;
  right: 0;
  bottom: 82px;
  width: 420px;
  max-width: calc(100vw - 40px);
  /* NE PAS dépasser la fenêtre visible */
  height: min(640px, calc(100vh - 120px)); /* 120px de marge haut+bas */
  background: var(--jlw-bg);
  border-radius: 22px;
  box-shadow: var(--jlw-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
}


#jlw-chatbot-widget.jlw-open .jlw-chat-window {
  display: flex;
}

.jlw-chat-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--jlw-border);
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.jlw-chat-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--jlw-primary);
}

/* Avatar logo dans le titre */
.jlw-chat-title-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.jlw-chat-title-logo img {
  width: 68%;
  height: 68%;
  object-fit: contain;
}

.jlw-chat-subtitle {
  font-size: 12px;
  color: var(--jlw-muted);
}

.jlw-chat-badge-green {
  display: inline-block;
  background: #16a34a;        /* Vert Tailwind-like */
  color: #ffffff;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;       /* capsule */
  margin-right: 6px;
}

/* Texte à côté (optionnel) */
.jlw-chat-subtitle-text {
  font-size: 12px;
  color: var(--jlw-muted);
}

/* Ligne horizontale avec le titre + capsule verte */
.jlw-chat-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

/* Titre */
.jlw-chat-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--jlw-primary);
  display: flex; 
  align-items: center;
}

.jlw-chat-robot {
  font-size: 18px;
  line-height: 1;
}

/* Capsule verte */
.jlw-chat-badge-green {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #16a34a;
  color: #ffffff;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

/* Texte en dessous */
.jlw-chat-subtitle-text {
  margin-top: 4px;
  font-size: 12px;
  color: var(--jlw-muted);
}

.jlw-chat-close {
  border: none;
  background: transparent;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  color: var(--jlw-muted);
  padding: 6px;
  border-radius: var(--jlw-radius-full);
}

.jlw-chat-close:hover {
  background: #e5e7eb;
  color: var(--jlw-text);
}

.jlw-chat-body {
  padding: 12px 14px 8px;
  flex: 1;
  overflow-y: auto;
  background: #f9fafb;
}

.jlw-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--jlw-text);
}

.jlw-chat-message {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.jlw-chat-message-bot .jlw-chat-bubble-msg {
  background: var(--jlw-primary-soft);
  color: var(--jlw-text);
  border-radius: 14px 14px 14px 4px;
}

.jlw-chat-message-user {
  justify-content: flex-end;
}

.jlw-chat-message-user .jlw-chat-bubble-msg {
  background: var(--jlw-primary);
  color: #ffffff;
  border-radius: 14px 14px 4px 14px;
}

.jlw-chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--jlw-radius-full);
  background: var(--jlw-primary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.jlw-chat-bubble-msg {
  padding: 9px 12px;
  max-width: 82%;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.jlw-chat-bubble-msg ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.jlw-chat-bubble-msg li {
  margin-bottom: 2px;
}

/* FAQ rapide */
.jlw-chat-quickfaq {
  margin-top: 2px;
}

.jlw-chat-quickfaq-title {
  font-size: 12px;
  color: var(--jlw-muted);
  margin-bottom: 4px;
}

.jlw-chat-quickfaq-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.jlw-chat-quickfaq-item {
  border: 1px solid var(--jlw-border);
  background: #ffffff;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  color: var(--jlw-text);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.jlw-chat-quickfaq-item:hover {
  background: var(--jlw-primary-soft);
  border-color: #bfdbfe;
  transform: translateY(-1px);
}

/* Input & bouton envoyer */
.jlw-chat-input-area {
  display: flex;
  flex-direction: row;      /* s'assure que c'est bien en ligne */
  align-items: center;      /* aligne verticalement input + bouton */
  flex-wrap: nowrap;        /* empêche le retour à la ligne */
  padding: 10px 10px 12px;
  border-top: 1px solid var(--jlw-border);
  background: #eff1f5;
  gap: 10px;
}

.jlw-chat-input {
  flex: 1 1 auto;          /* prend tout l’espace disponible */
  min-width: 0;            /* évite les débordements */
  width: 100%;             /* force l’input à s’étirer au max */
  max-width: none;         /* retire toute limite */
  border-radius: var(--jlw-radius-full);
  border: 1px solid var(--jlw-border);
  padding: 12px 16px;      /* légèrement plus grand aussi */
  font-size: 15px;
  outline: none;
}

.jlw-chat-input:focus {
  border-color: var(--jlw-primary);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.jlw-chat-send {
  border-radius: var(--jlw-radius-full);
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  background: var(--jlw-primary);
  color: #ffffff;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.jlw-chat-send:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.jlw-chat-send:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.25);
}

.jlw-chat-send-emoji {
  display: inline-block;
  transform-origin: center;
}

.jlw-chat-send:hover .jlw-chat-send-emoji {
  transform: translateY(-1px) rotate(-4deg);
}

.jlw-chat-message-typing .jlw-chat-bubble-msg {
  font-style: italic;
  color: var(--jlw-muted);
}

/* Animation mini bounce-back */
@keyframes jlw-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.90); }
  70%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.jlw-bounce {
  animation: jlw-bounce 0.28s ease-out;
}

/* Mobile */
@media (max-width: 480px) {
  .jlw-chat-window {
    width: 100vw;
    right: 0;
    border-radius: 16px 16px 0 0;
    bottom: 0;

    /* Occupe une partie de l’écran sans dépasser */
    height: min(560px, 80vh);
  }
}
