/* ═══════════════════════════════════════════════════════════════
   Aide MC2 Chatbot – Styles isolés
   Toutes les règles préfixées #amc2-chatbot-root
   pour ne pas affecter le reste du site.
═══════════════════════════════════════════════════════════════ */

#amc2-chatbot-root {
  --amc2-accent:    #e63312;
  --amc2-accent-dk: #b82a0e;
  --amc2-shadow:    0 8px 32px rgba(0,0,0,.18);
  --amc2-font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: var(--amc2-font);
  font-size: 15px;
  line-height: 1.5;
  box-sizing: border-box;
}

/* Reset ciblé uniquement sur les enfants du chatbot */
#amc2-chatbot-root *,
#amc2-chatbot-root *::before,
#amc2-chatbot-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  color: inherit;
  line-height: inherit;
}

/* ── Bulle ───────────────────────────────────────────────── */
#amc2-chatbot-root #amc2-bubble {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--amc2-accent);
  box-shadow: var(--amc2-shadow);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, background .2s;
  border: none; outline: none;
  margin-left: auto;
  position: relative;
}
#amc2-chatbot-root #amc2-bubble:hover         { background: var(--amc2-accent-dk); transform: scale(1.08); }
#amc2-chatbot-root #amc2-bubble svg           { width: 26px; height: 26px; fill: #fff; display: block; }
#amc2-chatbot-root #amc2-bubble.open svg.icon-chat  { display: none; }
#amc2-chatbot-root #amc2-bubble.open svg.icon-close { display: block; }
#amc2-chatbot-root #amc2-bubble      svg.icon-close { display: none; }

#amc2-chatbot-root #amc2-badge {
  position: absolute; top: 0; right: 0;
  width: 18px; height: 18px;
  background: #fff; color: var(--amc2-accent);
  border-radius: 50%; font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* ── Fenêtre ─────────────────────────────────────────────── */
#amc2-chatbot-root #amc2-window {
  position: absolute; bottom: 72px; right: 0;
  width: 360px; max-height: 540px;
  background: #fff; border-radius: 14px;
  box-shadow: var(--amc2-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: amc2-pop .22s ease;
}
#amc2-chatbot-root #amc2-window.hidden { display: none; }

@keyframes amc2-pop {
  from { opacity: 0; transform: scale(.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ──────────────────────────────────────────────── */
#amc2-chatbot-root #amc2-header {
  background: var(--amc2-accent); color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
#amc2-chatbot-root #amc2-header-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.15);
}
#amc2-chatbot-root #amc2-header-avatar img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top; display: block;
}
#amc2-chatbot-root #amc2-header-info { flex: 1; }
#amc2-chatbot-root #amc2-header-title {
  font-weight: 700; font-size: 15px; line-height: 1.2; color: #fff;
}
#amc2-chatbot-root #amc2-header-status {
  font-size: 12px; opacity: .85; color: #fff;
  display: flex; align-items: center; gap: 5px;
}
#amc2-chatbot-root #amc2-header-status::before {
  content: ''; display: inline-block;
  width: 7px; height: 7px;
  background: #6ef77b; border-radius: 50%; flex-shrink: 0;
}

/* Bouton langue */
#amc2-chatbot-root #amc2-lang-toggle {
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 20px; color: #fff;
  cursor: pointer; font-size: 12px; font-weight: 600;
  padding: 4px 10px; transition: background .15s;
  line-height: 1.4; white-space: nowrap;
}
#amc2-chatbot-root #amc2-lang-toggle:hover { background: rgba(255,255,255,.35); }

/* Bouton refresh */
#amc2-chatbot-root #amc2-refresh {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s; flex-shrink: 0;
}
#amc2-chatbot-root #amc2-refresh:hover    { background: rgba(255,255,255,.35); transform: rotate(30deg); }
#amc2-chatbot-root #amc2-refresh svg      { width: 15px; height: 15px; fill: none; display: block; }
#amc2-chatbot-root #amc2-refresh.spinning { animation: amc2-spin .6s ease; }

