/* ===== Chatbot Cannes Driver =====
   Widget autonome (vanilla JS) : ne dépend ni de React ni du bundle dist/.
   Les variables du design system sont utilisées avec un repli en dur pour les
   pages qui ne chargent pas colors_and_type.css.
   Position : en bas à GAUCHE — le bas à droite est occupé par la pile
   WhatsApp/Appeler (desktop) et le FAB doré (mobile).
   z-index : au-dessus du site (60-70), en dessous du bandeau cookies (9999). */

/* Note : aucun <p> dans le widget, volontairement. styles.css justifie tous
   les <p> en !important sous 760 px, avec une spécificité qu'on ne peut
   surpasser sans surenchère de sélecteurs — dans une colonne aussi étroite,
   le texte s'étire en lettres espacées. Des <div> évitent le problème. */

.cdc-launcher {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 90;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1px solid var(--hairline-strong, rgba(191, 149, 63, .42));
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-800, #141414);
  color: var(--gold-400, #d4af37);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .5);
  transition: transform 220ms cubic-bezier(.22, 1, .36, 1), opacity 220ms ease, border-color 220ms ease;
}
.cdc-launcher:hover { transform: translateY(-2px); border-color: var(--gold-500, #bf953f); }
.cdc-launcher:active { transform: scale(.94); }
.cdc-launcher:focus-visible { outline: 2px solid var(--gold-400, #d4af37); outline-offset: 3px; }
.cdc-launcher svg { width: 25px; height: 25px; }
.cdc-launcher.is-hidden { opacity: 0; transform: scale(.6); pointer-events: none; }

/* Pastille « 1 » tant que la conversation n'a pas été ouverte */
.cdc-launcher .cdc-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 12px; height: 12px;
  border-radius: 999px;
  background: var(--gold-500, #bf953f);
  border: 2px solid var(--ink-900, #0a0a0a);
}
.cdc-launcher.is-seen .cdc-dot { display: none; }

/* ---------- Panneau ---------- */

.cdc-panel {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 95;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--ink-900, #0a0a0a);
  border: 1px solid var(--hairline, rgba(191, 149, 63, .18));
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6);
  opacity: 0;
  transform: translateY(14px) scale(.98);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 260ms ease, transform 260ms cubic-bezier(.22, 1, .36, 1), visibility 0s linear 260ms;
}
.cdc-panel.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition-delay: 0s;
}

.cdc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--hairline, rgba(191, 149, 63, .18));
  background: var(--ink-800, #141414);
}
.cdc-head-mark {
  width: 36px; height: 36px;
  flex: none;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold-gradient, linear-gradient(135deg, #bf953f, #fcf6ba, #b38728));
  color: var(--ink-900, #0a0a0a);
}
.cdc-head-mark svg { width: 18px; height: 18px; }
.cdc-head-txt { min-width: 0; flex: 1; }
.cdc-head-title {
  margin: 0;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--silver-100, #f5f5f5);
}
.cdc-head-sub {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--silver-400, #9a9a9a);
  display: flex; align-items: center; gap: 6px;
}
.cdc-head-sub::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 999px;
  background: #35c76a;
  flex: none;
}
.cdc-close {
  flex: none;
  width: 32px; height: 32px;
  border: 0; padding: 0;
  background: transparent;
  color: var(--silver-400, #9a9a9a);
  cursor: pointer;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 180ms ease, background 180ms ease;
}
.cdc-close:hover { color: var(--silver-100, #f5f5f5); background: rgba(255, 255, 255, .06); }
.cdc-close:focus-visible { outline: 2px solid var(--gold-400, #d4af37); outline-offset: 2px; }
.cdc-close svg { width: 15px; height: 15px; }

.cdc-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-500, #3a3a3a) transparent;
}
.cdc-log::-webkit-scrollbar { width: 6px; }
.cdc-log::-webkit-scrollbar-thumb { background: var(--ink-500, #3a3a3a); border-radius: 999px; }

.cdc-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 14px;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: cdcIn 260ms cubic-bezier(.22, 1, .36, 1) both;
}
.cdc-msg--bot {
  align-self: flex-start;
  background: var(--ink-700, #1c1c1c);
  border: 1px solid var(--hairline-cool, rgba(255, 255, 255, .08));
  border-bottom-left-radius: 5px;
  color: var(--silver-100, #f5f5f5);
}
.cdc-msg--user {
  align-self: flex-end;
  background: var(--gold-500, #bf953f);
  border-bottom-right-radius: 5px;
  color: var(--ink-900, #0a0a0a);
  font-weight: 500;
}
.cdc-msg--error {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  border: 1px dashed var(--hairline-strong, rgba(191, 149, 63, .42));
  color: var(--silver-300, #b8b8b8);
  font-size: 13px;
  text-align: center;
}

@keyframes cdcIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Indicateur de frappe */
.cdc-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 14px;
  background: var(--ink-700, #1c1c1c);
  border: 1px solid var(--hairline-cool, rgba(255, 255, 255, .08));
  border-radius: 14px;
  border-bottom-left-radius: 5px;
}
.cdc-typing span {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--silver-500, #7a7a7a);
  animation: cdcBounce 1.2s infinite ease-in-out;
}
.cdc-typing span:nth-child(2) { animation-delay: .15s; }
.cdc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cdcBounce {
  0%, 60%, 100% { transform: none; opacity: .45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* Suggestions + bouton « Réserver ce trajet » */
.cdc-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 2px; }
.cdc-chip {
  border: 1px solid var(--hairline-strong, rgba(191, 149, 63, .42));
  background: transparent;
  color: var(--gold-300, #e6c869);
  border-radius: 999px;
  padding: 8px 13px;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background 180ms ease, color 180ms ease;
}
.cdc-chip:hover { background: var(--gold-500, #bf953f); color: var(--ink-900, #0a0a0a); }
.cdc-chip:focus-visible { outline: 2px solid var(--gold-400, #d4af37); outline-offset: 2px; }

/* Raccourci vers /reservation : action, pas suggestion — d'où le plein doré. */
.cdc-chip--go {
  background: var(--gold-gradient, linear-gradient(135deg, #bf953f, #fcf6ba, #b38728));
  border-color: transparent;
  color: var(--ink-900, #0a0a0a);
  font-weight: 600;
  letter-spacing: .06em;
  text-decoration: none;
}
.cdc-chip--go:hover { color: var(--ink-900, #0a0a0a); transform: translateY(-1px); }

.cdc-book {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: -2px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--gold-gradient, linear-gradient(135deg, #bf953f, #fcf6ba, #b38728));
  color: var(--ink-900, #0a0a0a);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  animation: cdcIn 260ms cubic-bezier(.22, 1, .36, 1) both;
}
.cdc-book:hover { color: var(--ink-900, #0a0a0a); transform: translateY(-1px); }

/* ---------- Zone de saisie ---------- */

.cdc-foot {
  border-top: 1px solid var(--hairline, rgba(191, 149, 63, .18));
  background: var(--ink-800, #141414);
  padding: 10px 12px 12px;
}
.cdc-form { display: flex; align-items: flex-end; gap: 8px; }
.cdc-input {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  resize: none;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--hairline-cool, rgba(255, 255, 255, .08));
  background: var(--ink-700, #1c1c1c);
  color: var(--silver-100, #f5f5f5);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.45;
}
.cdc-input::placeholder { color: var(--silver-500, #7a7a7a); }
.cdc-input:focus { outline: none; border-color: var(--gold-500, #bf953f); }

.cdc-send {
  flex: none;
  width: 42px; height: 42px;
  border: 0; padding: 0;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold-gradient, linear-gradient(135deg, #bf953f, #fcf6ba, #b38728));
  color: var(--ink-900, #0a0a0a);
  transition: opacity 180ms ease, transform 180ms ease;
}
.cdc-send:hover:not(:disabled) { transform: translateY(-1px); }
.cdc-send:disabled { opacity: .38; cursor: default; }
.cdc-send:focus-visible { outline: 2px solid var(--gold-400, #d4af37); outline-offset: 2px; }
.cdc-send svg { width: 17px; height: 17px; }

.cdc-note {
  margin: 9px 2px 0;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--silver-500, #7a7a7a);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cdc-note a {
  flex: none;
  white-space: nowrap;
  color: var(--silver-400, #9a9a9a);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cdc-note a:hover { color: var(--gold-400, #d4af37); }

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
  .cdc-launcher { bottom: 20px; left: 18px; width: 54px; height: 54px; }
  .cdc-panel {
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: 0;
    transform: translateY(22px);
  }
  .cdc-msg { max-width: 92%; }
  /* iOS : évite le zoom automatique à la mise au point du champ */
  .cdc-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .cdc-launcher, .cdc-panel, .cdc-send, .cdc-book { transition-duration: 1ms; }
  .cdc-msg, .cdc-book { animation: none; }
  .cdc-typing span { animation-duration: 2.4s; }
}
