:root {
  --sm-navy: #10192f;
  --sm-navy-light: #1c2947;
  --sm-teal: #14b8a6;
  --sm-teal-dark: #0d9488;
  --sm-bg: #f6f7fb;
  --sm-bubble-bot: #ffffff;
  --sm-bubble-user: var(--sm-navy);
  --sm-text: #1a1f2e;
  --sm-text-muted: #6b7280;
  --sm-border: #e5e7eb;
  --sm-font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --sm-font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --sm-radius: 16px;
  --sm-shadow: 0 12px 32px -8px rgba(16, 25, 47, 0.28);
}

#sm-chat-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: var(--sm-font-body);
  --sm-launcher-size: 60px;
}

/* ---------- Bouton flottant ---------- */
.sm-launcher {
  width: var(--sm-launcher-size);
  height: var(--sm-launcher-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sm-teal), var(--sm-teal-dark));
  border: none;
  cursor: pointer;
  box-shadow: var(--sm-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.sm-launcher:hover {
  transform: scale(1.06);
}
.sm-launcher:focus-visible {
  outline: 3px solid var(--sm-navy-light);
  outline-offset: 2px;
}
.sm-launcher svg {
  width: 26px;
  height: 26px;
  stroke: white;
}

/* ---------- Fenêtre de chat ---------- */
.sm-window {
  position: absolute;
  bottom: calc(var(--sm-launcher-size) + 16px);
  right: 0;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 540px;
  max-height: calc(100vh - 140px);
  background: var(--sm-bg);
  border-radius: var(--sm-radius);
  box-shadow: var(--sm-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.sm-window.sm-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sm-header {
  background: var(--sm-navy);
  background-image: radial-gradient(circle at 100% 0%, var(--sm-navy-light), var(--sm-navy) 60%);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sm-header-title {
  font-family: var(--sm-font-display);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sm-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sm-teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.25);
}
.sm-header-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}
.sm-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
}
.sm-close:hover {
  color: white;
}

.sm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sm-msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sm-msg-bot {
  align-self: flex-start;
  background: var(--sm-bubble-bot);
  border: 1px solid var(--sm-border);
  color: var(--sm-text);
  border-bottom-left-radius: 4px;
}
.sm-msg-user {
  align-self: flex-end;
  background: var(--sm-bubble-user);
  color: white;
  border-bottom-right-radius: 4px;
}

.sm-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--sm-bubble-bot);
  border: 1px solid var(--sm-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.sm-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sm-text-muted);
  animation: sm-bounce 1.1s infinite ease-in-out;
}
.sm-typing span:nth-child(2) { animation-delay: 0.15s; }
.sm-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sm-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sm-typing span { animation: none; }
}

.sm-input-row {
  border-top: 1px solid var(--sm-border);
  background: white;
  padding: 10px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.sm-input {
  flex: 1;
  border: 1px solid var(--sm-border);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: var(--sm-font-body);
  resize: none;
  outline: none;
  color: var(--sm-text);
}
.sm-input:focus {
  border-color: var(--sm-teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}
.sm-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--sm-navy);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.sm-send:hover {
  background: var(--sm-navy-light);
}
.sm-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.sm-send svg {
  width: 16px;
  height: 16px;
  stroke: white;
}

@media (max-width: 480px) {
  #sm-chat-root {
    bottom: 12px;
    right: 12px;
  }
  .sm-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
  }
}
