/* ═══════════════════════════════════════════════════════════
   Wiki Dashboard Panel — Styles
   ═══════════════════════════════════════════════════════════ */

/* ── Stats Bar ── */
.wiki-stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.wiki-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 12px 20px;
  min-width: 90px;
  flex: 1;
  transition: border-color 0.2s;
}

.wiki-stat:hover {
  border-color: #06b6d4;
}

.wiki-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #06b6d4;
  line-height: 1.2;
}

.wiki-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ── Three-column Layout ── */
.wiki-layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 16px;
  min-height: 560px;
}

@media (max-width: 1200px) {
  .wiki-layout {
    grid-template-columns: 240px 1fr;
  }
  .wiki-right-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .wiki-layout {
    grid-template-columns: 1fr;
  }
  .wiki-sidebar {
    max-height: 300px;
  }
}

/* ── Sidebar ── */
.wiki-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wiki-sidebar-header {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border-default);
}

.wiki-search-input {
  flex: 1;
  background: var(--bg-elevated, rgba(255,255,255,0.04));
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}

.wiki-search-input:focus {
  border-color: #06b6d4;
}

.wiki-search-input::placeholder {
  color: var(--text-muted);
}

.wiki-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.1s;
}

.wiki-action-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.wiki-action-btn:active {
  transform: translateY(0);
}

.wiki-action-btn svg {
  width: 14px;
  height: 14px;
}

/* ── Type Tabs ── */
.wiki-type-tabs {
  display: flex;
  padding: 6px 8px;
  gap: 2px;
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
}

.wiki-type-tab {
  background: none;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.wiki-type-tab:hover {
  background: rgba(6, 182, 212, 0.1);
  color: var(--text-secondary);
}

.wiki-type-tab.active {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
}

/* ── Page List ── */
.wiki-page-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.wiki-page-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.wiki-page-item:hover {
  background: rgba(6, 182, 212, 0.06);
}

.wiki-page-item.active {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
}

.wiki-page-item-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wiki-page-item-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.wiki-page-type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.wiki-page-type-badge[data-type="source"] {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.wiki-page-type-badge[data-type="entity"] {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.wiki-page-type-badge[data-type="concept"] {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.wiki-page-type-badge[data-type="analysis"] {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
}

.wiki-page-type-badge[data-type="overview"] {
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
}

.wiki-empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ── Main Viewer ── */
.wiki-main {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wiki-viewer {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.wiki-viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  color: var(--text-muted);
  text-align: center;
}

.wiki-viewer-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.wiki-viewer-empty h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.wiki-viewer-empty p {
  font-size: 0.85rem;
  margin: 0;
}

/* Page header in viewer */
.wiki-page-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-default);
}

.wiki-page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.wiki-page-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.wiki-page-tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(6, 182, 212, 0.1);
  border-radius: 4px;
  color: #06b6d4;
  font-size: 0.7rem;
}

/* Rendered markdown in viewer */
.wiki-page-body {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

.wiki-page-body h1 { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); margin: 24px 0 10px; }
.wiki-page-body h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin: 20px 0 8px; }
.wiki-page-body h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin: 16px 0 6px; }
.wiki-page-body h4 { font-size: 0.88rem; font-weight: 600; color: var(--text-secondary); margin: 14px 0 4px; }

.wiki-page-body p { margin: 0 0 12px; }
.wiki-page-body ul, .wiki-page-body ol { margin: 0 0 12px; padding-left: 24px; }
.wiki-page-body li { margin-bottom: 4px; }

.wiki-page-body blockquote {
  margin: 12px 0;
  padding: 10px 16px;
  border-left: 3px solid #06b6d4;
  background: rgba(6, 182, 212, 0.05);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
  font-style: italic;
}

.wiki-page-body code {
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.83em;
  color: #06b6d4;
}

.wiki-page-body pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  margin: 12px 0;
}

.wiki-page-body pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
}

.wiki-page-body hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 20px 0;
}

/* Wikilinks rendered as clickable spans */
.wiki-wikilink {
  color: #06b6d4;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.wiki-wikilink:hover {
  color: #22d3ee;
}

.wiki-wikilink.broken {
  color: #ef4444;
  opacity: 0.7;
}

/* ── Right Panel ── */
.wiki-right-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wiki-graph-card,
.wiki-log-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 14px;
}

.wiki-graph-card h4,
.wiki-log-card h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

#wiki-graph-canvas {
  width: 100%;
  height: 220px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.wiki-log-card {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wiki-log-list {
  flex: 1;
  overflow-y: auto;
  max-height: 260px;
}

.wiki-log-entry {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
}

.wiki-log-entry:last-child {
  border-bottom: none;
}

.wiki-log-entry-header {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 2px;
}

.wiki-log-entry-date {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
}

.wiki-log-entry-op {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}

.wiki-log-entry-op[data-op="ingest"] {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.wiki-log-entry-op[data-op="query"] {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.wiki-log-entry-op[data-op="lint"] {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
}

.wiki-log-entry-subject {
  color: var(--text-primary);
  font-weight: 500;
}

.wiki-log-entry-body {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.4;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wiki-log-empty {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
  padding: 20px 0;
}
