/* ============================================================
   NYSF — Maya front-desk concierge chat widget
   Self-contained. Load on any page alongside maya.js.
   Wired to the Supabase Edge Function `chat-maya` (system prompt
   + Claude call live server-side). Currently mounted on the
   Portrait (photo) studio page only.
   ============================================================ */
.chat-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 85;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--ink); color: var(--cream); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transition: transform 200ms var(--ease, ease);
  font-family: inherit;
}
.chat-fab:hover, .chat-fab:focus-visible { transform: scale(1.05); background: var(--gold); color: var(--ink); outline: none; }
.chat-fab svg { width: 22px; height: 22px; }
.chat-badge { position: absolute; top: -2px; right: -2px; background: var(--gold); color: var(--ink); width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--cream); }

.chat-panel {
  position: fixed; bottom: 92px; right: 24px; z-index: 86;
  width: 380px; max-width: calc(100vw - 48px); height: 540px; max-height: calc(100vh - 120px);
  background: var(--cream); border-radius: 4px; overflow: hidden;
  display: none; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  font-family: var(--sans, 'Nunito Sans', sans-serif);
}
.chat-panel.on { display: flex; }
.chat-head { padding: 18px 20px; background: var(--forest); color: var(--cream); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--gold); display: flex; align-items: center; justify-content: center; color: var(--ink); font-family: var(--display, 'Fraunces', serif); font-size: 18px; font-weight: 500; flex-shrink: 0; }
.chat-title { flex: 1; }
.chat-title strong { display: block; font-family: var(--display, 'Fraunces', serif); font-weight: 400; font-size: 16px; letter-spacing: -0.01em; }
.chat-title .status { font-size: 11px; opacity: 0.8; display: flex; align-items: center; gap: 6px; }
.chat-title .status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--success, #4caf50); }
.chat-close { background: none; border: none; color: var(--cream); font-size: 22px; cursor: pointer; padding: 0 4px; opacity: 0.7; }
.chat-close:hover { opacity: 1; }
.chat-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 84%; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.chat-msg.bot { background: #fff; border-top-left-radius: 4px; align-self: flex-start; }
.chat-msg.user { background: var(--ink); color: var(--cream); border-top-right-radius: 4px; align-self: flex-end; }
.chat-msg.typing { background: #fff; align-self: flex-start; display: inline-flex; gap: 4px; padding: 14px 16px; }
.chat-msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: mayaTyping 1.2s ease-in-out infinite; }
.chat-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes mayaTyping { 0%,60%,100% { opacity: 0.3; } 30% { opacity: 1; } }
.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 12px; }
.chat-quick button { background: transparent; border: 1px solid rgba(26,26,26,0.2); color: var(--ink); padding: 7px 12px; border-radius: 50px; font-size: 11px; font-weight: 600; font-family: inherit; cursor: pointer; }
.chat-quick button:hover, .chat-quick button:focus-visible { background: var(--ink); color: var(--cream); outline: none; }
.chat-input-row { border-top: 1px solid rgba(26,26,26,0.1); padding: 12px; display: flex; gap: 8px; background: #fff; flex-shrink: 0; }
.chat-input { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 14px; color: var(--ink); padding: 10px 12px; }
.chat-input:focus { outline: none; }
.chat-send { background: var(--ink); color: var(--cream); border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.chat-send:hover, .chat-send:focus-visible { background: var(--gold); color: var(--ink); outline: none; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 560px) {
  .chat-panel { left: 12px; right: 12px; width: auto; bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-fab, .chat-msg.typing span { transition: none; animation: none; }
}
