/* Assistant contextuel — La clé de l’impossible
   Fonctionne localement, sans bibliothèque externe ni clé API. */

.site-chatbot,
.site-chatbot * {
  box-sizing: border-box;
}

.site-chatbot {
  --chatbot-gold: var(--gold-300, #f2d17e);
  --chatbot-gold-strong: var(--gold-500, #c98a2e);
  --chatbot-navy: var(--navy-950, #020b14);
  --chatbot-panel: rgba(5, 20, 34, .985);
  --chatbot-line: rgba(242, 209, 126, .24);
  --chatbot-muted: var(--muted, #b6c1cd);
  position: fixed;
  inset: auto auto 0 0;
  z-index: 1400;
  font-family: var(--sans, Inter, ui-sans-serif, system-ui, sans-serif);
}

.chatbot-launcher {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 1402;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 50%;
  color: #06121f;
  background: linear-gradient(135deg, var(--chatbot-gold), var(--chatbot-gold-strong));
  box-shadow: 0 18px 45px rgba(0, 0, 0, .44), 0 0 0 7px rgba(226, 182, 84, .09);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.chatbot-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .5), 0 0 0 9px rgba(226, 182, 84, .11);
}

.chatbot-launcher:focus-visible,
.chatbot-icon-button:focus-visible,
.chatbot-chip:focus-visible,
.chatbot-action:focus-visible,
.chatbot-input:focus-visible,
.chatbot-send:focus-visible {
  outline: 3px solid var(--chatbot-gold);
  outline-offset: 3px;
}

.chatbot-launcher svg {
  width: 29px;
  height: 29px;
}

.chatbot-launcher .chatbot-close-icon {
  display: none;
}

.site-chatbot.is-open .chatbot-launcher .chatbot-open-icon {
  display: none;
}

.site-chatbot.is-open .chatbot-launcher .chatbot-close-icon {
  display: block;
}

.chatbot-unread {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  display: none;
  place-items: center;
  padding: 0 5px;
  border: 2px solid var(--chatbot-navy);
  border-radius: 999px;
  color: #fff;
  background: #d64545;
  font-size: .68rem;
  font-weight: 900;
  line-height: 1;
}

.chatbot-unread.is-visible {
  display: grid;
}

.chatbot-teaser {
  position: fixed;
  left: 5.55rem;
  bottom: 1.08rem;
  z-index: 1401;
  width: min(290px, calc(100vw - 7rem));
  padding: .82rem 2.35rem .82rem .95rem;
  border: 1px solid var(--chatbot-line);
  border-radius: 17px;
  color: #f8f3e8;
  background: rgba(5, 20, 34, .97);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .42);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px) translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}

.chatbot-teaser.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.site-chatbot.is-open .chatbot-teaser {
  opacity: 0;
  pointer-events: none;
}

.chatbot-teaser strong {
  display: block;
  margin-bottom: .18rem;
  color: var(--chatbot-gold);
  font-family: var(--serif, Georgia, serif);
  font-size: .97rem;
}

.chatbot-teaser span {
  display: block;
  color: var(--chatbot-muted);
  font-size: .78rem;
  line-height: 1.42;
}

.chatbot-teaser-close {
  position: absolute;
  top: .45rem;
  right: .5rem;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #d9e1e9;
  background: transparent;
  cursor: pointer;
}

.chatbot-teaser-close:hover {
  color: var(--chatbot-gold);
  background: rgba(255, 255, 255, .06);
}

.chatbot-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1398;
  display: none;
  background: rgba(0, 5, 10, .58);
  backdrop-filter: blur(3px);
}

.chatbot-panel {
  position: fixed;
  left: 1rem;
  bottom: 5.8rem;
  z-index: 1400;
  width: min(400px, calc(100vw - 2rem));
  height: min(650px, calc(100vh - 7.4rem));
  min-height: 460px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(242, 209, 126, .32);
  border-radius: 25px;
  background:
    radial-gradient(circle at 90% 0, rgba(226, 182, 84, .10), transparent 16rem),
    var(--chatbot-panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .62);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(18px) scale(.97);
  transform-origin: left bottom;
  transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}

