/* ============================================
   CHATBOT — SHARED COMPONENT
   ============================================ */
#chatbot-root {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9998;
  font-family: var(--body);
}
#chat-launcher {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--flame);
  color: var(--ink);
  border: none;
  padding: 0.875rem 1.25rem 0.875rem 0.875rem;
  font-family: var(--body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 100px;
  position: relative;
  box-shadow: 0 12px 30px -8px rgba(244, 185, 66, 0.5),
              0 0 0 1px rgba(244, 185, 66, 0.15);
  transition: all 0.4s var(--ease-out-expo);
}
#chat-launcher:hover {
  transform: translateY(-3px);
  background: var(--flame-light);
  box-shadow: 0 18px 40px -8px rgba(244, 185, 66, 0.65),
              0 0 0 1px rgba(244, 185, 66, 0.2);
}
#chat-launcher .chat-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  display: grid;
  place-items: center;
  color: var(--flame);
}
#chat-launcher .chat-icon svg { width: 14px; height: 14px; }
.chat-launcher-pulse {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  background: var(--jade);
  border-radius: 50%;
  border: 2px solid var(--flame);
}
.chat-launcher-pulse::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--jade);
  animation: chatPulse 2s ease-in-out infinite;
}
@keyframes chatPulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.8); opacity: 0; }
}
#chatbot-root.open #chat-launcher {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

#chat-window {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 400px;
  max-width: calc(100vw - 3rem);
  height: 600px;
  max-height: calc(100vh - 6rem);
  background: var(--bone);
  border: 1px solid var(--ink);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 80px -20px rgba(30, 33, 84, 0.5),
              0 0 0 1px rgba(244, 185, 66, 0.1);
  opacity: 0;
  transform: scale(0.92) translateY(20px);
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out-expo),
              transform 0.4s var(--ease-out-back);
  transform-origin: bottom right;
}
#chatbot-root.open #chat-window {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.125rem;
  background: var(--ink);
  color: var(--bone);
  border-bottom: 1px solid var(--rule-dark);
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}
.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--flame);
  flex-shrink: 0;
}
.chat-header-text { min-width: 0; flex: 1; }
.chat-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.chat-status {
  font-family: var(--mono);
  font-size: 0.625rem;
  color: var(--bone-warm);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.chat-status-dot {
  width: 7px;
  height: 7px;
  background: var(--jade);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--jade);
}
#chat-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink-80);
  color: var(--bone);
  display: grid;
  place-items: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
#chat-close:hover { background: var(--flame); color: var(--ink); transform: rotate(90deg); }
#chat-close svg { width: 14px; height: 14px; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  background: var(--bone);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--flame) transparent;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--flame); border-radius: 2px; }

.chat-msg {
  display: flex;
  max-width: 88%;
  animation: msgIn 0.4s var(--ease-out-expo);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; justify-content: flex-end; }
.chat-bubble {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
  border-radius: 18px;
}
.chat-msg.bot .chat-bubble {
  background: #fff;
  color: var(--ink);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--rule-light);
}
.chat-msg.user .chat-bubble {
  background: var(--ink);
  color: var(--bone);
  border-bottom-right-radius: 4px;
}
.chat-bubble strong { color: var(--flame-deep); font-weight: 700; }
.chat-msg.user .chat-bubble strong { color: var(--flame-light); }
.chat-bubble a { color: var(--electric); text-decoration: underline; }
.chat-msg.user .chat-bubble a { color: var(--flame-light); }

.chat-typing {
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.875rem 1rem;
  align-items: center;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--flame);
  border-radius: 50%;
  animation: chatTyping 1.3s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTyping {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0 0.5rem;
}
.quick-reply {
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 0.5rem 0.875rem;
  font-family: var(--body);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 100px;
  transition: all 0.25s var(--ease-out-expo);
}
.quick-reply:hover {
  background: var(--ink);
  color: var(--bone);
  transform: translateY(-1px);
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--rule-light);
  background: #fff;
  align-items: center;
}
#chat-input {
  flex: 1;
  border: 1px solid var(--rule-light);
  padding: 0.625rem 0.875rem;
  font-family: var(--body);
  font-size: 0.875rem;
  background: var(--bone-50);
  color: var(--ink);
  outline: none;
  border-radius: 100px;
  transition: all 0.25s;
}
#chat-input:focus {
  border-color: var(--flame);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(244, 185, 66, 0.12);
}
#chat-input:disabled { opacity: 0.5; }
#chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--flame);
  color: var(--ink);
  display: grid;
  place-items: center;
  transition: all 0.3s var(--ease-out-expo);
  flex-shrink: 0;
}
#chat-send:hover:not(:disabled) {
  background: var(--ink);
  color: var(--flame);
  transform: scale(1.08);
}
#chat-send:disabled { opacity: 0.4; }
#chat-send svg { width: 16px; height: 16px; }

.chat-footer {
  padding: 0.5rem 1rem;
  font-family: var(--mono);
  font-size: 0.625rem;
  text-align: center;
  background: var(--bone-warm);
  color: var(--ink);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-top: 1px solid var(--rule-light);
  opacity: 0.7;
}
.chat-footer a { color: var(--flame-deep); }
.chat-footer a:hover { text-decoration: underline; }

@media (max-width: 860px) {
  #chat-launcher .chat-launcher-text { display: none; }
  #chat-launcher { padding: 1rem; }
  #chat-launcher .chat-icon { margin: 0; }
}
@media (max-width: 520px) {
  #chatbot-root { bottom: 1rem; right: 1rem; }
  #chat-launcher { padding: 0.875rem; }
  #chat-window {
    width: calc(100vw - 2rem);
    height: calc(100vh - 8rem);
  }
}
