/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --cc-primary: #2563eb;
  --cc-primary-dark: #1d4ed8;
  --cc-bg: #ffffff;
  --cc-surface: #f8fafc;
  --cc-border: #e2e8f0;
  --cc-text: #1e293b;
  --cc-text-muted: #64748b;
  --cc-user-bg: var(--cc-primary);
  --cc-user-text: #ffffff;
  --cc-bot-bg: #f1f5f9;
  --cc-bot-text: #1e293b;
  --cc-shadow: 0 20px 60px rgba(0,0,0,.15), 0 4px 16px rgba(0,0,0,.08);
  --cc-radius: 20px;
  --cc-z: 99999;
  --cc-w: 380px;
  --cc-h: 540px;
}

/* ── Conteneur widget ──────────────────────────────────────────────────── */
#cc-widget {
  position: fixed;
  z-index: var(--cc-z);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

#cc-widget.cc-bottom-right {
  bottom: 24px;
  right: 24px;
}

#cc-widget.cc-bottom-left {
  bottom: 24px;
  left: 24px;
}

/* ── Bouton toggle ─────────────────────────────────────────────────────── */
.cc-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cc-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 20px rgba(0,0,0,.2), 0 0 0 0 rgba(var(--cc-primary), .4);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
  position: relative;
  outline: none;
}

.cc-toggle-btn:hover {
  background: var(--cc-primary-dark);
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}

.cc-toggle-btn:active {
  transform: scale(.96);
}

/* Pulse animation */
.cc-toggle-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--cc-primary);
  opacity: 0;
  animation: cc-pulse 2.5s ease-out infinite;
}

@keyframes cc-pulse {
  0%   { transform: scale(1); opacity: .4; }
  70%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Badge notification */
.cc-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ── Boîte de chat ─────────────────────────────────────────────────────── */
.cc-box {
  position: absolute;
  bottom: 76px;
  width: var(--cc-w);
  height: var(--cc-h);
  background: var(--cc-bg);
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.92) translateY(16px);
  opacity: 0;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
  pointer-events: none;
}

#cc-widget.cc-bottom-right .cc-box { right: 0; }
#cc-widget.cc-bottom-left  .cc-box { left: 0; }

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

.cc-hidden { display: none !important; }

/* ── Header ────────────────────────────────────────────────────────────── */
.cc-header {
  padding: 16px 20px;
  background: var(--cc-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cc-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.cc-avatar svg { width: 22px; height: 22px; }

.cc-title {
  font-weight: 700;
  font-size: 16px;
}

.cc-status {
  font-size: 12px;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.cc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: cc-blink 2s ease-in-out infinite;
}

@keyframes cc-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.cc-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.8);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}

.cc-close-btn:hover {
  color: white;
  background: rgba(255,255,255,.15);
}

/* ── Zone messages ─────────────────────────────────────────────────────── */
.cc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--cc-surface);
  scroll-behavior: smooth;
}

.cc-messages::-webkit-scrollbar { width: 4px; }
.cc-messages::-webkit-scrollbar-thumb { background: var(--cc-border); border-radius: 2px; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.cc-msg {
  display: flex;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease;
}

.cc-msg.cc-msg-in {
  opacity: 1;
  transform: translateY(0);
}

.cc-msg-user  { justify-content: flex-end; }
.cc-msg-assistant { justify-content: flex-start; }

.cc-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
}

.cc-msg-user .cc-bubble {
  background: var(--cc-user-bg);
  color: var(--cc-user-text);
  border-bottom-right-radius: 4px;
}

.cc-msg-assistant .cc-bubble {
  background: var(--cc-bot-bg);
  color: var(--cc-bot-text);
  border-bottom-left-radius: 4px;
}

/* Markdown dans les bulles */
.cc-bubble strong { font-weight: 600; }
.cc-bubble em { font-style: italic; }
.cc-bubble code {
  background: rgba(0,0,0,.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 13px;
}
.cc-bubble ul {
  margin: 6px 0 0 16px;
  padding: 0;
  list-style: disc;
}
.cc-bubble li { margin-bottom: 3px; }

/* ── Indicateur de frappe ──────────────────────────────────────────────── */
.cc-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.cc-typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cc-text-muted);
  animation: cc-bounce 1.2s ease-in-out infinite;
}

.cc-typing-bubble span:nth-child(1) { animation-delay: 0s; }
.cc-typing-bubble span:nth-child(2) { animation-delay: .2s; }
.cc-typing-bubble span:nth-child(3) { animation-delay: .4s; }

@keyframes cc-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Zone de saisie ────────────────────────────────────────────────────── */
.cc-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--cc-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--cc-bg);
  flex-shrink: 0;
}

#cc-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--cc-border);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--cc-text);
  background: var(--cc-surface);
  outline: none;
  transition: border-color .2s;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
}

#cc-input:focus {
  border-color: var(--cc-primary);
  background: white;
}

#cc-input:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.cc-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--cc-primary);
  border: none;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
  outline: none;
}

.cc-send-btn:hover {
  background: var(--cc-primary-dark);
  transform: scale(1.06);
}

.cc-send-btn:active { transform: scale(.94); }
.cc-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Questions rapides ──────────────────────────────────────────────────── */
.cc-quick-questions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 4px 0 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}

.cc-quick-questions.cc-quick-in {
  opacity: 1;
  transform: translateY(0);
}

.cc-quick-questions.cc-quick-out {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .2s ease, transform .2s ease;
}

.cc-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  background: var(--cc-bg);
  border: 1.5px solid var(--cc-primary);
  color: var(--cc-primary);
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s, color .18s, transform .12s;
  text-align: left;
  line-height: 1.3;
}

.cc-quick-btn::before {
  content: '→';
  font-size: 12px;
  opacity: .7;
  flex-shrink: 0;
}

.cc-quick-btn:hover {
  background: var(--cc-primary);
  color: #fff;
  transform: translateX(3px);
}

.cc-quick-btn:active {
  transform: scale(.97);
}

/* ── Responsive mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --cc-w: calc(100vw - 20px);
    --cc-h: calc(100vh - 120px);
  }

  #cc-widget.cc-bottom-right,
  #cc-widget.cc-bottom-left {
    bottom: 16px;
    right: 10px;
    left: 10px;
  }

  #cc-widget.cc-bottom-right .cc-box,
  #cc-widget.cc-bottom-left .cc-box {
    right: 0;
    left: 0;
  }
}
