/* =========================================================
   Chatbot widget — floating bottom-right
   ========================================================= */

.chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink-950);
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 30px -8px var(--accent), 0 4px 12px rgba(0,0,0,0.3);
  display: grid;
  place-items: center;
  transition: transform 200ms;
}
.chat-launcher:hover { transform: translateY(-3px) scale(1.05); }
.chat-launcher svg { width: 26px; height: 26px; }

.chat-launcher .chat-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 14px; height: 14px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--ink-950);
  animation: chatPulse 1.8s ease-in-out infinite;
}
@keyframes chatPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 60;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 140px));
  background: var(--ink-900);
  border: 1px solid var(--ink-600);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
}
.chat-panel.open {
  display: flex;
  animation: chatPanelIn 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes chatPanelIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.chat-header {
  padding: 1rem 1.2rem;
  background: linear-gradient(180deg, var(--ink-800), var(--ink-900));
  border-bottom: 1px solid var(--ink-700);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.chat-header .avatar {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  color: var(--accent);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
}
.chat-header .who { flex: 1; }
.chat-header .who strong {
  display: block;
  color: var(--ink-50);
  font-size: 0.95rem;
  font-weight: 600;
}
.chat-header .who span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ok);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.chat-header .who span::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.chat-close {
  background: none; border: none;
  color: var(--ink-300);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
}
.chat-close:hover { background: var(--ink-700); color: var(--ink-50); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--ink-600); border-radius: 3px; }

.chat-msg {
  max-width: 85%;
  padding: 0.7rem 0.95rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  animation: msgIn 220ms ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.chat-msg.bot {
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  color: var(--ink-100);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.chat-msg.user {
  background: var(--accent);
  color: var(--ink-950);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.chat-suggestions button {
  background: transparent;
  border: 1px solid var(--ink-600);
  color: var(--ink-200);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 150ms;
}
.chat-suggestions button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem;
  border-top: 1px solid var(--ink-700);
  background: var(--ink-900);
}
.chat-input input {
  flex: 1;
  background: var(--ink-800);
  border: 1px solid var(--ink-600);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  color: var(--ink-50);
  font-family: var(--font-body);
  font-size: 0.92rem;
}
.chat-input input:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-input button {
  background: var(--accent);
  color: var(--ink-950);
  border: none;
  border-radius: 8px;
  width: 42px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 120ms;
}
.chat-input button:hover { transform: scale(1.05); }

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.8rem 1rem;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}
.typing span {
  width: 6px; height: 6px;
  background: var(--ink-300);
  border-radius: 50%;
  animation: typingDot 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}
