/* =====================================================================
   Nancy, assistante de discussion (assets/js/nancy.js)
   ===================================================================== */
.scroll-up {
  bottom: 100px;
  right: 32px;
}

/* Remise à zéro des boutons et champs du chat (le site donne un style par défaut aux boutons). */
:where(.nancy-chat) button {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  line-height: inherit;
}
:where(.nancy-chat) a:hover {
  color: inherit;
}
.nancy-chat input[type="text"],
.nancy-chat input[type="tel"] {
  width: auto;
  height: auto;
}

.nancy-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1050;
  font-size: 15px;
}

.nancy-chat-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: #004ea1;
  color: #ffffff;
  font-size: 26px;
  box-shadow: 0 12px 30px rgba(0, 78, 161, 0.45);
  transition: transform 0.3s, background 0.3s;
}

.nancy-chat-toggle:hover {
  transform: scale(1.06);
}

.nancy-chat-toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #004ea1;
  animation: nancyPulse 2.4s ease-out infinite;
}

@keyframes nancyPulse {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(1.6); opacity: 0; }
}

.nancy-chat-ico-close,
.nancy-chat.is-open .nancy-chat-ico-open {
  display: none;
}

.nancy-chat.is-open .nancy-chat-ico-close {
  display: inline-block;
}

.nancy-chat.is-open .nancy-chat-toggle {
  background: #082c54;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.nancy-chat.is-open .nancy-chat-toggle::before,
.nancy-chat.is-open .nancy-chat-dot {
  display: none;
}

.nancy-chat-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #25d366;
  border: 2px solid #ffffff;
}

.nancy-chat-teaser {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 250px;
  padding: 16px 34px 16px 18px;
  border-radius: 16px 16px 4px 16px;
  background: #ffffff;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  animation: nancyStepIn 0.4s ease;
}

.nancy-chat-teaser[hidden] {
  display: none;
}

.nancy-chat-teaser p {
  margin: 0;
  font-size: 0.9rem;
  color: #082c54;
}

.nancy-chat-teaser-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: #9aa0a6;
}

.nancy-chat-window {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 430px;
  /* la fenêtre tient toujours entre le bouton et le haut de l'écran */
  height: min(600px, calc(100vh - 130px));
  height: min(600px, calc(100dvh - 130px));
  min-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  animation: nancyChatIn 0.3s ease;
}

.nancy-chat-window[hidden] {
  display: none;
}

@keyframes nancyChatIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.nancy-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  color: #ffffff;
  background:
    radial-gradient(circle at 100% 0, rgba(0, 78, 161, 0.45), transparent 60%),
    #082c54;
}

.nancy-chat-avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #004ea1;
  font-size: 20px;
}

.nancy-chat-head strong {
  display: block;
  white-space: nowrap;
  font-family: "Outfit", sans-serif;
  font-size: 1rem;
}

.nancy-chat-head small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.78rem;
}

.nancy-chat-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25d366;
}

.nancy-chat-human {
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #ffffff;
  border-radius: 20px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  transition: 0.3s;
}

.nancy-chat-human:hover {
  background: #004ea1;
  border-color: #004ea1;
}

.nancy-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: #f5f8fb;
  scroll-behavior: smooth;
}

.nancy-msg {
  display: flex;
  margin-bottom: 10px;
  animation: nancyMsgIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes nancyMsgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.nancy-msg-bot .nancy-msg-bubble {
  transform-origin: bottom left;
}

/* curseur pendant que Nancy écrit */
.nancy-msg-bubble.is-writing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: #004ea1;
  animation: nancyCaret 0.8s steps(1) infinite;
}

@keyframes nancyCaret {
  50% { opacity: 0; }
}

.nancy-msg-user .nancy-msg-bubble {
  transform-origin: bottom right;
}

.nancy-msg-user {
  justify-content: flex-end;
}

.nancy-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.92rem;
  animation: nancyStepIn 0.25s ease;
}

.nancy-msg-bot .nancy-msg-bubble {
  background: #ffffff;
  color: #082c54;
  border-bottom-left-radius: 4px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.nancy-msg-bot .nancy-msg-bubble a {
  color: #004ea1;
  font-weight: 600;
}

.nancy-msg-user .nancy-msg-bubble {
  background: #004ea1;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.nancy-ok {
  color: #25a55f;
}

.nancy-typing {
  display: flex;
  gap: 4px;
  padding: 14px 16px;
}

.nancy-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c3c7cc;
  animation: nancyDots 1.4s infinite ease-in-out;
}

