/* ============================================================
   Perplexity CF Dashboard — Stylesheet
   Design: dark, minimal, terminal-inspired
   ============================================================ */

:root {
  --bg:         #0d0f12;
  --surface:    #161a1f;
  --surface-2:  #1e242c;
  --border:     #2a3340;
  --accent:     #20c0a0;
  --accent-dim: #127a65;
  --text:       #e2e8f0;
  --text-muted: #6b7a8d;
  --danger:     #e05050;
  --user-bg:    #1a2a38;
  --ai-bg:      #131a20;
  --radius:     10px;
  --font-mono:  "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  --font-sans:  "Inter", system-ui, sans-serif;
  --transition: 0.18s ease;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
}
.header__inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header__brand  { display: flex; align-items: center; gap: .6rem; font-weight: 600; letter-spacing: .02em; }
.header__logo   { width: 22px; height: 22px; color: var(--accent); }
.header__meta   { display: flex; align-items: center; gap: .75rem; }

.badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  transition: background var(--transition);
}
.status-dot--checking { background: #888; animation: pulse 1.2s infinite; }
.status-dot--ok       { background: var(--accent); }
.status-dot--error    { background: var(--danger); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Layout ─────────────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 52px);
  max-width: 1280px;
  margin: 0 auto;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  overflow-y: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
}
.card__title {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .6rem;
}

.select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .4rem .6rem;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.select:focus { border-color: var(--accent); }

.toggle-group { display: flex; gap: .4rem; }
.toggle-btn {
  flex: 1;
  padding: .4rem .6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-btn--active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

.param-label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: .6rem;
}
.input-num {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .3rem .5rem;
  width: 90px;
  outline: none;
}
input[type=range] { accent-color: var(--accent); width: 100%; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn--primary   { background: var(--accent); color: #000; }
.btn--primary:hover   { filter: brightness(1.15); }
.btn--secondary { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.btn--secondary:hover { border-color: var(--accent); color: var(--text); }
.btn--full      { width: 100%; }
.btn:disabled   { opacity: .45; cursor: not-allowed; }

/* ── Chat area ───────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar       { width: 5px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Message bubbles */
.message {
  max-width: 780px;
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  line-height: 1.65;
  word-break: break-word;
}
.message--system {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  max-width: 100%;
}
.message--user {
  align-self: flex-end;
  background: var(--user-bg);
  border: 1px solid #1e3a52;
  color: var(--text);
  white-space: pre-wrap;
}
.message--ai {
  align-self: flex-start;
  background: var(--ai-bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.message--error {
  background: #1c0f0f;
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* AI message header */
.message__header {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: .4rem;
  font-family: var(--font-mono);
  letter-spacing: .04em;
}

/* Citations */
.citations {
  margin-top: .75rem;
  padding-top: .6rem;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.citations a {
  color: var(--accent);
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.citations a:hover { text-decoration: underline; }

/* Streaming cursor */
.cursor {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink .7s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Chat form ───────────────────────────────────────────── */
.chat-form {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: .9rem 1.25rem;
  display: flex;
  gap: .75rem;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .65rem .9rem;
  font-family: var(--font-sans);
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  max-height: 140px;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 720px) {
  .main { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
