/* Infinity floating chat — couleurs alignées IAP (noir / doré / crème) */
.infinity-chat-root {
  --iac-black: #000000;
  --iac-black-soft: #0b0b0b;
  --iac-accent: #f5b315;
  --iac-accent-soft: rgba(245, 179, 21, 0.18);
  --iac-accent-mid: #d49a12;
  --iac-cream: #faf6ec;
  --iac-white: #ffffff;
  --iac-text: #232323;
  --iac-muted: #606060;
  --iac-border: rgba(0, 0, 0, 0.12);
  --iac-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  font-family: inherit;
}

.infinity-chat-root *,
.infinity-chat-root *::before,
.infinity-chat-root *::after {
  box-sizing: border-box;
}

/* Au-dessus du bouton « back to top » (~45–50px + marge), sans le recouvrir */
.infinity-chat-wrap {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  right: max(16px, env(safe-area-inset-right));
  z-index: 10150;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.infinity-chat-wrap > * {
  pointer-events: auto;
}

@media (min-width: 768px) {
  .infinity-chat-wrap {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    right: 24px;
    gap: 14px;
  }
}

.infinity-chat-panel {
  width: min(100vw - 2rem, 400px);
  max-height: min(72vh, 520px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--iac-white);
  box-shadow: var(--iac-shadow);
}

.infinity-chat-panel.is-open {
  display: flex;
  opacity: 0;
  animation: infinity-chat-panel-in 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes infinity-chat-panel-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.infinity-chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(115deg, var(--iac-black-soft) 0%, var(--iac-black) 55%, #1a1610 100%);
  border-bottom: 2px solid var(--iac-accent);
}

.infinity-chat-header-text {
  min-width: 0;
}

.infinity-chat-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--iac-white);
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.infinity-chat-subtitle {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
}

.infinity-chat-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.infinity-chat-btn-icon:active {
  transform: scale(0.94);
}

.infinity-chat-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background-color: rgba(245, 179, 21, 0.25);
  color: var(--iac-white);
}

.infinity-chat-close:hover {
  background-color: rgba(245, 179, 21, 0.4);
}

.infinity-chat-close svg {
  width: 20px;
  height: 20px;
}

.infinity-chat-messages {
  flex: 1;
  min-height: 200px;
  max-height: min(52vh, 360px);
  overflow-y: auto;
  padding: 16px 12px;
  background: var(--iac-cream);
  scroll-behavior: smooth;
}

.infinity-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.infinity-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 6px;
}

.infinity-chat-row {
  display: flex;
  margin-bottom: 12px;
}

.infinity-chat-row.is-user {
  justify-content: flex-end;
}

.infinity-chat-bubble {
  max-width: 85%;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.55;
}

.infinity-chat-bubble.is-user {
  border: 1px solid rgba(245, 179, 21, 0.45);
  background: rgba(245, 179, 21, 0.14);
  color: var(--iac-text);
  border-bottom-right-radius: 6px;
}

.infinity-chat-bubble.is-assistant {
  border: 1px solid var(--iac-border);
  background: var(--iac-white);
  color: var(--iac-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 6px;
}

.infinity-chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.infinity-chat-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #25d366, #128c7e);
  color: var(--iac-white);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 10px rgba(37, 211, 102, 0.35);
}

.infinity-chat-wa:hover {
  filter: brightness(1.05);
}

.infinity-chat-typing {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}

.infinity-chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(245, 179, 21, 0.55);
  animation: infinity-chat-dot 0.95s ease-in-out infinite;
}

.infinity-chat-typing span:nth-child(2) {
  animation-delay: 0.17s;
}

.infinity-chat-typing span:nth-child(3) {
  animation-delay: 0.34s;
}

@keyframes infinity-chat-dot {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.88);
  }
  45% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .infinity-chat-panel.is-open {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .infinity-chat-fab,
  .infinity-chat-typing span {
    animation: none !important;
  }
}

.infinity-chat-compose {
  flex-shrink: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--iac-white);
  padding: 12px;
}

.infinity-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 14px;
  border: 2px solid #e8e4dc;
  background: var(--iac-white);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.infinity-chat-input-row:focus-within {
  border-color: var(--iac-accent);
  box-shadow: 0 0 0 3px rgba(245, 179, 21, 0.18);
}

.infinity-chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 112px;
  resize: none;
  padding: 10px 8px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  color: var(--iac-text);
  line-height: 1.4;
}

.infinity-chat-input:focus {
  outline: none;
}

.infinity-chat-input::placeholder {
  color: var(--iac-muted);
  opacity: 0.85;
}

.infinity-chat-input:disabled {
  opacity: 0.55;
}

.infinity-chat-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin-bottom: 2px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--iac-black-soft) 0%, var(--iac-black) 100%);
  color: var(--iac-accent);
  box-shadow:
    inset 0 1px 0 rgba(245, 179, 21, 0.35),
    0 2px 12px rgba(0, 0, 0, 0.2);
}

.infinity-chat-send:not(:disabled):hover {
  background: linear-gradient(135deg, #121212 0%, var(--iac-accent-mid) 160%);
  color: var(--iac-white);
}

.infinity-chat-send:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.infinity-chat-send svg {
  width: 18px;
  height: 18px;
}

.infinity-chat-fab {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--iac-black-soft) 0%, var(--iac-black) 100%);
  color: var(--iac-accent);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.45),
    0 0 0 3px rgba(245, 179, 21, 0.35),
    inset 0 2px 0 rgba(245, 179, 21, 0.25);
}

.infinity-chat-fab:hover {
  filter: brightness(1.08);
}

.infinity-chat-fab svg {
  width: 26px;
  height: 26px;
}

.infinity-chat-fab.is-open {
  animation: none;
}

.infinity-chat-fab:not(.is-open) {
  animation: infinity-chat-bounce 1.65s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  animation-delay: 0.2s;
}

@keyframes infinity-chat-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .infinity-chat-fab:not(.is-open) {
    animation: none;
  }
}

.infinity-chat-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
