/* =====================================================================
   Chatbot — assistant éducatif sur la caution de loyer suisse
   Tous les sélecteurs préfixés .cls-bot pour éviter les collisions avec
   styles.css / tailwind.css.
   ===================================================================== */

.cls-bot,
.cls-bot * {
  box-sizing: border-box;
}

/* ---------- Floating launcher ---------- */
.cls-bot__fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--primary, #b91c1c);
  color: #fff;
  font: 600 14px/1 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(185, 28, 28, 0.35), 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.cls-bot__fab:hover {
  background: #991b1b;
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(185, 28, 28, 0.45);
}
.cls-bot__fab:focus-visible {
  outline: 3px solid #fca5a5;
  outline-offset: 3px;
}
.cls-bot__fab-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cls-bot__fab-icon svg { width: 18px; height: 18px; }

.cls-bot[data-open="true"] .cls-bot__fab {
  transform: scale(0.9);
  opacity: 0;
  pointer-events: none;
}

/* ---------- Panel ---------- */
.cls-bot__panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: 460px;
  max-width: calc(100vw - 24px);
  height: 720px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22), 0 6px 16px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  font: 400 14px/1.5 'Inter', system-ui, sans-serif;
  color: #0f172a;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.cls-bot[data-open="true"] .cls-bot__panel {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Header ---------- */
.cls-bot__header {
  flex: 0 0 auto;
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cls-bot__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
}
.cls-bot__title {
  flex: 1;
  min-width: 0;
}
.cls-bot__title strong {
  display: block;
  font: 700 14px/1.2 'Plus Jakarta Sans', sans-serif;
  letter-spacing: -0.01em;
}
.cls-bot__title small {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  opacity: 0.9;
  margin-top: 2px;
}
.cls-bot__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}
.cls-bot__close {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.cls-bot__close:hover { background: rgba(255, 255, 255, 0.22); }
.cls-bot__close svg { width: 16px; height: 16px; }

/* ---------- Messages ---------- */
.cls-bot__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px;
  background: #f8fafc;
  scroll-behavior: smooth;
}
.cls-bot__messages::-webkit-scrollbar { width: 6px; }
.cls-bot__messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.cls-bot__msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 16px;
  animation: cls-bot-in 0.25s ease;
}
.cls-bot__msg--user { justify-content: flex-end; }
.cls-bot__msg--assistant { justify-content: flex-start; }

.cls-bot__msg-avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary, #b91c1c);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 10.5px/1 'Plus Jakarta Sans', sans-serif;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.25);
}

.cls-bot__bubble {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}
.cls-bot__msg--user .cls-bot__bubble {
  background: var(--primary, #b91c1c);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.cls-bot__msg--assistant .cls-bot__bubble {
  background: #fff;
  color: #0f172a;
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.04);
}
.cls-bot__bubble p,
.cls-bot__bubble li,
.cls-bot__bubble strong,
.cls-bot__bubble em,
.cls-bot__bubble h2,
.cls-bot__bubble h3 { color: inherit; }
.cls-bot__bubble p { margin: 0 0 8px; }
.cls-bot__bubble p:last-child { margin: 0; }
.cls-bot__bubble ul, .cls-bot__bubble ol { margin: 6px 0 8px 18px; padding: 0; }
.cls-bot__bubble li { margin-bottom: 3px; }
.cls-bot__bubble strong { font-weight: 700; }
.cls-bot__bubble a {
  color: var(--primary, #b91c1c);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: #fca5a5;
  text-underline-offset: 2px;
}
.cls-bot__bubble a:hover { text-decoration-color: var(--primary, #b91c1c); }
.cls-bot__msg--user .cls-bot__bubble a {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.6);
}
.cls-bot__bubble code {
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}
.cls-bot__bubble h2, .cls-bot__bubble h3 {
  font: 700 14px/1.3 'Plus Jakarta Sans', sans-serif;
  margin: 8px 0 6px;
}

/* Tables — wrapped pour overflow horizontal sur mobile */
.cls-bot__table-wrap {
  margin: 8px -4px;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.cls-bot__bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.4;
  background: #fff;
}
.cls-bot__bubble th,
.cls-bot__bubble td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eef2f7;
  color: #0f172a;
  white-space: nowrap;
}
.cls-bot__bubble th {
  background: #f8fafc;
  font: 600 12px/1.3 'Plus Jakarta Sans', sans-serif;
  color: #334155;
  letter-spacing: 0.01em;
}
.cls-bot__bubble tbody tr:last-child td { border-bottom: 0; }
.cls-bot__bubble td:first-child { font-weight: 600; }
.cls-bot__msg--user .cls-bot__table-wrap {
  border-color: rgba(255, 255, 255, 0.25);
}
.cls-bot__msg--user .cls-bot__bubble table { background: rgba(255, 255, 255, 0.08); }
.cls-bot__msg--user .cls-bot__bubble th {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.cls-bot__msg--user .cls-bot__bubble td { color: #fff; border-color: rgba(255, 255, 255, 0.15); }

/* ---------- Typing indicator ---------- */
.cls-bot__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}
.cls-bot__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: cls-bot-bounce 1.2s infinite;
}
.cls-bot__typing span:nth-child(2) { animation-delay: 0.15s; }
.cls-bot__typing span:nth-child(3) { animation-delay: 0.3s; }

/* ---------- Quick prompts ---------- */
.cls-bot__quick {
  padding: 0 16px 8px;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  background: #f8fafc;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  -webkit-overflow-scrolling: touch;
}
.cls-bot__quick::-webkit-scrollbar { height: 4px; }
.cls-bot__quick::-webkit-scrollbar-track { background: transparent; }
.cls-bot__quick::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.cls-bot__quick-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 7px 12px;
  font: 500 12.5px/1 'Inter', sans-serif;
  color: var(--primary, #b91c1c);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cls-bot__quick-btn:hover {
  background: var(--primary-50, #fef2f2);
  border-color: #fca5a5;
}

/* ---------- Composer ---------- */
.cls-bot__composer {
  flex: 0 0 auto;
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}
.cls-bot__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f1f5f9;
  border-radius: 14px;
  padding: 6px 6px 6px 12px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.cls-bot__form:focus-within {
  background: #fff;
  box-shadow: 0 0 0 2px var(--primary, #b91c1c) inset;
}
.cls-bot__input {
  flex: 1;
  border: 0;
  background: transparent;
  resize: none;
  font: 400 14px/1.5 'Inter', sans-serif;
  color: #0f172a;
  outline: 0;
  min-height: 22px;
  max-height: 110px;
  padding: 8px 0;
}
.cls-bot__input::placeholder { color: #94a3b8; }
.cls-bot__send {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--primary, #b91c1c);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.cls-bot__send:hover:not(:disabled) { background: #991b1b; }
.cls-bot__send:active:not(:disabled) { transform: scale(0.95); }
.cls-bot__send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}
.cls-bot__send svg { width: 16px; height: 16px; }

.cls-bot__legal {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
  text-align: center;
  line-height: 1.4;
}
.cls-bot__legal a { color: inherit; text-decoration: underline; }

/* ---------- Animations ---------- */
@keyframes cls-bot-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cls-bot-bounce {
  0%, 60%, 100% { transform: translateY(0);  opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Mobile fullscreen ---------- */
@media (max-width: 480px) {
  .cls-bot__panel {
    right: 0;
    left: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .cls-bot__fab {
    right: 14px;
    bottom: 14px;
    padding: 12px 16px 12px 12px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .cls-bot__panel,
  .cls-bot__fab,
  .cls-bot__msg,
  .cls-bot__typing span { transition: none; animation: none; }
}
