/* ── NutriFacts Max Chat Widget ─────────────────────────────────────────── */
#nfm-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #2563EB;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.40);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
  outline: none;
}
#nfm-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(37,99,235,.50);
}
#nfm-chat-btn svg { pointer-events: none; }

/* ── Chat Window ─────────────────────────────────────────────────────────── */
#nfm-chat-window {
  position: fixed;
  bottom: 92px;
  right: 28px;
  z-index: 9999;
  width: 360px;
  max-height: 520px;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 16px;
  box-shadow: 0 24px 48px -12px rgba(17,24,39,.18), 0 8px 16px -8px rgba(17,24,39,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}
#nfm-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
#nfm-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #2563EB;
  color: #fff;
  flex-shrink: 0;
}
#nfm-chat-header-info { display: flex; align-items: center; gap: 10px; }
#nfm-chat-avatar {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
#nfm-chat-title { font-weight: 600; font-size: 14px; line-height: 1.2; }
#nfm-chat-subtitle { font-size: 11px; opacity: .8; margin-top: 1px; }
#nfm-chat-close {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.8); padding: 4px;
  border-radius: 6px; display: flex; align-items: center;
  transition: color .15s;
}
#nfm-chat-close:hover { color: #fff; }

/* Messages */
#nfm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#nfm-chat-messages::-webkit-scrollbar { width: 4px; }
#nfm-chat-messages::-webkit-scrollbar-track { background: transparent; }
#nfm-chat-messages::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 2px; }

.nfm-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.nfm-msg.user {
  align-self: flex-end;
  background: #2563EB;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.nfm-msg.assistant {
  align-self: flex-start;
  background: #F3F4F6;
  color: #111827;
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.nfm-typing {
  align-self: flex-start;
  background: #F3F4F6;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex; gap: 4px; align-items: center;
}
.nfm-typing span {
  width: 6px; height: 6px;
  background: #9CA3AF;
  border-radius: 50%;
  animation: nfm-bounce .9s infinite;
}
.nfm-typing span:nth-child(2) { animation-delay: .15s; }
.nfm-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes nfm-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Input area */
#nfm-chat-footer {
  padding: 12px 14px;
  border-top: 1px solid #E5E7EB;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
#nfm-chat-input {
  flex: 1;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  color: #111827;
  transition: border-color .15s;
}
#nfm-chat-input:focus { border-color: #2563EB; }
#nfm-chat-input::placeholder { color: #9CA3AF; }
#nfm-chat-send {
  width: 34px; height: 34px; flex-shrink: 0;
  background: #2563EB;
  border: none; border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
#nfm-chat-send:hover { background: #1D4ED8; }
#nfm-chat-send:active { transform: scale(.94); }
#nfm-chat-send:disabled { background: #E5E7EB; cursor: not-allowed; }
#nfm-chat-send svg { pointer-events: none; }

/* Mobile */
@media (max-width: 480px) {
  #nfm-chat-window { width: calc(100vw - 24px); right: 12px; bottom: 80px; }
  #nfm-chat-btn { right: 16px; bottom: 16px; }
}
