/* ===== KNOWLEDGE GRAPH MODULE ===== */

#knowledgeGraphOverlay {
  z-index: 1100;
}

.kg-modal {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  background: var(--main-bg);
  overflow: hidden;
  margin: 0;
}

/* ── Header ── */
.kg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  flex-shrink: 0;
  height: 56px;
}

.kg-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
}

.kg-stats {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--main-bg);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.kg-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kg-hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ── Body / SVG canvas ── */
.kg-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--main-bg);
}

.kg-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Empty state ── */
.kg-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.kg-empty-icon {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

.kg-empty p {
  font-size: 14px;
  margin: 0;
}

.kg-empty small {
  font-size: 12px;
  opacity: 0.7;
}

/* ── Loading state ── */
.kg-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.kg-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: kg-spin 0.7s linear infinite;
}

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

/* ── Graph elements ── */
.kg-links line {
  stroke: var(--border);
  stroke-opacity: 0.6;
  stroke-width: 1px;
}

.kg-node {
  cursor: pointer;
}

.kg-node circle {
  stroke: var(--card-bg);
  stroke-width: 2px;
  transition: stroke-width 0.15s, filter 0.15s;
}

.kg-node:hover circle {
  stroke: var(--primary);
  stroke-width: 2.5px;
  filter: brightness(1.1);
}

.kg-label {
  font-size: 10px;
  fill: var(--text-muted);
  pointer-events: none;
  user-select: none;
}

/* ── Pass 2: Neighborhood highlight ── */
.kg-node--dimmed circle {
  opacity: 0.1;
  transition: opacity 0.15s;
}

.kg-node--dimmed text {
  opacity: 0.1;
  transition: opacity 0.15s;
}

.kg-node--highlighted circle {
  filter: brightness(1.2);
  stroke-width: 2.5px;
}

.kg-links line.kg-link--dimmed {
  stroke-opacity: 0.04 !important;
  transition: stroke-opacity 0.15s;
}

.kg-links line.kg-link--highlighted {
  stroke-opacity: 1 !important;
  stroke-width: 1.5px;
}

/* ── Pass 2: Project legend ── */
.kg-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  pointer-events: none;
  max-height: 40vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kg-legend-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.kg-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kg-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kg-legend-name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Dark mode overrides ── */
.dark-mode .kg-links line {
  stroke: #334155;
  stroke-opacity: 0.7;
}

.dark-mode .kg-node circle {
  stroke: #0f172a;
}

.dark-mode .kg-label {
  fill: #94a3b8;
}

.dark-mode .kg-stats {
  background: #0f172a;
}