.nancy-typing span:nth-child(2) { animation-delay: 0.2s; }
.nancy-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes nancyDots {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.nancy-chat-chips > * {
  animation: nancyMsgIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.nancy-chat-chips > *:nth-child(2) { animation-delay: 0.06s; }
.nancy-chat-chips > *:nth-child(3) { animation-delay: 0.12s; }
.nancy-chat-chips > *:nth-child(4) { animation-delay: 0.18s; }
.nancy-chat-chips > *:nth-child(n+5) { animation-delay: 0.24s; }

.nancy-typing-text {
  color: #9aa0a6;
  font-style: italic;
}

.nancy-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  background: #f5f8fb;
  max-height: 150px;
  overflow-y: auto;
}

.nancy-chat-chips:empty {
  display: none;
}

.nancy-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 20px;
  border: 1.5px solid rgba(0, 78, 161, 0.5);
  background: #ffffff;
  color: #082c54;
  font-size: 0.83rem;
  font-weight: 600;
  text-decoration: none;
  transition: 0.2s;
}

.nancy-chip i {
  color: #004ea1;
  font-size: 0.8rem;
}

.nancy-chip:hover {
  background: #004ea1;
  border-color: #004ea1;
  color: #ffffff;
}

.nancy-chip:hover i {
  color: #ffffff;
}

.nancy-chip-primary {
  background: #004ea1;
  border-color: #004ea1;
  color: #ffffff;
}

.nancy-chip-primary i {
  color: #ffffff;
}

.nancy-chip-human {
  background: #082c54;
  border-color: #082c54;
  color: #ffffff;
}

.nancy-chip-human i {
  color: #e2c65b;
}

.nancy-chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #efefef;
  background: #ffffff;
}

.nancy-chat-input input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1.5px solid transparent;
  border-radius: 24px;
  background: #f5f8fb;
  font-size: 0.93rem;
  outline: none;
}

.nancy-chat-input input:focus {
  border-color: #004ea1;
  background: #ffffff;
}

.nancy-chat-input button {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: #004ea1;
  color: #ffffff;
}

@media (max-width: 575.98px) {
  .nancy-chat {
    right: 14px;
    bottom: 14px;
  }

  .nancy-chat-window {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
  }

  .nancy-chat.is-open .nancy-chat-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 18px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
  }

  .nancy-chat-head {
    padding-right: 64px;
  }

  .nancy-chat-head > div {
    min-width: 0;
  }

  .nancy-chat-human span {
    display: none;
  }

  .nancy-chat-human {
    padding: 8px 12px;
    font-size: 0.95rem;
  }

  .scroll-up {
    right: 22px;
    bottom: 90px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nancy-chat-toggle::before,
  .nancy-msg,
  .nancy-chat-chips > * {
    animation: none;
  }
}


/* Discussion en direct dans la bulle */
.nancy-msg-agent .nancy-msg-bubble {
  background: #082c54;
  color: #ffffff;
  border-bottom-left-radius: 4px;
}

.nancy-msg-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #e2c65b;
  margin-bottom: 2px;
}

.nancy-msg-system {
  justify-content: center;
}

.nancy-msg-system .nancy-msg-bubble {
  max-width: 90%;
  padding: 4px 10px;
  background: transparent;
  color: #8b9097;
  font-size: 0.8rem;
  text-align: center;
  box-shadow: none;
}

.nancy-msg-user.is-pending .nancy-msg-bubble {
  opacity: 0.6;
}

.nancy-msg-user.is-failed .nancy-msg-bubble {
  background: #c62828;
}

.nancy-chat-online.nancy-wait {
  background: #b1951b;
  animation: nancyBlink 1.2s ease-in-out infinite;
}

.nancy-chat-online.nancy-off {
  background: #9aa0a6;
}

@keyframes nancyBlink {
  50% { opacity: 0.3; }
}

.nancy-chat-human[hidden] {
  display: none;
}

.nancy-chat.has-unread .nancy-chat-dot {
  background: #e53935;
  animation: nancyBlink 1s ease-in-out infinite;
}

/* Récapitulatif de la demande dans l'assistant */
.nancy-chat-recap > span {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.nancy-chat-recap dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f5f8fb;
  border: 1px solid rgba(0, 78, 161, 0.25);
  font-size: 0.9em;
}
.nancy-chat-recap dt {
  color: #7a7f87;
  font-weight: 500;
}
.nancy-chat-recap dd {
  margin: 0;
  font-weight: 600;
  word-break: break-word;
}
/* Photo de Nancy */
.nancy-chat-photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #ffffff;
}
.nancy-chat-toggle:has(.nancy-chat-photo) { padding: 0; background: #ffffff; }
.nancy-chat.is-open .nancy-chat-toggle .nancy-chat-photo { display: none; }
.nancy-chat-avatar { overflow: hidden; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); background: #ffffff; }
.nancy-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nancy-chat-teaser { display: flex; gap: 12px; align-items: flex-start; width: 290px; }
.nancy-chat-teaser p { margin: 0; font-size: 15px; line-height: 1.5; }
.nancy-chat-teaser-photo { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
/* petite photo à côté des messages de Nancy */
.nancy-msg-bot { align-items: flex-end; gap: 8px; }
.nancy-msg-face { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; box-shadow: 0 2px 6px rgba(8, 44, 84, 0.2); }
.nancy-msg-bot + .nancy-msg-bot .nancy-msg-face { visibility: hidden; }
