/* app/static/styles/site.css */
/*
Refactor note:
- Style real blockquotes for the RAG Query results, with a left rule and subtle background.
- Add an attribution band style under the quote for author/work/section/score/source.
*/

:root {
  --bg: #0f1115;
  --surface: #10131a;
  --surface-strong: #171923;
  --panel: #171923;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --brand: #6ee7b7;
  --brand-deep: #58c79d;
  --accent: #60a5fa;
  --border: #2a2f3a;
  --shadow: none;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.container { max-width: 1220px; margin: 0 auto; padding: 16px; }

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.nav a { color: var(--text); text-decoration: none; margin-left: 16px; }
.nav a:hover { color: var(--accent); }

.site-footer {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.muted { color: var(--muted); }

.prewrap {
  white-space: pre-wrap;
  background: var(--panel);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.chat { display: grid; grid-template-rows: 1fr auto auto; gap: 12px; height: calc(100vh - 180px); }
.chat-log { overflow-y: auto; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.chat-form { display: flex; gap: 8px; }
.chat-input,
.filter input,
.filter select,
.filter button,
.rag-control input,
.rag-control select {
  font-family: inherit;
}

.chat-input {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b0d12;
  color: var(--text);
}

.chat-send {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #0b0d12;
  font-weight: 600;
  cursor: pointer;
}

.msg { display: flex; margin-bottom: 10px; }
.msg .bubble { padding: 10px 12px; border-radius: 12px; max-width: 75%; border: 1px solid var(--border); white-space: pre-wrap; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: #0b0d12; }
.msg.bot .bubble { background: #10131a; }

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: transparent;
}

.catalog-table th,
.catalog-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: left;
}

.catalog-table th {
  color: var(--text);
}

.catalog-table a { color: var(--accent); text-decoration: none; }
.catalog-table a:hover { text-decoration: underline; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* === New: RAG quote presentation === */
.quote-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  background: var(--panel);
}

.quote-block {
  margin: 0 0 8px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--accent);
  background: rgba(255,255,255,0.02);
  line-height: 1.6;
}

.quote-attrib {
  color: var(--muted);
  font-size: 0.95rem;
}

.quote-attrib a {
  color: var(--accent);
  text-decoration: none;
}

.quote-attrib a:hover {
  text-decoration: underline;
}



.filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter input,
.filter select,
.filter button {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0b0d12;
  color: var(--text);
}

.filter button {
  background: var(--accent);
  color: #0b0d12;
  font-weight: 600;
  cursor: pointer;
}

.quote-context {
  margin-top: 6px;
  padding: 8px 12px;
  border-left: 3px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--muted);
  max-height: 420px;
  overflow-y: auto;
}

.quote-context-inner {
  display: grid;
  gap: 8px;
}

.ctx-group {
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

.ctx-group-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.ctx-sentence {
  margin: 0 0 2px 0;
  font-size: 0.95rem;
}

.ctx-before .ctx-sentence,
.ctx-after .ctx-sentence {
  color: var(--muted);
}

.ctx-center .ctx-sentence {
  background: rgba(96, 165, 250, 0.15); /* accent-ish */
  border-radius: 4px;
  padding: 4px 6px;
  color: var(--text);
}

.rag-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.rag-page-shell {
  display: grid;
  gap: 14px;
}

.rag-query-shell {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
}

.rag-query-main {
  display: grid;
  gap: 8px;
}

.rag-textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  line-height: 1.5;
}

.rag-query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.rag-query-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rag-sidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  padding: 12px;
}

.rag-filter-form {
  display: grid;
  gap: 10px;
}

.rag-side-card {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}

.rag-side-card h3 {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
}

.rag-list-card {
  border: 1px solid var(--border);
  background: #10131a;
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.rag-list-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0b0d12;
  padding: 6px;
  display: grid;
  gap: 6px;
}

.rag-list-text {
  font-size: 0.86rem;
  line-height: 1.3;
  color: var(--text);
}

.rag-list-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rag-list-empty {
  font-size: 0.86rem;
  color: var(--muted);
}

.rag-control {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.rag-control input,
.rag-control select,
.rag-control textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.rag-control input[type='range'] {
  width: 100%;
}

.rag-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rag-row > * {
  min-width: 0;
}

.rag-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #10131a;
}

.rag-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.rag-panel-inner {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.rag-panel h3 {
  margin: 0;
  font-size: 0.9rem;
}

.rag-checklist {
  max-height: 220px;
  overflow-y: auto;
}

.rag-check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.rag-check-input {
  margin-top: 2px;
}

.rag-check-text {
  line-height: 1.25;
}

.rag-hidden {
  display: none;
}

.rag-check {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ctx-nav-wrap {
  display: flex;
}

.ctx-nav-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.quote-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.quote-btn {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.ctx-sentence-actionable {
  cursor: pointer;
}

.ctx-sentence-actionable:hover {
  background: rgba(96, 165, 250, 0.08);
  border-radius: 4px;
}

.rag-main {
  min-width: 0;
}

.rag-status,
.rag-usage {
  margin-bottom: 10px;
}

.rag-filter-toggle {
  display: none;
}




.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.nav a {
  margin-left: 0; /* override old margin-left */
  padding: 6px 8px;
  border-radius: 8px;
}

.nav a:hover {
  background: rgba(96, 165, 250, 0.12);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}

.footer-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.footer-links {
  display: grid;
  gap: 6px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-note {
  max-width: 420px;
  line-height: 1.6;
}

.section-intro {
  display: grid;
  gap: 8px;
}

.section-intro h1 {
  margin: 0;
}

.section-intro-tight {
  margin-bottom: 12px;
}

.page-shell {
  display: grid;
  gap: 20px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.feature-card,
.callout-panel {
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.feature-card h2,
.callout-panel h2 {
  margin-top: 0;
  color: var(--brand);
}

.feature-card p,
.callout-panel p,
.coming-soon-list {
  margin-bottom: 0;
  line-height: 1.6;
}

.callout-panel.soft {
  background: #131722;
}

.coming-soon-list {
  padding-left: 20px;
}

@media (max-width: 860px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .feature-grid,
  .rag-layout {
    grid-template-columns: 1fr;
  }

  .rag-query-row {
    grid-template-columns: 1fr 1fr;
  }

  .rag-query-actions {
    grid-column: 1 / -1;
  }

  .rag-filter-toggle {
    display: inline-flex;
  }

  .rag-sidebar {
    display: none;
    position: static;
    max-height: none;
  }

  .rag-sidebar.open {
    display: block;
  }

  .rag-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 12px;
  }

  .nav {
    gap: 8px;
  }

  .filter {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter input,
  .filter select,
  .filter button {
    width: 100%;
  }

  .rag-query-row {
    grid-template-columns: 1fr;
  }

  .rag-query-actions {
    grid-column: auto;
  }

  .chat-send {
    width: 100%;
    justify-content: center;
  }
}
