:root {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1f2933;
  background-color: #f7f8fb;
  --panel-bg: #ffffff;
  --panel-border: #e3e8ef;
  --primary: #2f80ed;
  --danger: #eb5757;
  --warning: #f2994a;
  --success: #27ae60;
  --muted: #9aa5b1;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.page-header {
  padding: 16px 32px 8px;
}

.breadcrumb {
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.page-header h1 {
  margin: 4px 0 0;
  font-size: 32px;
  font-weight: 600;
}

.control-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 12px 32px 8px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.path-finder-group {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 16px;
}

.path-finder-group input {
  min-width: 180px;
}

.search-group input {
  width: 260px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  outline: none;
  transition: border-color 0.2s ease;
  text-align: left;
}

.search-group input::placeholder {
  text-align: left;
}

.search-group input:focus {
  border-color: var(--primary);
}

button {
  border: none;
  border-radius: 999px;
  padding: 9px 20px;
  cursor: pointer;
  font-weight: 500;
  background: #edf2f7;
  color: #1f2933;
  transition: background 0.2s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

button.primary {
  background: var(--primary);
  color: #fff;
}

button:active {
  transform: scale(0.98);
}

.status-badge {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--primary);
  background: rgba(47, 128, 237, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-left: auto;
}

.workspace {
  display: flex;
  gap: 16px;
  padding: 12px 32px 32px;
  align-items: flex-start;
}

.entity-panel {
  width: 360px;
  background: var(--panel-bg);
  border-radius: 18px;
  border: 1px solid var(--panel-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 640px;
}

.panel-toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f0f4ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tab-btn {
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
  border: 1px solid var(--panel-border);
  background: #fafbff;
  font-size: 13px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tab-btn strong {
  display: block;
  font-size: 15px;
  text-align: center;
  width: 100%;
}

.tab-btn.active {
  border-color: transparent;
  color: #fff;
}

.entity-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--panel-border);
}

.table-header .column {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
}

.table-header .column.name-col {
  justify-content: flex-start;
  text-align: left;
}

.table-header .column.action-col {
  justify-content: center;
  text-align: center;
  flex: 0 0 auto;
  min-width: 60px;
}

.table-body {
  flex: 1;
  overflow-y: auto;
  max-height: 100%;
}

.table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  gap: 16px; /* 增加整体间距 */
  min-height: 44px;
}

.table-row:last-child {
  border-bottom: none;
}

.row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  margin-right: 8px; /* 增加与右侧眼睛图标的间距 */
}

.row-main label {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  cursor: pointer;
  justify-content: flex-start;
}

.row-main span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  line-height: 1.4;
}

.badge {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 20px;
  font-weight: 500;
  margin-left: 4px; /* 与文字名称的间距 */
  flex-shrink: 0; /* 防止徽章被压缩 */
}

.action-btn {
  background: none;
  color: var(--muted);
  padding: 0;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex-shrink: 0; /* 防止眼睛图标被压缩 */
  margin-left: auto; /* 确保眼睛图标靠右 */
}

.action-btn:hover {
  color: var(--primary);
}

.graph-panel {
  flex: 1;
  background: var(--panel-bg);
  border-radius: 24px;
  border: 1px solid var(--panel-border);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.graph-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.graph-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pulse-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 8px 20px rgba(245, 87, 108, 0.3);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
}

.headline {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: #4b5563;
  text-align: center;
}

.legend-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.graph-container {
  position: relative;
  flex: 1;
  margin-top: 20px;
  border-radius: 24px;
  background: radial-gradient(circle at top, #ffffff 0%, #f5f7fb 65%, #edf1f7 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  overflow: hidden;
  min-height: 520px;
}

#graphCanvas {
  width: 100%;
  height: 100%;
  min-height: 520px;
  cursor: grab;
}

#graphCanvas.is-panning {
  cursor: grabbing;
}

.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(21, 24, 31, 0.9);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.4;
  max-width: 240px;
  backdrop-filter: blur(4px);
}

.graph-tooltip.hidden,
.empty-state.hidden {
  display: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
}

.highlight {
  background: rgba(47, 128, 237, 0.08);
}

/* 节点信息弹窗样式 */
.node-info-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  pointer-events: none;
  opacity: 1;
}

.node-info-modal.hidden {
  display: none !important;
  opacity: 0;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  pointer-events: all;
}

.modal-content {
  position: relative;
  background: var(--panel-bg);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  pointer-events: all;
  overflow: hidden;
}

/* 搜索时的双弹窗布局：节点信息在左，子图在右，平行放置 */
#nodeInfoModal .modal-overlay,
#searchSubgraphModal .modal-overlay {
  /* 不再使用各自的全屏遮罩，避免互相覆盖 */
  display: none;
}

#nodeInfoModal .modal-content {
  position: fixed;
  top: 72px;
  left: 40px;
  max-width: 420px;
  width: 26vw;
  min-width: 360px;
}

