/* ============================================================
   pRAG — Personal Retrieval AI for Peter Saddington
   style.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d0d0f;
  --bg-2:       #141416;
  --bg-3:       #1a1a1e;
  --bg-4:       #222228;
  --border:     #2a2a30;
  --orange:     #4f8ef7;
  --orange-dim: #3570d4;
  --text:       #eeeef2;
  --text-muted: #8888a0;
  --text-dim:   #4a4a60;
  --radius:     14px;
  --radius-sm:  8px;
  --sidebar-w:  280px;
  --info-w:     300px;
  --font:       'Inter', -apple-system, sans-serif;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ============================================================
   APP SHELL — three-column layout
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--info-w);
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   LEFT — CONTACTS SIDEBAR
   ============================================================ */
.contacts-sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* StaaS Fund logo */
.staas-logo {
  display: block;
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.staas-logo:hover { opacity: 1; }
.staas-logo-img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

.brand-block {
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.brand-p {
  color: var(--orange);
  font-style: italic;
}

.brand-rag {
  color: var(--text);
}

.brand-sub {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 3px;
}

.contacts-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 20px 8px;
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 10px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font);
  color: var(--text);
}

.contact-item:hover {
  background: var(--bg-3);
}

.contact-item.active {
  background: var(--bg-3);
  border-color: var(--border);
}

.contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
  opacity: 0.92;
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.contact-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-preview {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 16px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--orange);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  justify-content: center;
  transition: background 0.2s;
}

.sidebar-cta:hover { background: var(--orange-dim); }

/* ============================================================
   CENTER — CHAT MAIN
   ============================================================ */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.header-status {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
}

.prag-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--orange);
  border: 1px solid var(--orange);
  border-radius: 100px;
  padding: 3px 10px;
  text-transform: uppercase;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 720px;
}

.message--peter { align-self: flex-start; }
.message--user  { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  font-weight: 700;
}

.message--user .msg-avatar {
  background: var(--bg-4);
  color: var(--text-muted);
  font-size: 11px;
}

.msg-bubble {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.65;
  max-width: 600px;
  color: var(--text);
}

.message--user .msg-bubble {
  background: var(--orange);
  border-color: var(--orange);
  border-radius: 14px 4px 14px 14px;
  color: #fff;
}

