/* ═══════════════════════════════════════════════════════════════
   chat.css — the site-wide chat widget.
   Markup is injected by assets/chat.js; these styles read the
   :root tokens defined in site.css, so site.css must load first.
   ═══════════════════════════════════════════════════════════════ */

#chat-bubble {
  position: fixed; bottom: 24px; right: 24px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--gold); border: none; cursor: pointer;
  z-index: 9999; box-shadow: 0 4px 16px rgba(160,120,48,0.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
#chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 22px rgba(160,120,48,0.55); }
#chat-bubble svg { width: 24px; height: 24px; fill: #fff; }

#chat-panel {
  position: fixed; bottom: 90px; right: 24px;
  width: 340px; max-height: 480px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.13);
  z-index: 9998; display: flex; flex-direction: column; overflow: hidden;
  transform: scale(0.9) translateY(16px); opacity: 0; pointer-events: none;
  transition: transform 0.2s, opacity 0.2s; transform-origin: bottom right;
}
#chat-panel.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

.chat-head {
  background: var(--gold); padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-head-left { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-avatar svg { width: 15px; height: 15px; display: block; }
.chat-title { color: #fff; font-family: 'Cormorant Garamond', serif; font-size: 1.05rem; font-weight: 600; }
.chat-sub { color: rgba(255,255,255,0.78); font-size: 0.7rem; letter-spacing: 1.2px; text-transform: uppercase; }
.chat-x {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.75); font-size: 22px; line-height: 1; padding: 2px 5px;
  border-radius: 4px;
}
.chat-x:hover { color: #fff; background: rgba(255,255,255,0.15); }

.chat-msgs {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 9px; background: var(--bg);
}
.cmsg {
  max-width: 86%; padding: 10px 14px;
  font-size: 0.875rem; line-height: 1.6;
}
.cmsg.bot {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px 12px 12px 2px; align-self: flex-start;
}
.cmsg.user {
  background: var(--gold); color: #fff;
  border-radius: 12px 12px 2px 12px; align-self: flex-end;
}
.cmsg.typing { font-style: italic; color: var(--text-muted); }

.chat-foot {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--surface);
}
#chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; font-family: 'Inter', sans-serif; font-size: 0.875rem;
  resize: none; outline: none; max-height: 80px;
  background: var(--bg); color: var(--text);
}
#chat-input:focus { border-color: var(--gold-light); }
#chat-send {
  width: 36px; height: 36px; border-radius: 8px; border: none;
  background: var(--gold); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
#chat-send:hover { opacity: 0.85; }
#chat-send:disabled { opacity: 0.38; cursor: default; }
#chat-send svg { width: 16px; height: 16px; fill: #fff; }

/* markdown rendered inside bot bubbles */
.cmsg.bot strong { font-weight: 700; color: inherit; }
.cmsg.bot p { margin: 0 0 10px 0; line-height: 1.6; }
.cmsg.bot p:last-child { margin-bottom: 0; }
.cmsg.bot ul { margin: 0 0 10px 18px; padding: 0; }
.cmsg.bot ul:last-child { margin-bottom: 0; }
.cmsg.bot li { margin-bottom: 5px; line-height: 1.6; }

/* intro form */
#chat-intro {
  padding: 18px 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
#chat-intro p {
  margin: 0 0 4px; font-size: 13px; color: var(--text-muted, #aaa); line-height: 1.45;
}
#chat-intro input {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border, #333);
  background: var(--bg, #181510); color: var(--text, #f0e8d0);
  font-size: 14px; outline: none;
}
#chat-intro input:focus { border-color: var(--gold, #a07830); }
#chat-intro .chat-start-btn {
  background: var(--gold, #a07830); color: #fff;
  border: none; border-radius: 8px; padding: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s;
}
#chat-intro .chat-start-btn:hover { opacity: 0.88; }
#chat-intro .opt-label { font-size: 11px; color: var(--text-muted, #888); margin-top: -4px; }

@media (max-width: 480px) {
  #chat-panel {
    width: calc(100vw - 32px); right: 16px; left: 16px;
    bottom: 82px; max-height: 72vh;
    transition: transform 0.2s, opacity 0.2s, bottom 0.15s, max-height 0.15s;
  }
  #chat-bubble { right: 16px; bottom: 16px; }
}
