/* ── Afriqone AI Chat Widget ── */

#ai-chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  font-family: 'Outfit', -apple-system, sans-serif;
}

/* ── Bubble button ── */
.chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #161412;
  color: #f7f5f2;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(22, 20, 18, 0.3);
  transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1),
              box-shadow 200ms cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  margin-left: auto;
}
.chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(22, 20, 18, 0.35);
}
.chat-bubble:active { transform: scale(0.96); }

.chat-bubble-icon { position: absolute; transition: opacity 180ms ease, transform 180ms ease; }
.chat-bubble-icon--close { opacity: 0; transform: rotate(-90deg) scale(0.7); }
.chat-bubble--open .chat-bubble-icon--open { opacity: 0; transform: rotate(90deg) scale(0.7); }
.chat-bubble--open .chat-bubble-icon--close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Notification dot */
.chat-notif {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c8a96e;
  border: 2px solid #f7f5f2;
  animation: chat-pulse 2s ease-in-out infinite;
}
@keyframes chat-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

/* ── Chat window ── */
.chat-window {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 340px;
  max-height: 520px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(22, 20, 18, 0.18), 0 2px 8px rgba(22, 20, 18, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 240ms cubic-bezier(0.23, 1, 0.32, 1),
              transform 240ms cubic-bezier(0.23, 1, 0.32, 1);
}
.chat-window--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0.9rem;
  background: #161412;
  color: #f7f5f2;
  flex-shrink: 0;
}
.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #c8a96e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 800;
  color: #161412;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-size: 0.88rem; font-weight: 700; letter-spacing: -0.01em; }
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: rgba(247, 245, 242, 0.6);
  margin-top: 1px;
}
.chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}
.chat-header-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(247, 245, 242, 0.1);
  border: none;
  color: #f7f5f2;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms ease;
}
.chat-header-close:hover { background: rgba(247, 245, 242, 0.2); }

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #f7f5f2;
  scrollbar-width: thin;
  scrollbar-color: rgba(22, 20, 18, 0.12) transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(22, 20, 18, 0.12); border-radius: 2px; }

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  animation: chat-msg-in 200ms cubic-bezier(0.23, 1, 0.32, 1) both;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg--user { flex-direction: row-reverse; }

.chat-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #c8a96e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 800;
  color: #161412;
  flex-shrink: 0;
}

.chat-msg-bubble {
  max-width: 76%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg--bot .chat-msg-bubble {
  background: #ffffff;
  color: #161412;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(22, 20, 18, 0.07);
}
.chat-msg--user .chat-msg-bubble {
  background: #161412;
  color: #f7f5f2;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.7rem 0.9rem;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a09890;
  animation: chat-dot 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input row ── */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(22, 20, 18, 0.08);
  background: #ffffff;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid rgba(22, 20, 18, 0.12);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.84rem;
  color: #161412;
  background: #f7f5f2;
  outline: none;
  transition: border-color 150ms ease;
}
.chat-input::placeholder { color: #b0a99e; }
.chat-input:focus { border-color: #161412; }

.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #161412;
  color: #f7f5f2;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms ease, transform 150ms ease;
}
.chat-send:hover { background: #2e2b28; }
.chat-send:active { transform: scale(0.94); }

/* ── Mobile ── */
@media (max-width: 480px) {
  #ai-chat-widget {
    bottom: 1rem;
    right: 1rem;
  }
  .chat-window {
    width: calc(100vw - 2rem);
    max-height: 75dvh;
    bottom: calc(100% + 10px);
    right: 0;
  }
}

/* On product page with sticky bar — lift widget up */
body.has-sticky-bar #ai-chat-widget {
  bottom: calc(1.5rem + 68px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 480px) {
  body.has-sticky-bar #ai-chat-widget {
    bottom: calc(1rem + 68px + env(safe-area-inset-bottom, 0px));
  }
}
