/* ============================================================
   Ask Anthony — AI chat assistant widget
   Reuses the design tokens from styles.css (:root vars)
   ============================================================ */

.chatbot { position: fixed; z-index: 200; right: 24px; bottom: 24px; }

/* ---------- Launcher ---------- */
.chat-launcher {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 50%;
  padding: 0;
  background: var(--ink);
  box-shadow: 0 14px 34px rgba(14, 18, 23, 0.34);
  cursor: pointer;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
  overflow: visible;
}
.chat-launcher::after {
  content: "";
  position: absolute; inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0.55;
  animation: chatPulse 2.6s ease-out infinite;
}
@keyframes chatPulse {
  0% { transform: scale(1); opacity: 0.55; }
  70% { transform: scale(1.28); opacity: 0; }
  100% { opacity: 0; }
}
.chat-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 20px 44px rgba(14, 18, 23, 0.44); }
.chat-launcher__img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.chat-launcher__dot {
  position: absolute; right: 3px; bottom: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #2ecc71; border: 3px solid var(--paper);
  z-index: 2;
}
/* Close icon shown when the panel is open */
.chat-launcher__close {
  position: absolute; inset: 0; margin: auto;
  width: 26px; height: 26px;
  display: none; place-items: center;
  color: #fff;
}
.chat-launcher__close svg { width: 24px; height: 24px; }
.chatbot.open .chat-launcher__img,
.chatbot.open .chat-launcher__dot,
.chatbot.open .chat-launcher::after { opacity: 0; }
.chatbot.open .chat-launcher { background: var(--gold); }
.chatbot.open .chat-launcher__close { display: grid; }

/* Greeting nudge bubble */
.chat-nudge {
  position: absolute; right: 84px; bottom: 14px;
  width: max-content; max-width: 220px;
  background: #fff; color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px 14px 4px 14px;
  padding: 0.7rem 0.95rem;
  font-size: 0.86rem; line-height: 1.4;
  box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(6px) scale(0.96);
  transform-origin: bottom right;
  transition: all 0.45s var(--ease);
  pointer-events: none;
}
.chat-nudge strong { color: var(--gold-deep); }
.chat-nudge.show { opacity: 1; transform: none; pointer-events: auto; }
.chat-nudge__x {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: 0.8rem; line-height: 1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.chatbot.open .chat-nudge { display: none; }

/* ---------- Panel ---------- */
.chat-panel {
  position: absolute; right: 0; bottom: 88px;
  width: 384px; max-width: calc(100vw - 40px);
  height: 574px; max-height: calc(100svh - 140px);
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(14, 18, 23, 0.34);
  border: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; transform: translateY(18px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.chatbot.open .chat-panel { opacity: 1; transform: none; pointer-events: auto; }

/* Header */
.chat-head {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--ink);
  color: #fff;
  position: relative;
}
.chat-head__avatar {
  width: 46px; height: 46px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.18);
}
.chat-head__meta { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.chat-head__name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.chat-head__status { font-size: 0.72rem; letter-spacing: 0.04em; color: rgba(255,255,255,0.7); display: inline-flex; align-items: center; gap: 0.4rem; }
.chat-head__status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,0.2); }
.chat-head__min {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: rgba(255,255,255,0.8);
  transition: background 0.3s, color 0.3s;
}
.chat-head__min:hover { background: rgba(255,255,255,0.12); color: #fff; }
.chat-head__min svg { width: 18px; height: 18px; }

/* Message area */
.chat-body {
  flex: 1; overflow-y: auto;
  padding: 1.2rem 1.1rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.7rem;
  background:
    radial-gradient(circle at 100% 0%, rgba(184,147,90,0.06), transparent 45%),
    var(--paper);
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 7px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(14,18,23,0.16); border-radius: 10px; }

.msg { max-width: 84%; font-size: 0.92rem; line-height: 1.5; padding: 0.7rem 0.95rem; border-radius: 14px; animation: msgIn 0.35s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg--bot { align-self: flex-start; background: #fff; color: var(--text); border: 1px solid var(--line-2); border-bottom-left-radius: 4px; box-shadow: 0 2px 10px rgba(14,18,23,0.05); }
.msg--user { align-self: flex-end; background: var(--gold); color: #fff; border-bottom-right-radius: 4px; }
.msg--bot a { color: var(--gold-deep); font-weight: 600; }

/* Typing indicator */
.chat-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 0.85rem 1rem; background: #fff; border: 1px solid var(--line-2); border-radius: 14px; border-bottom-left-radius: 4px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-light); animation: typing 1.3s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Quick replies */
.chat-quick { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.4rem 1.1rem 0.8rem; }
.chat-quick button {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 500;
  color: var(--gold-deep); background: rgba(184,147,90,0.1);
  border: 1px solid rgba(184,147,90,0.32); border-radius: 100px;
  padding: 0.42rem 0.85rem; transition: all 0.3s var(--ease); white-space: nowrap;
}
.chat-quick button:hover { background: var(--gold); color: #fff; border-color: var(--gold); }

/* Composer */
.chat-foot { padding: 0.75rem 0.85rem; border-top: 1px solid var(--line); background: #fff; }
.chat-form { display: flex; align-items: flex-end; gap: 0.5rem; }
.chat-form textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 0.7rem 0.9rem; font-family: var(--sans); font-size: 0.92rem; line-height: 1.4;
  max-height: 96px; background: var(--paper); color: var(--text);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-form textarea:focus { outline: none; border-color: var(--gold); background: #fff; box-shadow: 0 0 0 3px rgba(184,147,90,0.14); }
.chat-send {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px;
  background: var(--gold); color: #fff; display: grid; place-items: center;
  transition: background 0.3s, transform 0.3s;
}
.chat-send:hover { background: var(--gold-deep); transform: translateY(-1px); }
.chat-send:disabled { opacity: 0.45; cursor: default; transform: none; }
.chat-send svg { width: 19px; height: 19px; }
.chat-disclaimer { text-align: center; font-size: 0.66rem; color: var(--muted-light); margin-top: 0.5rem; letter-spacing: 0.01em; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .chatbot { right: 16px; bottom: 16px; }
  .chat-panel { width: calc(100vw - 24px); height: calc(100svh - 110px); right: -4px; bottom: 84px; }
  .chat-launcher { width: 62px; height: 62px; }
  .chat-nudge { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-launcher::after { animation: none; }
}
