/* LLM KB custom styles (extends qazstack.ui tokens) */

:root {
  --accent: #6366f1;
  --accent-hover: #4f46e5;
}

/* Hero */
.hero-section {
  text-align: center;
  padding: 2.5rem 0 1.5rem;
}
.hero-section h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}
.dashboard-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
.dashboard-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

/* Provider rows */
.provider-list, .wiki-list, .entity-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.provider-row, .wiki-row, .entity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition);
}
.provider-row:hover, .wiki-row:hover, .entity-row:hover {
  background: var(--bg);
}
.provider-count, .entity-count {
  font-weight: 600;
  color: var(--accent);
}
.wiki-title { flex: 1; }

/* Sentiment bar */
.sentiment-bar {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 2rem;
  font-size: 0.8rem;
  font-weight: 600;
}
.sentiment-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  min-width: 3rem;
}
.sentiment-positive { background: var(--success); }
.sentiment-negative { background: var(--danger); }
.sentiment-neutral { background: #94a3b8; }

/* Filters */
.filters-bar {
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.filter-btn {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-btn .count {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Sources list */
.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}
.source-item {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  transition: box-shadow var(--transition);
}
.source-item:hover { box-shadow: var(--shadow-md); }
.source-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.source-title {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.source-title:hover { color: var(--accent); }
.source-excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}
.source-meta {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Source detail */
.source-detail-header { margin-bottom: 1.5rem; }
.source-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.source-body {
  line-height: 1.75;
  font-size: 1rem;
  white-space: pre-wrap;
}
.source-entities { margin-bottom: 1.5rem; }
.entity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.entity-tag {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  text-decoration: none;
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.entity-tag:hover { border-color: var(--accent); color: var(--accent); }

/* Entities grid */
.entities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.entity-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition);
}
.entity-card:hover { box-shadow: var(--shadow-md); }
.entity-card-name {
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.entity-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}
.entity-card-count { color: var(--text-muted); }

/* Badges by entity type */
.badge-person { background: #dbeafe; color: #1e40af; }
.badge-organization { background: #fef3c7; color: #92400e; }
.badge-location { background: #d1fae5; color: #065f46; }
.badge-term { background: #ede9fe; color: #5b21b6; }
.badge-sentiment-positive { background: var(--success); color: #fff; }
.badge-sentiment-negative { background: var(--danger); color: #fff; }
.badge-sentiment-neutral { background: #94a3b8; color: #fff; }

[data-theme="dark"] .badge-person { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-organization { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-location { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-term { background: #2e1065; color: #c4b5fd; }

/* Search */
.search-form { margin: 1.5rem 0; }
.search-input-group {
  display: flex;
  gap: 0.5rem;
}
.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.search-options {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  align-items: center;
  font-size: 0.9rem;
}
.input-small {
  width: 60px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.input-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

/* Search results */
.search-results { margin: 1rem 0; }
.search-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.search-result {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.result-title {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.result-title:hover { color: var(--accent); }
.result-score {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent);
}
.result-content {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}
.result-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Ask page */
.ask-form { margin: 1.5rem 0; }
.ask-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
}
.ask-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.ask-options {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  align-items: center;
  font-size: 0.9rem;
}
.ask-answer {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.ask-answer.hidden { display: none; }
.answer-text {
  line-height: 1.75;
  white-space: pre-wrap;
}
.answer-sources {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.source-chip {
  padding: 0.3rem 0.7rem;
  background: var(--bg);
  border-radius: 999px;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text-secondary);
}
.source-chip:hover { color: var(--accent); }
.answer-meta {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
}

/* Wiki */
.wiki-article { max-width: 800px; }
.wiki-header { margin-bottom: 1.5rem; }
.wiki-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.wiki-summary {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.wiki-body {
  line-height: 1.8;
  white-space: pre-wrap;
}
.wiki-related {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}
.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.related-link {
  padding: 0.3rem 0.7rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--accent);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Utilities */
.text-muted { color: var(--text-muted); }
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-info { background: #e0f2fe; color: #075985; }
.badge-secondary { background: var(--bg); color: var(--text-secondary); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
[data-theme="dark"] .badge-info { background: #0c4a6e; color: #7dd3fc; }

@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .entities-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .search-input-group { flex-direction: column; }
  .search-options, .ask-options { flex-direction: column; align-items: flex-start; }
}
