/* ===== AI Chat Widget — uses the site's existing CSS variables (--panel, --line, --text, --teal, --ink, --muted) ===== */

#aiChatFab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(160deg, var(--teal), var(--gold-mid));
  color: var(--ink-on-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  transition: transform .15s ease;
}
#aiChatFab:hover { transform: scale(1.06); }
#aiChatFab i { font-size: 24px; }
#aiChatFab .ai-fab-label {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--panel);
  color: var(--teal);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: .04em;
  padding: 2px 5px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

#aiChatPanel {
  position: fixed;
  right: 18px;
  bottom: 86px;
  z-index: 9999;
  width: min(360px, calc(100vw - 36px));
  height: min(520px, calc(100vh - 140px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#aiChatPanel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#aiChatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--teal-dim);
  flex-shrink: 0;
}
#aiChatHeader .ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: .02em;
}
#aiChatHeader .ai-chat-title i { color: var(--teal); font-size: 16px; }
#aiChatCloseBtn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  line-height: 1;
}
#aiChatCloseBtn:hover { color: var(--text); }

#aiChatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
}
.ai-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--teal);
  color: var(--ink-on-gold);
  border-bottom-right-radius: 3px;
}
.ai-msg.assistant {
  align-self: flex-start;
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}
.ai-msg.assistant.loading { color: var(--muted); font-style: italic; }
.ai-msg.error {
  align-self: flex-start;
  background: rgba(248,113,113,.1);
  color: var(--red);
  border: 1px solid rgba(248,113,113,.3);
}

#aiChatInputRow {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
#aiChatInput {
  flex: 1;
  background: var(--field-bg);
  border: 1px solid var(--field-border-strong);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
}
#aiChatInput::placeholder { color: var(--placeholder); }
#aiChatSendBtn {
  background: var(--teal);
  color: var(--ink-on-gold);
  border: none;
  border-radius: 10px;
  width: 40px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
#aiChatSendBtn:disabled { opacity: .5; cursor: default; }

#aiChatDisclaimer {
  padding: 6px 14px 10px;
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  flex-shrink: 0;
}
