/* MUST Chatbot — Widget flottant */

/* ── FAB Button ── */
.must-chatbot-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary, #8B5CF6), var(--primary-dark, #7C3AED));
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
  font-size: 0;
}

.must-chatbot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(139, 92, 246, 0.5);
}

.must-chatbot-fab svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.must-chatbot-fab--active svg.icon-chat { display: none; }
.must-chatbot-fab:not(.must-chatbot-fab--active) svg.icon-close { display: none; }
.must-chatbot-fab--active { background: linear-gradient(135deg, #dc2626, #b91c1c); }

/* Notification badge */
.must-chatbot-fab__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: var(--secondary, #34D399);
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #0f0a1a;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s, transform 0.3s;
}

.must-chatbot-fab__badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* ── Chat Window ── */
.must-chatbot {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  width: 400px;
  max-width: calc(100vw - 2rem);
  height: 560px;
  max-height: calc(100vh - 8rem);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(15, 10, 26, 0.25);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.must-chatbot.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
.must-chatbot__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--primary, #8B5CF6), var(--primary-dark, #7C3AED));
  color: #fff;
  flex-shrink: 0;
}

.must-chatbot__avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.must-chatbot__header-info { flex: 1; }

.must-chatbot__header-name {
  font-size: 0.9375rem;
  font-weight: 600;
}

.must-chatbot__header-status {
  font-size: 0.75rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.must-chatbot__header-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary, #34D399);
  display: inline-block;
}

.must-chatbot__close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s;
}

.must-chatbot__close:hover { background: rgba(255, 255, 255, 0.25); }

/* ── Messages ── */
.must-chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #f8f6fc;
  scroll-behavior: smooth;
}

.must-chatbot__messages::-webkit-scrollbar { width: 4px; }
.must-chatbot__messages::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.2);
  border-radius: 4px;
}

.must-chatbot-msg {
  display: flex;
  gap: 0.5rem;
  max-width: 88%;
  animation: msgIn 0.3s ease;
}

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

.must-chatbot-msg--bot { align-self: flex-start; }
.must-chatbot-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.must-chatbot-msg__avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.must-chatbot-msg--bot .must-chatbot-msg__avatar {
  background: linear-gradient(135deg, var(--primary, #8B5CF6), var(--primary-dark, #7C3AED));
  color: #fff;
}

.must-chatbot-msg--user .must-chatbot-msg__avatar {
  background: var(--secondary, #34D399);
  color: #0f0a1a;
}

.must-chatbot-msg__bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #1a1a2e;
  word-break: break-word;
}

.must-chatbot-msg--bot .must-chatbot-msg__bubble {
  background: #fff;
  border: 1px solid #e8e2f4;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 8px rgba(15, 10, 26, 0.04);
}

.must-chatbot-msg--user .must-chatbot-msg__bubble {
  background: linear-gradient(135deg, var(--primary, #8B5CF6), var(--primary-dark, #7C3AED));
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.must-chatbot-msg__bubble p { margin: 0 0 0.5rem; }
.must-chatbot-msg__bubble p:last-child { margin-bottom: 0; }
.must-chatbot-msg__bubble strong { color: inherit; }
.must-chatbot-msg__bubble ul, .must-chatbot-msg__bubble ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}
.must-chatbot-msg__bubble li { margin-bottom: 0.25rem; }

.must-chatbot-msg__bubble a {
  color: var(--primary, #7c3aed);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.must-chatbot-msg--user .must-chatbot-msg__bubble a { color: #c4b5fd; }

/* Sources */
.must-chatbot-sources {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f0ecf7;
  font-size: 0.75rem;
  color: #6b7280;
}

.must-chatbot-sources__title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--primary, #7c3aed);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.must-chatbot-sources__link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--primary, #7c3aed);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  background: rgba(124, 58, 237, 0.06);
  border-radius: 6px;
  margin: 0.15rem 0.25rem 0.15rem 0;
  transition: background 0.2s;
}

.must-chatbot-sources__link:hover { background: rgba(124, 58, 237, 0.12); }

/* Typing indicator */
.must-chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
  align-items: center;
}

.must-chatbot-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary, #7c3aed);
  opacity: 0.4;
  animation: typing 1.2s infinite ease-in-out;
}

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

@keyframes typing {
  0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.15); }
}

/* ── Suggestions ── */
.must-chatbot__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 1rem 0.5rem;
  background: #f8f6fc;
}

.must-chatbot__suggestion {
  padding: 0.4rem 0.75rem;
  background: #fff;
  border: 1px solid #e8e2f4;
  border-radius: 100px;
  font-size: 0.75rem;
  color: var(--primary, #7c3aed);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.must-chatbot__suggestion:hover {
  background: var(--primary, #7c3aed);
  color: #fff;
  border-color: var(--primary, #7c3aed);
}

/* ── Input ── */
.must-chatbot__input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-top: 1px solid #f0ecf7;
  flex-shrink: 0;
}

.must-chatbot__input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1px solid #e8e2f4;
  border-radius: 12px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  color: #1a1a2e;
  background: #f8f6fc;
  transition: border-color 0.2s, background 0.2s;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
}

.must-chatbot__input:focus {
  border-color: var(--primary, #7c3aed);
  background: #fff;
}

.must-chatbot__input::placeholder { color: #9ca3af; }

.must-chatbot__send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary, #8B5CF6), var(--primary-dark, #7C3AED));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.must-chatbot__send:hover { transform: scale(1.05); }

.must-chatbot__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.must-chatbot__send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.must-chatbot__footer-note {
  text-align: center;
  padding: 0.35rem 1rem 0.5rem;
  font-size: 0.65rem;
  color: #9ca3af;
  background: #fff;
}

/* ── Welcome Message ── */
.must-chatbot-welcome {
  text-align: center;
  padding: 1.5rem 1rem;
}

.must-chatbot-welcome__icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

.must-chatbot-welcome__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 0.35rem;
}

.must-chatbot-welcome__subtitle {
  font-size: 0.8125rem;
  color: #6b7280;
  line-height: 1.5;
}

/* ── Blocs de code (assistant pédagogique par cours) ── */
.must-chatbot-msg__bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.85em;
}
.must-chatbot-code {
  background: #1e1e2e;
  color: #e2e2e2;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 0.82rem;
  line-height: 1.5;
}
.must-chatbot-code code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .must-chatbot {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .must-chatbot-fab {
    bottom: 1rem;
    right: 1rem;
  }
}