/* ───────────────────────────────────────────────────────────────────
 * C-redit Chatbot — widget styles
 * Charte : navy #14264a, accent #3dcc5b, font Inter
 * Tout est préfixé .ccb- pour éviter toute collision GP / thème
 * ─────────────────────────────────────────────────────────────────── */

.ccb-launcher,
.ccb-panel,
.ccb-panel * {
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Launcher style Messenger — gros bouton chat avec halo pulse */
.ccb-launcher {
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #14264a 0%, #1e3666 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(20, 38, 74, 0.35), 0 0 0 0 rgba(201, 162, 76, 0.5);
  border: none;
  z-index: 999998;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: ccb-pulse 2.4s ease-out infinite;
}
@keyframes ccb-pulse {
  0%   { box-shadow: 0 6px 20px rgba(20, 38, 74, 0.35), 0 0 0 0 rgba(201, 162, 76, 0.55); }
  70%  { box-shadow: 0 6px 20px rgba(20, 38, 74, 0.35), 0 0 0 18px rgba(201, 162, 76, 0); }
  100% { box-shadow: 0 6px 20px rgba(20, 38, 74, 0.35), 0 0 0 0 rgba(201, 162, 76, 0); }
}
.ccb-launcher:hover {
  transform: scale(1.08);
  animation: none;
  box-shadow: 0 10px 28px rgba(20, 38, 74, 0.45);
}
.ccb-launcher:focus-visible {
  outline: 3px solid #c9a24c;
  outline-offset: 3px;
}
/* Bulle de chat via SVG inline data-uri — pixel-perfect, immunisé contre les overrides du thème */
.ccb-launcher-icon {
  width: 36px;
  height: 36px;
  display: block;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 36'%3E%3Cpath fill='%23fff' d='M4 0h32a4 4 0 0 1 4 4v20a4 4 0 0 1-4 4H14l-8 8v-8H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z'/%3E%3Ccircle cx='12' cy='14' r='2.2' fill='%2314264a'/%3E%3Ccircle cx='20' cy='14' r='2.2' fill='%2314264a'/%3E%3Ccircle cx='28' cy='14' r='2.2' fill='%2314264a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}
.ccb-launcher[aria-expanded="true"] {
  transform: scale(0);
  pointer-events: none;
  animation: none;
}

/* Panel */
.ccb-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 580px;
  max-height: calc(100vh - 40px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(20, 38, 74, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ccb-panel.ccb-open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* Header */
.ccb-header {
  background: #14264a;
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ccb-header-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.ccb-header-sub {
  font-size: 11px;
  opacity: 0.7;
  font-weight: 400;
}
.ccb-close {
  background: #fff;
  border: none;
  color: #14264a;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 1;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.ccb-close:hover {
  background: #c9a24c;
  color: #fff;
  transform: rotate(90deg);
  box-shadow: 0 4px 12px rgba(201,162,76,0.4);
}
/* Croix : caractère unicode, plus de SVG */
.ccb-close {
  font-size: 22px !important;
  font-weight: 400;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  padding: 0;
}

/* Messages */
.ccb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f6f8fb;
}
.ccb-messages::-webkit-scrollbar { width: 6px; }
.ccb-messages::-webkit-scrollbar-thumb { background: #c9d1dd; border-radius: 3px; }

/* Bubbles */
.ccb-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ccb-bubble strong { font-weight: 600; }
.ccb-bubble em { font-style: italic; }
.ccb-bubble ul { margin: 6px 0; padding-left: 18px; }
.ccb-bubble li { margin: 2px 0; }
.ccb-bubble p { margin: 6px 0; }
.ccb-bubble p:first-child { margin-top: 0; }
.ccb-bubble p:last-child { margin-bottom: 0; }

.ccb-bubble-bot {
  background: #fff;
  color: #14264a;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(20, 38, 74, 0.06);
}
.ccb-bubble-user {
  background: #14264a;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ccb-bubble-system {
  background: #fef3c7;
  color: #78350f;
  align-self: stretch;
  font-size: 12px;
  border-radius: 8px;
  text-align: center;
}
.ccb-bubble-error {
  background: #fee2e2;
  color: #991b1b;
  align-self: stretch;
  font-size: 13px;
  border-radius: 8px;
}

/* CTA inside bot bubble — aligné sur le doré du site */
.ccb-cta {
  display: inline-block;
  margin-top: 10px;
  padding: 10px 16px;
  background: #c9a24c;
  color: #14264a !important;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none !important;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(201, 162, 76, 0.25);
}
.ccb-cta:hover {
  background: #b28a36;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(201, 162, 76, 0.35);
}

/* Sources */
.ccb-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e4e9f1;
  font-size: 11px;
  color: #5e6e84;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ccb-sources-label { font-weight: 500; }
.ccb-source-link {
  color: #14264a;
  text-decoration: underline;
  text-decoration-color: #c9d1dd;
}
.ccb-source-link:hover { text-decoration-color: #3dcc5b; }

/* Chips de suggestions cliquables (quick replies) */
.ccb-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  align-self: stretch;
}
.ccb-chip {
  background: #fff;
  border: 1.5px solid #c9a24c;
  color: #14264a;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s, transform 0.1s, box-shadow 0.2s;
  font-family: inherit;
  line-height: 1.35;
  box-shadow: 0 1px 2px rgba(20, 38, 74, 0.06);
}
.ccb-chip:hover {
  background: #c9a24c;
  color: #14264a;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(201, 162, 76, 0.3);
}
.ccb-chip:focus-visible {
  outline: 2px solid #c9a24c;
  outline-offset: 2px;
}

/* Loading dots */
.ccb-typing {
  align-self: flex-start;
  background: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: inline-flex;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(20, 38, 74, 0.06);
}
.ccb-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #14264a;
  opacity: 0.4;
  animation: ccb-bounce 1.4s ease-in-out infinite;
}
.ccb-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ccb-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes ccb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Lien mentions légales en footer du panneau */
.ccb-footer-legal {
  background: #fff;
  padding: 6px 12px 10px;
  text-align: center;
  border-top: 1px solid #f0f3f7;
  flex-shrink: 0;
}
.ccb-footer-legal a {
  font-size: 11px;
  color: #8597a8;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.ccb-footer-legal a:hover { color: #14264a; text-decoration: underline; }

/* Input footer */
.ccb-input-wrap {
  border-top: 1px solid #e4e9f1;
  padding: 12px;
  background: #fff;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.ccb-input {
  flex: 1;
  border: 1px solid #c9d1dd;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.4;
}
.ccb-input:focus { border-color: #14264a; }
/* Bouton envoyer : texte "Envoyer" (plus fiable que SVG) */
.ccb-send {
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  background: #c9a24c;
  color: #fff !important;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(201, 162, 76, 0.4);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.01em;
}
.ccb-send:hover:not(:disabled) {
  background: #b28a36;
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(201, 162, 76, 0.5);
}
.ccb-send:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* Tooltip "Une question ?" — attire l'œil au repos */
.ccb-tooltip {
  position: fixed;
  right: 90px;
  bottom: 110px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 38px 12px 18px;
  box-shadow: 0 8px 24px rgba(20, 38, 74, 0.18);
  font-size: 14px;
  color: #14264a;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 999997;
  max-width: 240px;
}
.ccb-tooltip.ccb-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.ccb-tooltip::after {
  content: '';
  position: absolute;
  right: -7px;
  bottom: 18px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #fff;
  filter: drop-shadow(2px 0 2px rgba(20, 38, 74, 0.06));
}
.ccb-tooltip-close {
  position: absolute;
  right: 8px;
  top: 8px;
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: #8597a8;
  cursor: pointer;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.ccb-tooltip-close:hover { background: #f0f3f7; color: #14264a; }

/* Mobile */
@media (max-width: 480px) {
  /* sticky bar mobile "Simuler / Planifier" fait ~75px de haut → on cale au-dessus */
  .ccb-launcher { right: 16px; bottom: 90px; width: 52px; height: 52px; }
  .ccb-tooltip { display: none; } /* pas de tooltip en mobile (place limitée) */
  .ccb-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}

/* Réduit le mouvement pour les utilisateurs concernés */
@media (prefers-reduced-motion: reduce) {
  .ccb-launcher, .ccb-panel, .ccb-cta, .ccb-typing-dot { transition: none; animation: none; }
}
