/* Chatbot Néo-style (ABFC namespaced) */

#abfc-chatbot {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9999;
  font-family: inherit;
}

#abfc-chatbot .abfc-chatbot__fab,
#abfc-chatbot .abfc-chatbot__panel,
#abfc-chatbot .abfc-chatbot__backdrop {
  pointer-events: auto;
}

@keyframes abfc-chatbot-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px) scale(1.02);
  }
  60% {
    transform: translateY(0);
  }
  80% {
    transform: translateY(-4px);
  }
}

.abfc-chatbot__fab {
  position: relative;
  border: none;
  border-radius: 999px;
  padding: 1.25rem 2.25rem;
  min-width: 210px;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.35);
  cursor: pointer;
  transition: transform 220ms ease, box-shadow 220ms ease;
  text-transform: none;
  z-index: 10001;
  animation: abfc-chatbot-bounce 0.6s cubic-bezier(0.25, 0.75, 0.5, 1.25) 0s 3 normal both;
  will-change: transform;
}

@keyframes abfc-chatbot-dot {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.6);
  }
  40% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 1;
    transform: translateY(-2px) scale(0.85);
  }
}

@keyframes abfc-chatbot-bubble-cloud {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.9);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@keyframes abfc-chatbot-cloud-appear {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes abfc-chatbot-hint-fade {
  0% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* Sequential bubble hint */
.abfc-chatbot__fab-hint {
  position: absolute;
  left: 50%;
  bottom: 130%;
  transform: translate(-50%, 10px) scale(0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  pointer-events: none;
  animation: abfc-chatbot-hint-fade 7s linear forwards;
}

/* cloud appear after dots sequence */
.abfc-chatbot__bubble-cloud {
  position: relative;
  width: 250px;
  padding: 1.5rem 1.8rem;
  border-radius: 999px;
  background: #fff;
  border: 3px solid #0f172a;
  box-shadow: 14px 16px 0 rgba(15, 23, 42, 0.2), 0 22px 42px rgba(15, 23, 42, 0.25);
  display: flex;
  justify-content: center;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(12px);
  animation: abfc-chatbot-cloud-appear 0.9s ease 3.1s forwards;
}

.abfc-chatbot__bubble-text {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #0f172a;
  line-height: 1.3;
}

.abfc-chatbot__bubble-dots {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.abfc-chatbot__bubble-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #0f172a;
  box-shadow: 5px 4px 0 rgba(15, 23, 42, 0.18);
  opacity: 0;
  animation: abfc-chatbot-dot 1s ease forwards;
  animation-fill-mode: forwards;
}

.abfc-chatbot__bubble-dot--first { animation-delay: 2.7s; }
.abfc-chatbot__bubble-dot--second { animation-delay: 2.4s; }
.abfc-chatbot__bubble-dot--third { animation-delay: 2.1s; }

.abfc-chatbot__fab:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.45);
  animation-play-state: paused;
}

.abfc-chatbot__fab:focus-visible {
  outline: 2px solid #fde047;
  outline-offset: 2px;
  animation-play-state: paused;
}

.abfc-chatbot__fab:active {
  transform: translateY(1px);
}

.abfc-chatbot__fab-pulse {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
  animation: abfc-chatbot-pulse 1.8s infinite;
}

.abfc-chatbot__fab-label {
  display: inline-block;
}

.abfc-chatbot__backdrop {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.25), transparent 60%);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 240ms ease;
  z-index: 9988;
  pointer-events: none;
  display: none;
}

.abfc-chatbot__panel {
  position: fixed;
  bottom: 7.5rem;
  right: 1.35rem;
  width: min(360px, calc(100vw - 2rem));
  background: rgba(15, 23, 42, 0.92);
  border-radius: 22px;
  padding: 1rem;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transform: translateY(40px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease, transform 260ms ease;
  color: #f8fafc;
  z-index: 9990;
}

.abfc-chatbot--open .abfc-chatbot__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.abfc-chatbot--open .abfc-chatbot__backdrop {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

.abfc-chatbot__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.abfc-chatbot__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.abfc-chatbot__avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  background: transparent;
  padding: 6px;
  transition: transform 0.4s ease;
}

.abfc-chatbot__avatar:hover img {
  animation: neo-spin 0.4s linear;
}

@keyframes neo-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
}

