/* ============================================
   AI Views Styles — 智能问答 / 知识星系 / 智能报告
   Design: Palantir-inspired dark, data-dense
   ============================================ */

/* === Nav Divider === */
.nav-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 4px;
  margin-top: 8px;
}
.nav-divider span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
}
.nav-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--overlay-10);
}

/* === Common AI Layout === */
.ai-chat-container,
.ai-galaxy-container,
.ai-report-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ai-chat-header,
.ai-galaxy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
}
.ai-chat-title svg {
  color: var(--text2);
}

.ai-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.ai-btn-ghost:hover {
  background: var(--surface-raised);
  border-color: var(--overlay-10);
}

/* === Chat Messages === */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--text2);
}
.ai-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.ai-welcome-icon svg {
  color: var(--text3);
}
.ai-welcome h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text2);
}
.ai-welcome p {
  margin: 0 0 20px;
  font-size: 13px;
  max-width: 360px;
}

.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 480px;
}
.ai-suggestions button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.ai-suggestions button:hover {
  background: var(--surface-raised);
  border-color: var(--accent);
  color: var(--accent);
}

/* === Messages === */
.ai-msg {
  max-width: 80%;
  animation: aiMsgIn 0.2s ease;
}
@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg-user {
  align-self: flex-end;
}
.ai-msg-user .ai-msg-content {
  background: var(--accent);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.ai-msg-assistant {
  align-self: flex-start;
}
.ai-msg-assistant .ai-msg-content {
  background: var(--surface-raised);
  color: var(--text1);
  border-radius: 16px 16px 16px 4px;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.7;
}
.ai-msg-assistant .ai-msg-content h3,
.ai-msg-assistant .ai-msg-content h4 {
  margin: 12px 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.ai-msg-assistant .ai-msg-content h3:first-child,
.ai-msg-assistant .ai-msg-content h4:first-child {
  margin-top: 0;
}
.ai-msg-assistant .ai-msg-content li {
  margin: 2px 0;
  margin-left: 16px;
}
.ai-msg-assistant .ai-msg-content code {
  background: var(--overlay-10);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.ai-msg-assistant .ai-msg-content strong {
  font-weight: 600;
}
.ai-msg-assistant .ai-msg-content p {
  margin: 6px 0;
}
.ai-msg-assistant .ai-msg-content p:first-child { margin-top: 0; }
.ai-msg-assistant .ai-msg-content p:last-child { margin-bottom: 0; }

/* Sources */
.ai-msg-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.ai-sources-label {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
}
.ai-source-link,
.ai-source-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: rgba(79,140,255,0.10);
  color: var(--blue);
  text-decoration: none;
  transition: background 0.15s;
}
.ai-source-link:hover {
  background: rgba(79,140,255,0.16);
}

/* Typing indicator */
.ai-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: aiDot 1.4s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* === Chat Input === */
.ai-chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  transition: border-color 0.15s;
}
.ai-chat-input-wrap:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}
.ai-chat-input-wrap textarea {
  flex: 1;
  border: none;
  background: none;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 120px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text1);
}
.ai-chat-input-wrap textarea::placeholder {
  color: var(--text3);
}
.ai-send-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.ai-send-btn:hover { opacity: 0.85; }
.ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ai-chat-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 6px;
  text-align: center;
}

/* === Galaxy (event/document-centric, brainOS-inspired) === */
.gx-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}
.gx-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.gx-brand {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.gx-brand em { font-style: normal; color: var(--accent); }

.gx-filters { display: flex; gap: 4px; flex-shrink: 0; }
.gx-pill {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.gx-pill:hover { border-color: var(--overlay-10); background: var(--surface-raised); }
.gx-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.gx-search { flex: 0 1 200px; }
.gx-search input {
  width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  background: var(--surface-raised);
  color: var(--text2);
  outline: none;
  transition: border-color 0.15s;
}
.gx-search input:focus { border-color: var(--accent); background: var(--surface); }
.gx-search input::placeholder { color: var(--text3); }

.gx-stats {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.3px;
  white-space: nowrap;
  margin-left: auto;
}

.gx-body { flex: 1; position: relative; overflow: hidden; }

/* Legend — dynamic domain list */
.gx-legend {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--legend-bg);
  backdrop-filter: blur(6px);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  max-height: calc(100% - 48px);
  overflow-y: auto;
}
.gx-legend-title {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 9px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.gx-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
  line-height: 1.4;
}
.gx-legend-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
}
.gx-legend-cnt {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 10px;
  color: var(--text3);
  margin-left: auto;
}
.gx-legend-sep {
  height: 1px;
  background: var(--hover);
  margin: 4px 0;
}
.gx-diamond-icon {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 0;
  transform: rotate(45deg);
  background: #34D399;
}

