/* Portfolio RAG Chat Widget — Dark theme matching the portfolio */

/* ── Reset & Variables ────────────────────────────────────── */
.pf-chat *, .pf-chat *::before, .pf-chat *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --pf-bg: #0a0f14;
  --pf-panel: #101822;
  --pf-panel-2: #0d141d;
  --pf-text: #eef4fb;
  --pf-muted: #a9b6c6;
  --pf-line: rgba(255,255,255,.08);
  --pf-accent: #8cd0ff;
  --pf-accent-2: #b7ffd9;
  --pf-danger: #ff6b6b;
  --pf-radius: 16px;
  --pf-radius-sm: 10px;
  --pf-shadow: 0 18px 40px rgba(0,0,0,.5);
  --pf-font: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  --pf-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

/* ── Floating Button ──────────────────────────────────────── */
.pf-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #8cd0ff 0%, #b7ffd9 100%);
  color: #0a0f14;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(140,208,255,.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pf-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(140,208,255,.5);
}
.pf-chat-btn.pf-hidden { display: none; }

/* ── Chat Panel ───────────────────────────────────────────── */
.pf-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 48px);
  background: var(--pf-panel);
  border: 1px solid var(--pf-line);
  border-radius: var(--pf-radius);
  box-shadow: var(--pf-shadow);
  display: flex;
  flex-direction: column;
  font-family: var(--pf-font);
  color: var(--pf-text);
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.pf-chat-panel.pf-hidden {
  display: none;
}

/* ── Header ───────────────────────────────────────────────── */
.pf-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--pf-panel-2);
  border-bottom: 1px solid var(--pf-line);
  flex-shrink: 0;
}
.pf-chat-header-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--pf-accent);
}
.pf-chat-close {
  background: none;
  border: none;
  color: var(--pf-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.pf-chat-close:hover {
  color: var(--pf-text);
  background: rgba(255,255,255,.06);
}

/* ── Messages ─────────────────────────────────────────────── */
.pf-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pf-chat-messages::-webkit-scrollbar { width: 5px; }
.pf-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.1);
  border-radius: 4px;
}

/* Message bubbles */
.pf-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--pf-radius-sm);
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}
.pf-msg-user {
  align-self: flex-end;
  background: rgba(140,208,255,.12);
  border: 1px solid rgba(140,208,255,.15);
  color: var(--pf-text);
}
.pf-msg-assistant {
  align-self: flex-start;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--pf-line);
}
.pf-msg-error {
  align-self: center;
  background: rgba(255,107,107,.1);
  border: 1px solid rgba(255,107,107,.2);
  color: var(--pf-danger);
  font-size: 13px;
  text-align: center;
}

/* ── Sources strip ────────────────────────────────────────── */
.pf-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.pf-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(140,208,255,.08);
  border: 1px solid rgba(140,208,255,.12);
  border-radius: 20px;
  font-size: 11px;
  color: var(--pf-accent);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-source-chip:hover {
  background: rgba(140,208,255,.15);
  border-color: rgba(140,208,255,.25);
}
.pf-source-score {
  color: var(--pf-accent-2);
  font-family: var(--pf-mono);
  font-size: 10px;
}

/* ── Source detail panel (X-ray) ──────────────────────────── */
.pf-source-detail {
  margin-top: 8px;
  padding: 12px;
  background: var(--pf-panel-2);
  border: 1px solid var(--pf-line);
  border-radius: var(--pf-radius-sm);
  font-size: 12px;
  line-height: 1.5;
  animation: pf-slide-in 0.2s ease;
}
@keyframes pf-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.pf-source-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.pf-source-detail-path {
  color: var(--pf-accent);
  font-weight: 600;
  font-size: 12px;
}
.pf-source-detail-score {
  color: var(--pf-accent-2);
  font-family: var(--pf-mono);
  font-size: 11px;
}
.pf-source-detail-text {
  color: var(--pf-muted);
  font-family: var(--pf-mono);
  font-size: 11.5px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(0,0,0,.2);
  border-radius: 6px;
  margin-bottom: 8px;
}
.pf-source-detail-link {
  font-size: 11px;
}
.pf-source-detail-link a {
  color: var(--pf-accent);
  text-decoration: underline;
}

/* ── Typing indicator ─────────────────────────────────────── */
.pf-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
}
.pf-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pf-muted);
  animation: pf-bounce 1.2s infinite;
}
.pf-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.pf-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes pf-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input area ───────────────────────────────────────────── */
.pf-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--pf-line);
  background: var(--pf-panel-2);
  flex-shrink: 0;
}
.pf-chat-input {
  flex: 1;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--pf-line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: var(--pf-font);
  color: var(--pf-text);
  outline: none;
  resize: none;
  max-height: 80px;
  transition: border-color 0.15s;
}
.pf-chat-input::placeholder { color: var(--pf-muted); opacity: 0.6; }
.pf-chat-input:focus { border-color: rgba(140,208,255,.3); }
.pf-chat-send {
  background: linear-gradient(135deg, #8cd0ff, #b7ffd9);
  border: none;
  border-radius: 10px;
  color: #0a0f14;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.pf-chat-send:hover { opacity: 0.9; }
.pf-chat-send:active { transform: scale(0.96); }
.pf-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Footer disclaimer ────────────────────────────────────── */
.pf-chat-footer {
  padding: 8px 14px;
  text-align: center;
  font-size: 10.5px;
  color: var(--pf-muted);
  opacity: 0.7;
  border-top: 1px solid var(--pf-line);
  flex-shrink: 0;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .pf-chat-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .pf-chat-btn {
    bottom: 16px;
    right: 16px;
  }
}
