/* Widget de chat du centre de formation — styles isolés (préfixe cc-) */
.cc-root {
  --cc-color: #0d4f8b;
  --cc-bg: #ffffff;
  --cc-surface: #f3f5f8;
  --cc-text: #1b2430;
  --cc-muted: #5d6876;
  --cc-border: #dfe4ea;
  position: fixed;
  bottom: 20px;
  z-index: 2147483000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--cc-text);
}
.cc-root *, .cc-root *::before, .cc-root *::after { box-sizing: border-box; }
.cc-right { right: 20px; }
.cc-left { left: 20px; }

/* Bouton flottant */
.cc-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--cc-color);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease;
  margin-left: auto;
}
.cc-left .cc-launcher { margin-left: 0; }
.cc-launcher:hover { transform: scale(1.06); }
.cc-launcher:focus-visible { outline: 3px solid #ffb020; outline-offset: 3px; }
.cc-launcher svg { width: 28px; height: 28px; }
.cc-ico-close { display: none; }
.cc-open .cc-ico-open { display: none; }
.cc-open .cc-ico-close { display: block; }

/* Fenêtre */
.cc-panel {
  position: absolute;
  bottom: 76px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--cc-bg);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cc-panel[hidden] { display: none; }
.cc-right .cc-panel { right: 0; }
.cc-left .cc-panel { left: 0; }

.cc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 14px 16px;
  background: var(--cc-color);
  color: #fff;
}
.cc-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  flex: none;
}
.cc-avatar svg { width: 24px; height: 24px; }
.cc-titles { flex: 1; min-width: 0; }
.cc-title { font-weight: 650; font-size: 16px; }
.cc-subtitle { font-size: 12.5px; opacity: 0.85; }
.cc-icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.cc-icon-btn:hover { background: rgba(255, 255, 255, 0.15); }
.cc-icon-btn svg { width: 20px; height: 20px; }

/* Messages */
.cc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  background: var(--cc-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cc-row { display: flex; }
.cc-user { justify-content: flex-end; }
.cc-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cc-assistant .cc-bubble {
  background: var(--cc-bg);
  border: 1px solid var(--cc-border);
  border-bottom-left-radius: 4px;
}
.cc-user .cc-bubble {
  background: var(--cc-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cc-para + .cc-para { margin-top: 0.7em; }
.cc-bubble a { color: inherit; text-decoration: underline; }
.cc-error .cc-bubble { border-color: #f1b8b4; background: #fdf1f0; color: #8c1d18; }

.cc-typing { display: inline-flex; gap: 4px; align-items: center; padding: 13px 14px; }
.cc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cc-muted);
  opacity: 0.5;
  animation: cc-blink 1.2s infinite ease-in-out;
}
.cc-typing span:nth-child(2) { animation-delay: 0.2s; }
.cc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cc-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Suggestions */
.cc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 14px 10px;
  background: var(--cc-surface);
}
.cc-chips[hidden] { display: none; }
.cc-chip {
  border: 1px solid var(--cc-color);
  color: var(--cc-color);
  background: var(--cc-bg);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.cc-chip:hover { background: var(--cc-color); color: #fff; }

/* Zone de saisie */
.cc-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 8px 14px;
  border-top: 1px solid var(--cc-border);
  background: var(--cc-bg);
}
.cc-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--cc-border);
  border-radius: 12px;
  padding: 9px 12px;
  font: inherit;
  color: var(--cc-text);
  background: var(--cc-bg);
  max-height: 120px;
  outline: none;
}
.cc-input:focus { border-color: var(--cc-color); }
.cc-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--cc-color);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.cc-send:disabled { opacity: 0.5; cursor: wait; }
.cc-send svg { width: 20px; height: 20px; }
[dir="rtl"] .cc-send svg, .cc-root[dir="rtl"] .cc-send svg { transform: scaleX(-1); }
.cc-foot {
  font-size: 11.5px;
  color: var(--cc-muted);
  text-align: center;
  padding: 0 10px 8px;
  background: var(--cc-bg);
}

/* Mobile : plein écran */
@media (max-width: 480px) {
  .cc-root { bottom: 16px; }
  .cc-right { right: 16px; }
  .cc-left { left: 16px; }
  .cc-open .cc-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  .cc-open .cc-launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-launcher, .cc-typing span { transition: none; animation: none; }
}
