/* app/static/css/nlquery.css */
.nlq-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 180px);
}

@media (max-width: 900px) {
  .nlq-split { grid-template-columns: 1fr; height: auto; }
}

.nlq-chat-pane, .nlq-side-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  /* Grid items default to min-width: auto, which lets long unwrapped content
     (a long SPARQL line, a wide table) grow the column instead of scrolling
     inside it — this makes the column shrinkable so overflow: auto below
     actually contains the content. */
  min-width: 0;
}

.nlq-chat-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.nlq-turns {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nlq-turn {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.nlq-turn-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  white-space: pre-wrap;
}

.nlq-turn-assistant {
  align-self: flex-start;
  background: var(--surface-hover);
  color: var(--text);
}

.nlq-turn-assistant p { margin: 0 0 8px; }
.nlq-turn-assistant p:last-child { margin-bottom: 0; }
.nlq-turn-assistant ul, .nlq-turn-assistant ol { margin: 4px 0; padding-left: 20px; }
.nlq-turn-assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: rgba(127, 127, 127, .16);
  padding: 1px 4px;
  border-radius: 4px;
}
.nlq-turn-assistant pre {
  background: rgba(127, 127, 127, .16);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
}
.nlq-turn-assistant pre code { background: none; padding: 0; }

.nlq-tool-entry {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-hover);
  border-radius: 999px;
  padding: 3px 10px;
}

.nlq-tool-entry::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  border-top-color: transparent;
  animation: nlq-spin .7s linear infinite;
}

.nlq-tool-entry.is-done::before {
  content: '\2713';
  width: auto;
  height: auto;
  border: none;
  animation: none;
  color: var(--accent);
  font-size: 11px;
  line-height: 1;
}

.nlq-tool-entry.is-clickable {
  cursor: pointer;
}

.nlq-tool-entry.is-clickable:hover {
  background: var(--accent);
  color: #fff;
}

.nlq-tool-entry.is-clickable:hover::before {
  color: #fff;
}

.nlq-thinking {
  align-self: flex-start;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-hover);
}

.nlq-thinking-dots {
  display: flex;
  gap: 4px;
}

.nlq-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: nlq-bounce 1.2s infinite ease-in-out;
}

.nlq-thinking-dots span:nth-child(2) { animation-delay: .15s; }
.nlq-thinking-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes nlq-spin {
  to { transform: rotate(360deg); }
}

@keyframes nlq-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: .5; }
  40% { transform: scale(1); opacity: 1; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nlq-ontology-block {
  align-self: flex-start;
  max-width: 90%;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text-muted);
}

.nlq-ontology-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.nlq-ontology-chunk {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.nlq-ontology-curie {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: var(--accent);
  margin-right: 4px;
}

.nlq-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.nlq-input-row textarea {
  flex: 1;
  resize: vertical;
}

.nlq-sparql-actions {
  display: flex;
  gap: 8px;
}

.nlq-sparql-editor {
  height: 220px;
  border-bottom: 1px solid var(--border);
}

.nlq-sparql-error {
  padding: 10px 20px;
  font-size: 12px;
  color: #dc2626;
  background: rgba(220, 38, 38, .08);
}

.nlq-results-wrap {
  padding: 0 20px 18px;
  overflow: auto;
  max-height: 360px;
}

.nlq-results-wrap table.data-table {
  table-layout: fixed;
}

.nlq-results-wrap table.data-table th,
.nlq-results-wrap table.data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.nlq-col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 6px;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}

.nlq-col-resizer:hover,
.nlq-col-resizer.is-resizing {
  background: var(--accent);
  opacity: .5;
}

.nlq-empty {
  padding: 14px 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* .sb2-new-btn has no rules anywhere else in the app (wiki.html's sidebar
   uses the same class and renders as an unstyled default <button> there
   too) — defined here so /queries is the first page where it actually
   looks intentional. */
.sb2-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 8px 0 6px 6px;
  border: 1px dashed var(--sb2-border);
  border-radius: 50%;
  background: transparent;
  color: var(--sb2-text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.sb2-new-btn:hover {
  background: var(--sb2-hover-bg);
  color: var(--sb2-text-active);
  border-color: var(--accent);
}

.sb2-new-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sb2-new-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.sb2-empty {
  padding: 10px 16px;
  color: var(--sb2-section);
  font-size: 12px;
}

/* .nlq-conversation-item already carries the base .sb2-item class (flex
   row, height, margin, border-radius, hover/active background+accent bar)
   — these rules only add what that base doesn't cover: the link filling
   the row, and hover-reveal action buttons overlaid on top of it. Nothing
   here should apply its own background, or it'll double up with the base
   .sb2-item:hover/.active background and look like a card nested inside
   the row instead of one flush highlighted row. */
.nlq-conversation-item {
  position: relative;
  padding-right: 4px;
}

.nlq-conversation-item .nlq-conversation-link {
  flex: 1;
  min-width: 0;
  display: block;
  color: inherit;
  text-decoration: none;
  padding-right: 48px;
}

.nlq-conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nlq-conversation-actions {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}

.nlq-conversation-item:hover .nlq-conversation-actions,
.nlq-conversation-item:focus-within .nlq-conversation-actions {
  opacity: 1;
}

.nlq-conversation-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--sb2-text);
  cursor: pointer;
  border-radius: 5px;
}

.nlq-conversation-actions button:hover {
  background: var(--sb2-active-bg);
  color: var(--sb2-text-active);
}

.nlq-conversation-actions svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nlq-conversation-title-input {
  flex: 1;
  min-width: 0;
  height: 24px;
  font-size: 13px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--sb2-bg);
  color: var(--sb2-text-active);
}
