/* OpenClaw Observatory v2 - 世界级设计系统 */
/* 灵感: Linear.app + Vercel Dashboard */

:root {
  --bg-primary: #0a0a0b;
  --bg-secondary: #111113;
  --bg-card: #18181b;
  --bg-hover: #1f1f23;
  --border: #27272a;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --blue: #3b82f6;
  --purple: #a855f7;
  --orange: #f97316;
  --cyan: #06b6d4;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "Fira Code", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === 侧边导航 === */
.sidebar {
  width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 24px;
}
.logo-icon { font-size: 24px; color: var(--accent); }
.logo-text-wrap { display: flex; flex-direction: column; line-height: 1.25; }
.logo-text-main { font-size: 19px; font-weight: 700; letter-spacing: -0.5px; background: linear-gradient(135deg, var(--accent), var(--purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo-text-sub { font-size: 12px; font-weight: 500; color: var(--text-secondary); letter-spacing: 1px; }
.nav-links { list-style: none; flex: 1; }
.nav-links li { margin-bottom: 2px; }
.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
}
.nav-links a:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-links a.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon { font-size: 16px; }
.nav-footer { padding: 12px; border-top: 1px solid var(--border); }
.version { font-size: 11px; color: var(--text-muted); }

/* === 主内容区 === */
.content {
  flex: 1;
  margin-left: 220px;
  padding: 32px;
  max-width: 1200px;
}

/* === 页头 === */
.page-header { margin-bottom: 32px; }
.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.page-header .subtitle { color: var(--text-muted); font-size: 14px; }

/* === 段位制理解度 === */
.rank-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  text-align: center;
}
.rank-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.rank-bar-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 12px;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  transition: width 0.8s ease;
}
.rank-name {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.rank-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.rank-stat {
  font-size: 13px;
  color: var(--text-muted);
}
.rank-suggestion {
  margin-top: 16px;
  padding: 10px 16px;
  background: var(--accent-glow);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--accent);
  display: inline-block;
}

/* === 卡片网格 === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s;
}
.card:hover { border-color: #3f3f46; }
.card-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.card-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -1px;
}
.card-detail {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === 健康度指标 === */
.health-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.health-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.health-dot.yellow { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.health-dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.health-info h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.health-info .desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* === 状态灯 === */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-warning { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.status-error { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-idle { background: var(--text-muted); }
.status-stale { background: var(--yellow); }
.status-pending { background: var(--yellow); animation: pulse 2s infinite; }
.status-unknown { background: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* === 活动流 === */
.activity-feed {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}
.activity-feed h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.feed-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.feed-item:last-child { border-bottom: none; }
.feed-time {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  width: 45px;
  flex-shrink: 0;
}
.feed-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.feed-icon.brain { background: var(--accent-glow); color: var(--accent); }
.feed-icon.link { background: rgba(168,85,247,0.15); color: var(--purple); }
.feed-icon.arrow-up { background: var(--green-bg); color: var(--green); }
.feed-icon.collect { background: var(--yellow-bg); color: var(--yellow); }
.feed-text { color: var(--text-secondary); }
.feed-detail {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

/* === 快速操作 === */
.quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.quick-btn {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.quick-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* === 类型标签 === */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-right: 4px;
}
.tag-belief { background: rgba(239,68,68,0.15); color: #f87171; }
.tag-decision { background: rgba(59,130,246,0.15); color: #60a5fa; }
.tag-lesson { background: rgba(34,197,94,0.15); color: #4ade80; }
.tag-shift { background: rgba(168,85,247,0.15); color: #c084fc; }
.tag-user_preference { background: rgba(249,115,22,0.15); color: #fb923c; }
.tag-fact { background: rgba(113,113,122,0.15); color: #a1a1aa; }
.tag-discovery { background: rgba(234,179,8,0.15); color: #facc15; }
.tag-system_rule { background: rgba(99,102,241,0.15); color: #818cf8; }
.tag-task_done, .tag-task_complete { background: rgba(34,197,94,0.1); color: #86efac; }
.tag-question { background: rgba(6,182,212,0.15); color: #67e8f9; }

/* === 分布条 === */
.dist-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dist-label {
  width: 80px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  text-align: right;
}
.dist-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.dist-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.dist-count {
  width: 40px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  text-align: right;
  flex-shrink: 0;
}

/* === 时间线 === */
.timeline {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}
.timeline h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.timeline-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.timeline-row:last-child { border-bottom: none; }
.timeline-date {
  color: var(--text-muted);
  width: 60px;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 12px;
}
.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
  flex-shrink: 0;
}
.timeline-content {
  color: var(--text-secondary);
  line-height: 1.5;
}

/* === 记忆浏览器 === */
.explorer-layout { display: flex; gap: 24px; }
.filter-panel { width: 220px; flex-shrink: 0; }
.filter-group { margin-bottom: 16px; }
.filter-group label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.filter-group select, .filter-group input[type="text"], .filter-group input[type="date"] {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.filter-group select:focus, .filter-group input:focus {
  border-color: var(--accent);
}
.date-shortcuts {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.date-shortcut {
  padding: 3px 8px;
  font-size: 11px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.1s;
}
.date-shortcut:hover, .date-shortcut.active {
  border-color: var(--accent);
  color: var(--accent);
}
.entry-list { flex: 1; }
.entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
  transition: all 0.15s;
}
.entry-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.entry-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.entry-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.entry-footer {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  align-items: center;
}
.entry-score { font-family: var(--mono); color: var(--accent); }
.entry-links { color: var(--purple); }

/* 管理按钮 */
.entry-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.action-btn {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.action-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.action-btn.confirm { border-color: var(--green); color: var(--green); }
.action-btn.confirm:hover { background: var(--green-bg); }
.action-btn.archive { border-color: var(--yellow); color: var(--yellow); }
.action-btn.archive:hover { background: var(--yellow-bg); }
.action-btn.delete { border-color: var(--red); color: var(--red); }
.action-btn.delete:hover { background: var(--red-bg); }
.type-select {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  outline: none;
}

/* 批量操作 */
.batch-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--accent);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.batch-bar.show { display: flex; }
.batch-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: white;
  cursor: pointer;
}
.batch-btn:hover { background: rgba(255,255,255,0.1); }
.entry-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* === 知识图谱 === */
#graph-canvas {
  width: 100%;
  height: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.graph-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-muted);
  align-items: center;
}
.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.graph-detail-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 16px;
}

/* === 架构全景 === */
.arch-flow {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  overflow-x: auto;
}
.arch-layer-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 8px;
}
.arch-layer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.arch-layer-name {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.arch-layer-stat {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.arch-components {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.arch-comp {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 160px;
  transition: all 0.2s;
}
.arch-comp:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.arch-comp-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}
.arch-comp-detail {
  font-size: 11px;
  color: var(--text-muted);
}
.arch-comp-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 2px;
}
.arch-arrow {
  text-align: center;
  padding: 8px 0;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.arch-arrow-line {
  width: 2px;
  height: 20px;
  background: linear-gradient(to bottom, var(--accent), var(--border));
}
.arch-arrow-label {
  font-size: 11px;
  color: var(--accent);
  font-family: var(--mono);
}

/* === 测试台 === */
.test-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
}
.test-score-big {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -2px;
  margin-bottom: 4px;
}
.test-score-big.good { color: var(--green); }
.test-score-big.mid { color: var(--yellow); }
.test-score-big.bad { color: var(--red); }
.test-label {
  font-size: 14px;
  color: var(--text-muted);
}
.test-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.test-question {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
}
.test-score-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.test-score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.test-keywords {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kw-hit { color: var(--green); }
.kw-miss { color: var(--red); text-decoration: line-through; }
.test-hits {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.test-hit-item {
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.test-hit-item:last-child { border-bottom: none; }

/* === 骨架屏 === */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-title { height: 24px; margin-bottom: 12px; width: 40%; }
.skeleton-card { height: 80px; margin-bottom: 12px; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === 加载状态 === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === 响应式（手机端）=== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    height: 64px;
    flex-direction: row;
    padding: 0 4px;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
  }
  .logo, .nav-footer { display: none; }
  .nav-links {
    display: flex;
    width: 100%;
    justify-content: space-around;
    align-items: center;
  }
  .nav-links li { margin: 0; }
  .nav-links a {
    flex-direction: column;
    font-size: 10px;
    gap: 2px;
    padding: 8px 4px;
  }
  .nav-label { display: block; font-size: 9px; }
  .content {
    margin-left: 0;
    margin-bottom: 64px;
    padding: 16px;
  }
  .card-grid, [style*="grid-template-columns:repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .health-bar { grid-template-columns: 1fr; }
  .explorer-layout { flex-direction: column; }
  .filter-panel { width: 100%; }
  .rank-name { font-size: 22px; }
  .quick-actions { flex-direction: column; }
  #graph-canvas { height: 400px; }
  .arch-components { flex-direction: column; }
  .graph-legend { flex-direction: column; gap: 8px; }
}