#searchSubgraphModal .modal-content {
  position: fixed;
  top: 72px;
  right: 40px;
  max-width: 620px;
  width: 40vw;
  min-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--panel-border);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #1f2933;
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: #f0f4ff;
  color: var(--primary);
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.modal-close-btn:hover {
  background: #e0e8ff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.node-info-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--panel-border);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
  min-width: 120px;
  flex-shrink: 0;
}

.info-value {
  flex: 1;
  color: #1f2933;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.type-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}

/* 路径查找输入框组样式 */
.path-finder-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-left: 0;
}

.path-finder-group input {
  min-width: 150px;
  max-width: 180px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  outline: none;
  transition: border-color 0.2s ease;
  text-align: left;
}

.path-finder-group input::placeholder {
  text-align: left;
}

.path-finder-group input:focus {
  border-color: var(--primary);
}

.path-finder-group button {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-width: max-content !important;
  width: auto !important;
  padding: 9px 20px !important;
  display: inline-flex !important;
}

.qa-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 0;
}

.qa-group button {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-width: max-content !important;
  padding: 9px 20px !important;
}

.qa-group input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  outline: none;
  transition: border-color 0.2s ease;
}

.qa-group input:focus {
  border-color: var(--primary);
}

.qa-answer {
  font-size: 13px;
  color: #1f2933;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 12px;
  max-width: 560px;
  line-height: 1.4;
}

/* QA modal */
.qa-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qa-modal-input {
  display: flex;
  gap: 10px;
}

.qa-modal-input input {
  flex: 1;
}

.qa-modal-answer {
  max-height: 360px;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  max-width: none; /* 允许在弹窗内占满宽度 */
  width: 100%;
}

/* 路径弹窗样式 */
.path-modal {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 1;
}

.path-modal.hidden {
  display: none !important;
  opacity: 0;
}

.path-modal-content {
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
}

.path-summary {
  padding: 16px 24px;
  background: #f0f4ff;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #1f2933;
}

.path-summary strong {
  color: var(--primary);
  font-size: 16px;
}

.no-paths {
  padding: 40px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.paths-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(85vh - 200px);
  overflow-y: auto;
  padding-right: 8px;
}

.path-item {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  background: var(--panel-bg);
}

.path-header {
  font-weight: 600;
  font-size: 14px;
  color: #1f2933;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.path-nodes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.path-node {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f8fafc;
  border-left: 3px solid;
  border-radius: 6px;
  font-size: 13px;
}

/* QA 弹窗优化样式 */
#qaModal .modal-content {
  max-width: 960px; /* 放大约三分之一 */
  width: 96%;
  border-radius: 20px;
  background: linear-gradient(180deg, #f9fbff 0%, #ffffff 100%);
}

.qa-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fbff;
}

.qa-modal-input {
  display: flex;
  gap: 10px;
  align-items: center;
}

.qa-modal-input input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d9e3f5;
  background: #ffffff;
  font-size: 14px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.qa-modal-input input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.12);
  outline: none;
}

#qaBtn.primary {
  min-width: 88px;
}

#clearQaBtn {
  min-width: 76px;
  background: #f3f6fb;
}

.qa-modal-answer {
  max-height: 420px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e3e8ef;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.qa-bubble {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: #f5f7fb;
  border: 1px solid #e5e9f2;
}

.qa-bubble.assistant {
  background: #eef6ff;
  border-color: #d6e7ff;
}

.qa-bubble .qa-role {
  font-weight: 700;
  color: #1f2933;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  min-width: 44px; /* 固定宽度，确保左右对齐 */
}

.qa-bubble .qa-content {
  font-size: 14px;
  color: #1f2933;
  line-height: 1.55;
  font-weight: 700;
}

.qa-disclaimer {
  grid-column: 2;
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
  margin-top: 6px;
  padding: 6px 10px;
  background: #fff9e6;
  border: 1px solid #ffd966;
  border-radius: 6px;
  font-weight: 400;
  align-self: start;
}

.qa-error {
  color: #d14343;
  background: #fff5f5;
  border: 1px solid #f2c9c9;
  padding: 10px 12px;
  border-radius: 10px;
}

@media (max-width: 720px) {
  .qa-modal-input {
    flex-direction: column;
    align-items: stretch;
  }
  #qaBtn,
  #clearQaBtn {
    width: 100%;
  }
}

.path-node i {
  font-size: 12px;
}

.path-node .node-name {
  font-weight: 500;
  color: #1f2933;
}

.path-node .node-id {
  color: #64748b;
  font-size: 11px;
}

.path-arrow {
  color: #94a3b8;
  font-size: 18px;
  font-weight: 600;
  margin: 0 4px;
}

@media (max-width: 1100px) {
  .workspace {
    flex-direction: column;
  }

  .entity-panel {
    width: 100%;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .info-row {
    flex-direction: column;
    gap: 4px;
  }

  .info-label {
    min-width: auto;
  }
}

