/* ─── FAB ──────────────────────────────────────────────── */
.chat-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 200;
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(145deg, var(--blue) 0%, var(--navy) 100%);
  color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), opacity var(--t);
  animation: fabGlow 2.6s ease-in-out infinite;
}
.chat-fab:hover {
  transform: scale(1.09);
  box-shadow: 0 8px 30px rgba(37,99,235,.5), 0 0 26px 8px rgba(37,99,235,.45);
  animation-play-state: paused;
}
.chat-fab svg { pointer-events: none; }

/* Pulsing halo ring behind the FAB */
.chat-fab::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  z-index: -1; pointer-events: none;
  animation: fabRing 2.6s ease-out infinite;
}

@keyframes fabGlow {
  0%, 100% { box-shadow: 0 4px 18px rgba(13,36,86,.35), 0 0 12px 2px rgba(37,99,235,.35); }
  50%      { box-shadow: 0 6px 24px rgba(13,36,86,.4), 0 0 26px 7px rgba(37,99,235,.65); }
}
@keyframes fabRing {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,.45); }
  70%  { box-shadow: 0 0 0 16px rgba(37,99,235,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-fab { animation: none; }
  .chat-fab::after { animation: none; }
}

/* ─── Drawer (panneau vertical, ancré en bas à droite) ─── */
.chat-drawer {
  position: fixed; bottom: 28px; right: 28px; z-index: 210;
  width: 384px; max-width: calc(100vw - 40px);
  height: 600px; max-height: calc(100vh - 120px);
  background: var(--surface); border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(13,36,86,.22), 0 8px 24px rgba(0,0,0,.1);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: bottom right;
  transform: translateY(18px) scale(.96);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.2,.64,1), opacity .25s ease, visibility .3s;
}
.chat-drawer.is-open {
  transform: translateY(0) scale(1);
  opacity: 1; visibility: visible; pointer-events: auto;
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--emerald); flex-shrink: 0;
  animation: dpulse 2s ease-in-out infinite;
}
.chat-title { font-size: .9375rem; font-weight: 600; color: var(--navy); }
.chat-subtitle { font-size: .75rem; color: var(--muted); margin-top: 1px; }
.chat-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: background var(--t), color var(--t);
}
.chat-close:hover { background: var(--border); color: var(--text); }

/* ─── Messages ─────────────────────────────────────────── */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.chat-welcome {
  background: var(--blue-50); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: .875rem; color: var(--text-mid); line-height: 1.55;
}

.chat-msg { display: flex; gap: 8px; }
.chat-msg--user { flex-direction: row-reverse; }
.chat-msg--assistant { flex-direction: row; }

.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.chat-msg--user .msg-avatar    { background: var(--navy); color: #fff; }
.chat-msg--assistant .msg-avatar { background: var(--blue-100); color: var(--blue); }

.msg-bubble {
  max-width: 82%; padding: 10px 14px;
  border-radius: 14px; font-size: .9rem; line-height: 1.6;
}
.chat-msg--user .msg-bubble {
  background: var(--navy); color: #fff;
  border-radius: 14px 4px 14px 14px;
}
.chat-msg--assistant .msg-bubble {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
}

/* Markdown inside assistant bubbles */
.msg-bubble p { margin-bottom: .5em; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { color: var(--navy); }
.msg-bubble em { font-style: italic; }
.msg-bubble ul, .msg-bubble ol { padding-left: 1.25em; margin: .4em 0; }
.msg-bubble li { margin-bottom: .2em; }

/* Typing indicator */
.typing-dots {
  display: inline-flex; gap: 4px; align-items: center; height: 16px;
}
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted-light); display: block;
  animation: tdot .9s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes tdot { 0%,100% { opacity:.3; transform: scale(.8); } 50% { opacity:1; transform: scale(1); } }

/* ─── Input ────────────────────────────────────────────── */
.chat-input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}
.chat-input {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: var(--bg); font-family: inherit; font-size: .9375rem;
  color: var(--text); outline: none;
  transition: border-color var(--t);
  resize: none;
}
.chat-input:focus { border-color: var(--blue); }
.chat-input::placeholder { color: var(--muted-light); }
.chat-send {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--navy); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; align-self: flex-end;
  transition: background var(--t), transform var(--t);
}
.chat-send:hover:not(:disabled) { background: var(--blue); }
.chat-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 600px) {
  .chat-fab { bottom: 20px; right: 20px; }
  .chat-drawer {
    bottom: 16px; right: 12px; left: 12px;
    width: auto; max-width: none;
    height: calc(100vh - 90px);
  }
}
