/* ============================
   Portfolio Assistant chat widget
   Reuses the color/font tokens already defined in style.css
   ============================ */

.chatbot-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px var(--shadow);
  transition: transform 0.2s ease, background 0.2s ease;
}

.chatbot-launcher:hover { transform: translateY(-3px); }

.chatbot-launcher svg { width: 24px; height: 24px; }

.chatbot-launcher .icon-close { display: none; }
.chatbot-launcher.is-open .icon-chat { display: none; }
.chatbot-launcher.is-open .icon-close { display: block; }

.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.chatbot-panel {
  position: fixed;
  right: 24px;
  bottom: 94px;
  z-index: 50;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 140px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.chatbot-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--bg);
}

.chatbot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chatbot-avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.chatbot-header-text h4 {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

.chatbot-header-text p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  opacity: 0.7;
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.chatbot-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chatbot-msg.bot {
  align-self: flex-start;
  background: var(--surface);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.chatbot-msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

.chatbot-msg.error {
  align-self: center;
  background: transparent;
  color: #B4483A;
  font-size: 0.8rem;
  text-align: center;
}

.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 14px;
}

.chatbot-suggestion {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.76rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.chatbot-suggestion:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.chatbot-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: chatbot-bounce 1.2s infinite ease-in-out;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chatbot-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
}

.chatbot-input:focus { border-color: var(--accent); }

.chatbot-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.chatbot-send:hover { transform: scale(1.06); }
.chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.chatbot-send svg { width: 16px; height: 16px; }

@media (max-width: 480px) {
  .chatbot-panel {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 88px;
  }
  .chatbot-launcher { right: 16px; bottom: 16px; }
}
