/* ── Portfolio RAG Chat Widget ──────────────────────────────────────────────── */

#chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1a1a2e;
  border: 2px solid #e94560;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}
#chat-toggle:hover { transform: scale(1.08); }

#chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 340px;
  max-height: 480px;
  background: #16213e;
  border: 1px solid #e94560;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  font-family: inherit;
}
#chat-window.hidden { display: none; }

#chat-header {
  background: #1a1a2e;
  color: #e94560;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e94560;
}
#chat-header span {
  font-weight: 400;
  font-size: 12px;
  color: #aaa;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}

.msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}
.msg.user {
  align-self: flex-end;
  background: #e94560;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.msg.bot {
  align-self: flex-start;
  background: #0f3460;
  color: #e2e2e2;
  border-bottom-left-radius: 3px;
}
.msg.typing {
  opacity: 0.6;
  font-style: italic;
}

#chat-input-row {
  display: flex;
  border-top: 1px solid #0f3460;
  padding: 8px;
  gap: 6px;
  background: #1a1a2e;
}
#chat-input {
  flex: 1;
  background: #0f3460;
  border: 1px solid #e94560;
  border-radius: 8px;
  color: #fff;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  resize: none;
}
#chat-input::placeholder { color: #888; }

#chat-send {
  background: #e94560;
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 0 14px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
}
#chat-send:hover { background: #c73652; }
#chat-send:disabled { background: #555; cursor: not-allowed; }

/* ── Markdown inside bot messages ─────────────────────────────────────────── */
.msg.bot p { margin: 0 0 6px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot h2, .msg.bot h3, .msg.bot h4 {
  margin: 8px 0 4px;
  font-size: 14px;
  color: #e94560;
}
.msg.bot h2 { font-size: 15px; }
.msg.bot strong { color: #fff; }
.msg.bot em { font-style: italic; }
.msg.bot ul {
  margin: 4px 0;
  padding-left: 18px;
}
.msg.bot li { margin-bottom: 2px; }
.msg.bot code {
  background: rgba(255,255,255,0.1);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}
.msg.bot pre {
  background: rgba(0,0,0,0.3);
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
}
.msg.bot pre code {
  background: none;
  padding: 0;
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  #chat-window {
    width: calc(100vw - 24px);
    right: 12px;
  }
}
