/* ============================================================
   Widget chat IA — CSS partagé (classique + modules)
   Utilise les mêmes variables CSS que les autres feuilles :
   --c-coral, --c-teal-dark, --c-cream, --c-cream-2, --c-yellow-soft,
   --c-ink, --c-ink-soft, --font-title, --font-body.
   ============================================================ */

#cm2-chat-root { font-family: var(--font-body); }

#cm2-chat-toggle {
  position: fixed;
  bottom: 90px; right: 24px;
  z-index: 9995;
  background: linear-gradient(135deg, var(--c-coral), #ff8a8a);
  color: #fff;
  border: 3px solid #fff;
  border-radius: 50px;
  padding: 12px 20px;
  font-family: var(--font-title);
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 107, 107, .4);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform .2s, box-shadow .2s;
  animation: cm2-chat-bob 3s ease-in-out infinite;
}
#cm2-chat-toggle:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 30px rgba(255, 107, 107, .55);
}
@keyframes cm2-chat-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

.cm2-chat-emoji { font-size: 1.4rem; }

#cm2-chat-panel {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9996;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(30, 75, 95, .3);
  border: 4px solid var(--c-coral);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cm2-chat-in .25s ease;
}
#cm2-chat-panel.hidden { display: none; }

@keyframes cm2-chat-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cm2-chat-head {
  background: var(--c-teal-dark);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cm2-chat-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-title);
}
.cm2-chat-head-title > span:first-child { font-size: 1.8rem; }
.cm2-chat-head-title strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
}
.cm2-chat-head-title small {
  display: block;
  font-size: .75rem;
  opacity: .8;
  font-weight: 600;
}
#cm2-chat-close {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
#cm2-chat-close:hover { background: rgba(255,255,255,.28); }

.cm2-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--c-cream);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cm2-msg { display: flex; max-width: 85%; }
.cm2-msg-user      { align-self: flex-end; }
.cm2-msg-assistant { align-self: flex-start; }

.cm2-msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: .92rem;
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
.cm2-msg-user .cm2-msg-bubble {
  background: var(--c-coral);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.cm2-msg-assistant .cm2-msg-bubble {
  background: #fff;
  color: var(--c-ink);
  border: 2px solid var(--c-yellow-soft);
  border-bottom-left-radius: 6px;
}

.cm2-thinking {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
}
.cm2-thinking span {
  width: 8px; height: 8px;
  background: var(--c-ink-soft);
  border-radius: 50%;
  animation: cm2-pulse 1.2s ease-in-out infinite;
}
.cm2-thinking span:nth-child(2) { animation-delay: .2s; }
.cm2-thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes cm2-pulse {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%            { transform: scale(1);  opacity: 1; }
}

.cm2-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 2px solid var(--c-cream-2);
}
#cm2-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--c-cream-2);
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: .95rem;
  outline: none;
}
#cm2-chat-input:focus { border-color: var(--c-coral); }

#cm2-chat-send {
  background: var(--c-coral);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
}
#cm2-chat-send:hover { background: var(--c-teal-dark); }

.cm2-chat-footer {
  font-size: .72rem;
  color: var(--c-ink-soft);
  text-align: center;
  padding: 6px 10px;
  background: #fff;
  margin: 0;
  border-top: 1px solid var(--c-cream-2);
}

@media (max-width: 420px) {
  #cm2-chat-toggle .cm2-chat-toggle-label { display: none; }
  #cm2-chat-toggle { padding: 12px; }
  #cm2-chat-panel { width: calc(100vw - 16px); right: 8px; bottom: 16px; }
}

@media print {
  #cm2-chat-root { display: none !important; }
}