@keyframes amc2-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Messages ────────────────────────────────────────────── */
#amc2-chatbot-root #amc2-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: #f7f8fa; scroll-behavior: smooth;
}
#amc2-chatbot-root .amc2-msg {
  max-width: 82%; padding: 10px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.55; word-wrap: break-word;
  font-family: var(--amc2-font);
}
#amc2-chatbot-root .amc2-msg.bot {
  background: #fff; border: 1px solid #e8eaed;
  align-self: flex-start; border-bottom-left-radius: 4px; color: #1a1a1a;
}
#amc2-chatbot-root .amc2-msg.user {
  background: var(--amc2-accent); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
#amc2-chatbot-root .amc2-msg a            { color: var(--amc2-accent); text-decoration: underline; word-break: break-all; }
#amc2-chatbot-root .amc2-msg.user a       { color: #fff; }
#amc2-chatbot-root .amc2-msg strong       { font-weight: 700; }
#amc2-chatbot-root .amc2-msg em           { font-style: italic; }
#amc2-chatbot-root .amc2-msg p            { margin: 4px 0; }
#amc2-chatbot-root .amc2-msg h3,
#amc2-chatbot-root .amc2-msg h4           { font-size: 14px; font-weight: 700; margin: 8px 0 3px; }
#amc2-chatbot-root .amc2-msg ul,
#amc2-chatbot-root .amc2-msg ol           { margin: 6px 0 2px 18px; padding: 0; list-style: disc; }
#amc2-chatbot-root .amc2-msg li           { margin: 3px 0; display: list-item; }

/* Disclaimer */
#amc2-chatbot-root .amc2-disclaimer {
  margin-top: 8px; padding: 7px 10px;
  background: #fff8e1; border-left: 3px solid #f9a825;
  border-radius: 0 6px 6px 0;
  font-size: 12px; line-height: 1.5; color: #555;
}
#amc2-chatbot-root .amc2-disclaimer a {
  color: var(--amc2-accent); text-decoration: underline;
  font-weight: 600; white-space: nowrap; word-break: normal;
}

/* Typing dots */
#amc2-chatbot-root .amc2-typing {
  display: flex; gap: 5px; align-items: center;
  padding: 10px 13px; background: #fff; border: 1px solid #e8eaed;
  border-radius: 14px 14px 14px 4px;
  align-self: flex-start; width: fit-content;
}
#amc2-chatbot-root .amc2-typing span {
  width: 7px; height: 7px; background: #aaa; border-radius: 50%;
  display: inline-block; animation: amc2-bounce .9s infinite;
}
#amc2-chatbot-root .amc2-typing span:nth-child(2) { animation-delay: .15s; }
#amc2-chatbot-root .amc2-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes amc2-bounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: .5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Saisie ──────────────────────────────────────────────── */
#amc2-chatbot-root #amc2-input-area {
  padding: 10px 12px; background: #fff; border-top: 1px solid #e8eaed;
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0;
}
#amc2-chatbot-root #amc2-input {
  flex: 1; border: 1px solid #dde1e7; border-radius: 22px;
  padding: 9px 14px; font-size: 14px; font-family: var(--amc2-font);
  outline: none; resize: none; max-height: 100px;
  overflow-y: auto; line-height: 1.4; transition: border-color .2s;
  background: #fff; color: #1a1a1a; display: block; width: 100%;
}
#amc2-chatbot-root #amc2-input:focus { border-color: var(--amc2-accent); outline: none; }

#amc2-chatbot-root #amc2-send {
  width: 38px; height: 38px; min-width: 38px;
  border-radius: 50%; background: var(--amc2-accent);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s; flex-shrink: 0;
}
#amc2-chatbot-root #amc2-send:hover    { background: var(--amc2-accent-dk); transform: scale(1.08); }
#amc2-chatbot-root #amc2-send:disabled { background: #ccc; cursor: default; transform: none; }
#amc2-chatbot-root #amc2-send svg      { width: 17px; height: 17px; fill: #fff; display: block; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 420px) {
  #amc2-chatbot-root              { bottom: 16px; right: 16px; }
  #amc2-chatbot-root #amc2-window { width: calc(100vw - 32px); right: -16px; bottom: 68px; max-height: 72vh; }
}