.abfc-chatbot__avatar-text {
  font-size: 0.65rem;
  text-align: center;
  line-height: 1.1;
}

.abfc-chatbot__header-text {
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.4;
}

.abfc-chatbot__header-text p:first-child {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.abfc-chatbot__header-text p:last-child {
  margin: 0;
  color: rgba(248, 250, 252, 0.72);
}

.abfc-chatbot__close {
  border: none;
  background: transparent;
  color: #f8fafc;
  font-size: 1.1rem;
  padding: 0.3rem;
  border-radius: 999px;
  transition: background 180ms ease;
  cursor: pointer;
}

.abfc-chatbot__close:hover,
.abfc-chatbot__close:focus-visible {
  background: rgba(255, 255, 255, 0.1);
}

.abfc-chatbot__history {
  max-height: 210px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.25rem;
  margin-bottom: 0.6rem;
}

.abfc-chatbot__message {
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-line;
  max-width: 100%;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  animation: abfc-chatbot-pop 320ms ease;
}

.abfc-chatbot__message--bot {
  background: rgba(15, 118, 208, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  align-self: flex-start;
}

.abfc-chatbot__message .abfc-chatbot__link {
  color: var(--abfc-link, #1fa3dd);
  text-decoration: underline;
  font-weight: 600;
}

.abfc-chatbot__message--user {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(14, 165, 233, 0.9));
  color: #fff;
  border: none;
  align-self: flex-end;
}

.abfc-chatbot__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.abfc-chatbot__chip {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  background: rgba(15, 23, 42, 0.6);
  color: #f8fafc;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.abfc-chatbot__chip:hover,
.abfc-chatbot__chip:focus-visible {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.6);
  transform: translateY(-1px);
}

.abfc-chatbot__form {
  display: flex;
  gap: 0.5rem;
}

.abfc-chatbot__input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #f8fafc;
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  transition: border 180ms ease;
}

.abfc-chatbot__input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.8);
}

.abfc-chatbot__send {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  color: #0f172a;
  font-weight: 600;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.abfc-chatbot__send:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.45);
}

.abfc-chatbot__send:focus-visible {
  outline: 2px solid #fde047;
  outline-offset: 2px;
}

.abfc-chatbot__typing {
  align-self: flex-start;
  display: flex;
  gap: 0.25rem;
}

.abfc-chatbot__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  animation: abfc-chatbot-typing 1s infinite ease;
}

.abfc-chatbot__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.abfc-chatbot__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes abfc-chatbot-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes abfc-chatbot-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.25);
    opacity: 0.4;
  }
  100% {
    transform: scale(0.9);
    opacity: 0.9;
  }
}

@keyframes abfc-chatbot-typing {
  0% {
    opacity: 0.2;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
}

@keyframes abfc-chatbot-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@media (max-width: 640px) {
  #abfc-chatbot {
    right: 1rem;
    left: 1rem;
    bottom: 1rem;
  }

  .abfc-chatbot__panel {
    width: calc(100vw - 2rem);
    bottom: 5.5rem;
    right: 1rem;
  }

  .abfc-chatbot__fab {
    min-width: 0;
    width: min(420px, calc(100% - 2rem));
    justify-content: center;
    padding: 1rem 1.25rem;
  }

  .abfc-chatbot__fab-label {
    font-size: 1rem;
    letter-spacing: 0.04em;
  }

  .abfc-chatbot__fab-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .abfc-chatbot__fab,
  .abfc-chatbot__panel,
  .abfc-chatbot__chip,
  .abfc-chatbot__send {
    transition: none !important;
    animation: none !important;
  }
  .abfc-chatbot__fab-hint {
    animation: none !important;
    opacity: 1;
  }
}

.abfc-logout-floating {
  right: calc(2rem + 230px) !important;
}

@media (max-width: 767px) {
  .abfc-logout-floating {
    right: 14px !important;
  }
}
