/* ── Chatbot Widget ──────────────────────────────────────────────────────── */

/* ── Chat nudge bubble ───────────────────────────────────────────────────── */
#chatbot-nudge {
  position: fixed;
  bottom: 88px;
  right: 20px;
  background: #fff;
  border: 1px solid #e7d8c8;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: #1c1917;
  box-shadow: 0 4px 16px rgba(0,0,0,0.13);
  z-index: 9997;
  max-width: 200px;
  line-height: 1.4;
  cursor: pointer;
  animation: nudge-in 0.3s ease;
}
#chatbot-nudge::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 22px;
  width: 13px;
  height: 13px;
  background: #fff;
  border-right: 1px solid #e7d8c8;
  border-bottom: 1px solid #e7d8c8;
  transform: rotate(45deg);
}
#chatbot-nudge.hide {
  animation: nudge-out 0.25s ease forwards;
}
@keyframes nudge-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes nudge-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

#chatbot-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand, #7c2d12);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
#chatbot-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

#chatbot-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  transform: scale(0.9) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
#chatbot-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.chatbot-header {
  background: var(--brand, #7c2d12);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chatbot-header-icon { font-size: 20px; }
.chatbot-header-info { flex: 1; }
.chatbot-header-name {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}
.chatbot-header-sub {
  font-size: 11px;
  opacity: 0.8;
  margin: 0;
}
#chatbot-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
  line-height: 1;
}
#chatbot-close:hover { opacity: 1; }

#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fdf8f5;
}

.chat-msg {
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-msg.bot {
  background: #fff;
  color: #1c1917;
  border: 1px solid #e7e0d8;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  background: var(--brand, #7c2d12);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.typing {
  background: #fff;
  border: 1px solid #e7e0d8;
  align-self: flex-start;
  color: #78716c;
  font-style: italic;
  font-size: 13px;
}
.chat-inline-link {
  color: var(--brand, #7c2d12);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.chat-inline-link:hover { opacity: 0.75; }

.chat-msg.disclaimer {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #78350f;
  align-self: stretch;
  max-width: 100%;
  font-size: 12px;
  line-height: 1.55;
  border-radius: 8px;
  padding: 10px 13px;
}

.chat-msg.chat-msg-ratelimit {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #78350f;
  align-self: stretch;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.7;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chatbot-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e7e0d8;
  background: #fff;
  flex-shrink: 0;
}
#chatbot-input {
  flex: 1;
  border: 1px solid #d6cdc4;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  color: #1c1917;
  background: #fdf8f5;
}
#chatbot-input:focus { border-color: var(--brand, #7c2d12); }
#chatbot-send {
  background: var(--brand, #7c2d12);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
#chatbot-send:hover { opacity: 0.88; }
#chatbot-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Birth Chart Panel ───────────────────────────────────────────────────── */
#chatbot-birth-panel {
  background: #fdf3e8;
  border-bottom: 1px solid #e7d8c8;
  padding: 12px 14px;
  flex-shrink: 0;
  display: none;
}
#chatbot-birth-panel.visible { display: block; }

.cb-panel-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand, #7c2d12);
  margin: 0 0 10px;
  letter-spacing: 0.03em;
}
.cb-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.cb-field label {
  font-size: 11px;
  color: #78716c;
  font-weight: 600;
}
.cb-field input {
  border: 1px solid #d6cdc4;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1c1917;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.cb-field input:focus { border-color: var(--brand, #7c2d12); }
#cb_loc_result {
  font-size: 11.5px;
  color: #059669;
  margin: -4px 0 6px;
  min-height: 16px;
}
#cb_calculate {
  width: 100%;
  background: var(--brand, #7c2d12);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
#cb_calculate:hover { opacity: 0.88; }
#cb_calculate:disabled { opacity: 0.45; cursor: not-allowed; }

.chatbot-chart-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #059669;
  font-weight: 600;
  padding: 6px 14px;
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  flex-shrink: 0;
  cursor: pointer;
}
.chatbot-chart-badge span { flex: 1; }

#chatbot-chart-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--brand, #7c2d12);
  font-weight: 700;
}

@media (max-width: 480px) {
  #chatbot-window {
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
    height: 420px;
  }
  #chatbot-btn { right: 16px; bottom: 16px; }
}