.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { color: inherit; font-weight: 600; }
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin-bottom: 8px; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 10px 0 5px;
}
.msg-bubble code {
  background: var(--bg-4);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* Welcome message style */
.welcome-msg .msg-bubble {
  border-color: var(--border);
}

/* Message column wrapper */
.msg-col { display: flex; flex-direction: column; min-width: 0; }

/* Sources pill + panel */
.sources-wrapper { margin-top: 6px; }
.sources-pill {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.sources-pill:hover { background: var(--bg-2); border-color: var(--text-muted); color: var(--text); }
.sources-panel {
  margin-top: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 600px;
  font-size: 13px;
  line-height: 1.6;
}
.sources-panel.collapsed { display: none; }
.sources-panel a { color: #4f8ef7; text-decoration: none; }
.sources-panel a:hover { text-decoration: underline; }
.sources-panel ul { padding-left: 0; margin: 0; }
.sources-panel li { margin-bottom: 6px; list-style: none; }
.sources-panel p { margin: 0 0 4px; }
.sources-panel strong { font-size: 13px; }

/* Typing indicator */
.typing-wrap {
  padding: 0 28px 8px;
  flex-shrink: 0;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 14px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* Topic chips */
.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 28px 12px;
  flex-shrink: 0;
}

.topic-chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.topic-chip:hover {
  border-color: var(--orange);
  color: var(--text);
}

/* Input area */
.input-area {
  padding: 12px 28px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 140px;
  transition: border-color 0.2s;
}

.chat-input:focus { border-color: var(--orange); }
.chat-input::placeholder { color: var(--text-dim); }

.send-btn {
  width: 42px;
  height: 42px;
  background: var(--orange);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

.send-btn:hover { background: var(--orange-dim); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { background: var(--bg-4); cursor: not-allowed; opacity: 0.5; }

.input-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: center;
}

/* ============================================================
   RIGHT — INFO PANEL
   ============================================================ */
.info-panel {
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  padding: 28px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-avatar-wrap {
  display: flex;
  justify-content: center;
}

.info-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 0 18px rgba(79,142,247,0.3), 0 0 6px rgba(108,99,255,0.2);
}

.info-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.info-avatar img.home-photo {
  object-position: center 25%;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.msg-avatar.has-photo {
  overflow: hidden;
  background: none !important;
}

.info-name {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.info-title {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.info-bio {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.65;
  text-align: center;
}

.info-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-stat {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.info-stat-num {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--orange);
  line-height: 1;
}

.info-stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info-divider {
  height: 1px;
  background: var(--border);
}

.info-section-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.info-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.info-link:hover {
  background: var(--bg-3);
  color: var(--text);
}

.info-link i { color: var(--orange); font-size: 15px; }

/* Persona switcher dots */
.persona-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.persona-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  opacity: 0.6;
  border: 2px solid transparent;
  transition: opacity 0.2s, border-color 0.2s;
}

.persona-dot.active {
  opacity: 1;
  border-color: #fff;
}

.persona-dot:hover { opacity: 1; }

/* About button — right panel bottom */
.about-btn-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--orange);
  border: none;
  border-radius: 100px;
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 4px;
}
.about-btn-panel:hover { background: var(--orange-dim); }
.about-btn-panel:active { transform: scale(0.98); }
.about-btn-panel i { font-size: 16px; }

.cta-btn-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  text-decoration: none;
  margin-top: 8px;
  transition: all 0.15s;
}
.cta-btn-panel:hover { background: var(--bg-3); border-color: var(--text-muted); }
.cta-btn-panel i { font-size: 16px; }

/* About modal */
.about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.about-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.about-modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px 32px;
  max-width: 480px;
  width: calc(100% - 40px);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.about-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-4);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.about-close:hover { background: var(--border); color: var(--text); }

.about-logo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.about-tagline {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 24px;
}

.about-section {
  margin-bottom: 20px;
}
.about-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.about-section p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

.about-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.about-link-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.about-link-btn:hover { border-color: var(--orange); color: var(--text); }
.about-link-btn i { color: var(--orange); }

/* About modal divider + FAQ title */
.about-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0 20px;
}

.about-faq-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

/* FAQ accordion */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.faq-item {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.faq-header:hover { color: var(--orange); }
.faq-header i {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.25s;
  flex-shrink: 0;
}

.faq-item.open .faq-header i {
  transform: rotate(45deg);
}

.faq-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 16px;
}

.faq-item.open .faq-body {
  max-height: 600px;
  padding: 0 16px 16px;
}

.faq-body p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 8px;
}
.faq-body p:last-child { margin-bottom: 0; }
.faq-body strong { color: var(--text); }
.faq-body ul {
  padding-left: 18px;
  margin-bottom: 8px;
}
.faq-body li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 2px;
}

.faq-disclaimer {
  font-size: 11px !important;
}
.faq-disclaimer p {
  font-size: 11px;
  line-height: 1.6;
}

/* ============================================================
   MOBILE PERSONA BAR (hidden on desktop)
   ============================================================ */
.mobile-persona-bar {
  display: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  :root { --info-w: 0px; }
  .info-panel { display: none; }
  .app { grid-template-columns: var(--sidebar-w) 1fr; }
}

@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }
  .contacts-sidebar { display: none; }
  .app { grid-template-columns: 1fr; }

  /* Show persona bar on mobile */
  .mobile-persona-bar {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
    flex-shrink: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-persona-bar::-webkit-scrollbar { display: none; }

  .mobile-persona-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    font-family: var(--font);
    opacity: 0.55;
    transition: opacity 0.2s;
  }
  .mobile-persona-btn.active { opacity: 1; }

  .mobile-persona-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    border: 2px solid transparent;
    transition: border-color 0.2s;
  }
  .mobile-persona-btn.active .mobile-persona-avatar {
    border-color: #fff;
  }

  .mobile-persona-label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
  }
  .mobile-persona-btn.active .mobile-persona-label {
    color: var(--text);
  }

  /* Tighter chat padding on mobile */
  .chat-header {
    padding: 12px 16px;
  }

  .messages {
    padding: 16px 14px 8px;
    gap: 14px;
    justify-content: flex-end;
  }

  .message {
    max-width: 100%;
  }

  .msg-bubble {
    max-width: calc(100vw - 80px);
    font-size: 14px;
    padding: 10px 13px;
  }

  .typing-wrap {
    padding: 0 14px 6px;
  }

  .topic-chips {
    padding: 0 14px 10px;
    gap: 6px;
  }

  .topic-chip {
    font-size: 12px;
    padding: 6px 12px;
  }

  .input-area {
    padding: 10px 14px 16px;
  }

  .input-note {
    font-size: 10px;
  }

  .sources-panel { max-width: calc(100vw - 80px); }
}