.site-chatbot.is-open .chatbot-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.chatbot-header {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .72rem;
  align-items: center;
  min-height: 78px;
  padding: .9rem .85rem;
  border-bottom: 1px solid var(--chatbot-line);
  background: linear-gradient(135deg, rgba(12, 39, 63, .98), rgba(3, 15, 27, .98));
}

.chatbot-brand-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(242, 209, 126, .36);
  border-radius: 14px;
  color: #07111d;
  background: linear-gradient(135deg, var(--chatbot-gold), var(--chatbot-gold-strong));
  box-shadow: 0 10px 24px rgba(0, 0, 0, .26);
}

.chatbot-brand-icon svg {
  width: 24px;
  height: 24px;
}

.chatbot-heading {
  min-width: 0;
}

.chatbot-heading strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-family: var(--serif, Georgia, serif);
  font-size: 1.05rem;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatbot-status {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .25rem;
  color: var(--chatbot-muted);
  font-size: .72rem;
  line-height: 1.2;
}

.chatbot-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #58c59b;
  box-shadow: 0 0 0 4px rgba(88, 197, 155, .12);
}

.chatbot-header-actions {
  display: flex;
  gap: .24rem;
}

.chatbot-icon-button {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #dbe4ec;
  background: transparent;
  cursor: pointer;
}

.chatbot-icon-button:hover {
  color: var(--chatbot-gold);
  border-color: var(--chatbot-line);
  background: rgba(255, 255, 255, .05);
}

.chatbot-icon-button svg {
  width: 18px;
  height: 18px;
}

.chatbot-context {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 38px;
  padding: .5rem .9rem;
  border-bottom: 1px solid rgba(242, 209, 126, .12);
  color: var(--chatbot-muted);
  background: rgba(226, 182, 84, .035);
  font-size: .72rem;
}

.chatbot-context span:first-child {
  color: var(--chatbot-gold);
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.chatbot-context strong {
  min-width: 0;
  overflow: hidden;
  color: #eaf0f5;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatbot-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem .88rem .75rem;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(242, 209, 126, .28) transparent;
}

.chatbot-messages::-webkit-scrollbar {
  width: 7px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(242, 209, 126, .24);
}

.chatbot-message {
  display: flex;
  gap: .48rem;
  align-items: flex-end;
  margin-bottom: .8rem;
  animation: chatbot-message-in .22s ease both;
}

.chatbot-message.is-user {
  justify-content: flex-end;
}

.chatbot-avatar {
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  border: 1px solid rgba(242, 209, 126, .24);
  border-radius: 10px;
  color: #07111d;
  background: linear-gradient(135deg, var(--chatbot-gold), var(--chatbot-gold-strong));
  font-size: .82rem;
  font-weight: 900;
}

.chatbot-bubble-wrap {
  max-width: 82%;
}

.chatbot-bubble {
  padding: .72rem .84rem;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 17px 17px 17px 5px;
  color: #eef3f7;
  background: rgba(18, 50, 78, .84);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .14);
  font-size: .88rem;
  line-height: 1.52;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.chatbot-message.is-user .chatbot-bubble {
  border-color: rgba(242, 209, 126, .23);
  border-radius: 17px 17px 5px 17px;
  color: #07111d;
  background: linear-gradient(135deg, #f3d58d, #d59b3c);
  font-weight: 650;
}

.chatbot-message-meta {
  margin-top: .23rem;
  color: #7f90a1;
  font-size: .62rem;
}

.chatbot-message.is-user .chatbot-message-meta {
  text-align: right;
}

.chatbot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .42rem;
  margin-top: .48rem;
}

.chatbot-action {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .38rem;
  padding: .46rem .67rem;
  border: 1px solid rgba(242, 209, 126, .28);
  border-radius: 999px;
  color: var(--chatbot-gold);
  background: rgba(226, 182, 84, .055);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.chatbot-action:hover {
  border-color: var(--chatbot-gold);
  background: rgba(226, 182, 84, .11);
  transform: translateY(-1px);
}

.chatbot-action.is-primary {
  border-color: transparent;
  color: #07111d;
  background: linear-gradient(135deg, var(--chatbot-gold), var(--chatbot-gold-strong));
}

.chatbot-action svg {
  width: 14px;
  height: 14px;
}

.chatbot-typing {
  display: none;
  gap: .45rem;
  align-items: flex-end;
  margin-bottom: .8rem;
}

.chatbot-typing.is-visible {
  display: flex;
}

.chatbot-typing-bubble {
  height: 39px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 .9rem;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 17px 17px 17px 5px;
  background: rgba(18, 50, 78, .84);
}

.chatbot-typing-bubble i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chatbot-gold);
  animation: chatbot-typing 1s infinite ease-in-out;
}