.gx-canvas { width: 100%; height: 100%; }
.gx-canvas svg { width: 100%; height: 100%; display: block; }
.gx-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text3);
  font-size: 13px;
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
}

/* Detail panel — rich sections */
.gx-detail {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 300px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.40);
  border: 1px solid var(--border);
  padding: 16px;
  z-index: 10;
  max-height: calc(100% - 48px);
  overflow-y: auto;
}
.gx-detail::-webkit-scrollbar { width: 4px; }
.gx-detail::-webkit-scrollbar-thumb { background: var(--overlay-10); border-radius: 2px; }

.gx-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}
.gx-detail-breadcrumb {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.gx-detail-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  line-height: 1.35;
}
.gx-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.gx-meta-date {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 11px;
  color: var(--text2);
}
.gx-tag-domain {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.gx-detail-close {
  padding: 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text3);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gx-detail-close:hover { background: var(--hover); color: var(--text2); }

.gx-detail-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.gx-detail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.gx-detail-section h5 {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
}
.gx-detail-body {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
}

.gx-detail-nums {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.gx-detail-nums > div { text-align: center; flex: 1; }
.gx-detail-nums strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text1);
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
}
.gx-detail-nums span { font-size: 10px; color: var(--text3); letter-spacing: 0.3px; }

/* People chips */
.gx-detail-people {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.gx-person-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--hover);
  color: var(--text2);
  font-weight: 500;
}

/* Document links */
.gx-doc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text2);
  font-size: 12px;
  transition: background 0.12s;
  margin-bottom: 2px;
}
.gx-doc-link:hover { background: var(--surface-raised); }
.gx-doc-link svg { flex-shrink: 0; color: var(--text3); }
.gx-doc-link span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gx-doc-link em { font-style: normal; color: var(--text3); font-size: 10px; margin-left: 4px; }

/* Connection items with icons and relation labels */
.gx-conn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.gx-conn:last-child { border-bottom: none; }
.gx-conn-icon {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
}
.gx-conn-name {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.gx-rel-label {
  font-style: normal;
  font-weight: 400;
  font-size: 10px;
  color: var(--text3);
  margin-left: 4px;
}

.gx-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.gx-hints {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.3px;
}
.gx-controls { display: flex; align-items: center; gap: 4px; }
.gx-zoom-label {
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 10px;
  color: var(--text3);
  min-width: 36px;
  text-align: right;
  margin-right: 4px;
}
.gx-controls button {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.gx-controls button:hover { background: var(--hover); border-color: var(--overlay-10); }

/* === Reports === */
.ai-report-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 24px;
}
.ai-report-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
}
.ai-report-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(79,140,255,0.15);
  transform: translateY(-2px);
}
.ai-report-card svg {
  color: var(--text2);
  margin-bottom: 12px;
}
.ai-report-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
}
.ai-report-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
}

.ai-report-output {
  margin: 0 24px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.ai-report-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.ai-report-output-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.ai-report-body {
  padding: 20px 24px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
  max-height: 500px;
  overflow-y: auto;
}
.ai-report-body h3, .ai-report-body h4 {
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text1);
}
.ai-report-body li {
  margin: 4px 0 4px 16px;
}
.ai-report-body strong {
  font-weight: 600;
}

/* === Empty State === */
.ai-empty {
  text-align: center;
  padding: 40px;
  color: var(--text3);
  font-size: 14px;
}