.chatbot-typing-bubble i:nth-child(2) { animation-delay: .13s; }
.chatbot-typing-bubble i:nth-child(3) { animation-delay: .26s; }

.chatbot-suggestions {
  flex: 0 0 auto;
  display: flex;
  gap: .45rem;
  overflow-x: auto;
  padding: .4rem .82rem .65rem;
  border-top: 1px solid rgba(242, 209, 126, .08);
  scrollbar-width: none;
}

.chatbot-suggestions::-webkit-scrollbar {
  display: none;
}

.chatbot-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: .43rem .7rem;
  border: 1px solid rgba(242, 209, 126, .25);
  border-radius: 999px;
  color: #e8edf2;
  background: rgba(255, 255, 255, .035);
  font-size: .72rem;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}

.chatbot-chip:hover {
  color: #07111d;
  border-color: transparent;
  background: var(--chatbot-gold);
}

.chatbot-composer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .55rem;
  align-items: end;
  padding: .72rem .78rem .8rem;
  border-top: 1px solid var(--chatbot-line);
  background: rgba(2, 11, 20, .88);
}

.chatbot-input {
  width: 100%;
  min-height: 44px;
  max-height: 112px;
  resize: none;
  overflow-y: auto;
  padding: .67rem .78rem;
  border: 1px solid rgba(242, 209, 126, .2);
  border-radius: 15px;
  color: #fff;
  background: rgba(255, 255, 255, .045);
  font-size: .84rem;
  line-height: 1.4;
}

.chatbot-input::placeholder {
  color: #8392a1;
}

.chatbot-input:focus {
  border-color: rgba(242, 209, 126, .6);
  background: rgba(255, 255, 255, .065);
}

.chatbot-send {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 14px;
  color: #07111d;
  background: linear-gradient(135deg, var(--chatbot-gold), var(--chatbot-gold-strong));
  cursor: pointer;
  box-shadow: 0 9px 22px rgba(201, 138, 46, .2);
  transition: transform .18s ease, opacity .18s ease;
}

.chatbot-send:hover {
  transform: translateY(-1px);
}

.chatbot-send:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none;
}

.chatbot-send svg {
  width: 20px;
  height: 20px;
}

.chatbot-privacy {
  flex: 0 0 auto;
  margin: -.35rem 0 0;
  padding: 0 .85rem .58rem;
  color: #728395;
  background: rgba(2, 11, 20, .88);
  font-size: .61rem;
  text-align: center;
}

.chatbot-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes chatbot-message-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes chatbot-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 640px) {
  body.chatbot-open {
    overflow: hidden;
  }

  .site-chatbot.is-open .chatbot-backdrop {
    display: block;
  }

  .chatbot-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(82dvh, 720px);
    min-height: 500px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 25px 25px 0 0;
    transform-origin: center bottom;
  }

  .chatbot-launcher {
    width: 56px;
    height: 56px;
  }

  .site-chatbot.is-open .chatbot-launcher {
    opacity: 0;
    pointer-events: none;
  }

  .chatbot-teaser {
    left: 4.95rem;
    bottom: .92rem;
    width: min(260px, calc(100vw - 5.8rem));
  }

  .chatbot-header {
    min-height: 72px;
    padding: .78rem .72rem;
  }

  .chatbot-context {
    padding-inline: .75rem;
  }

  .chatbot-messages {
    padding-inline: .72rem;
  }

  .chatbot-bubble-wrap {
    max-width: 86%;
  }

  .chatbot-privacy {
    padding-bottom: max(.58rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 390px) {
  .chatbot-header-actions .chatbot-reset {
    display: none;
  }

  .chatbot-teaser {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-panel,
  .chatbot-launcher,
  .chatbot-teaser,
  .chatbot-message,
  .chatbot-action,
  .chatbot-send {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .site-chatbot {
    display: none !important;
  }
}
