/* ===== AI Agent Knowledge Base - Style ===== */
:root {
  --bg: #0f0f14;
  --bg-secondary: #16161e;
  --bg-card: #1a1a26;
  --bg-sidebar: #12121a;
  --border: #252536;
  --text: #e2e2f0;
  --text-secondary: #9898b8;
  --text-muted: #6b6b88;
  --accent: #f43f5e;
  --accent-soft: #f43f5e22;
  --green: #10b981;
  --green-soft: #10b98122;
  --amber: #f59e0b;
  --amber-soft: #f59e0b22;
  --blue: #3b82f6;
  --blue-soft: #3b82f622;
  --purple: #8b5cf6;
  --purple-soft: #8b5cf622;
  --cyan: #06b6d4;
  --cyan-soft: #06b6d422;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h1 { font-size: 1rem; color: #fff; margin-bottom: 4px; }
.sidebar-header p { font-size: 0.78rem; color: rgba(255,255,255,0.75); }

.sidebar-nav { padding: 12px 0; flex: 1; overflow-y: auto; }

.nav-section { margin-bottom: 2px; }

.nav-section-title {
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: color 0.15s;
}
.nav-section-title:hover { color: var(--text); }
.nav-section-title .arrow {
  font-size: 0.6rem;
  transition: transform 0.2s;
  display: inline-block;
  width: 12px;
  text-align: center;
  color: var(--text-muted);
}
.nav-section-title .arrow.open { transform: rotate(90deg); color: var(--text); }

.nav-items {
  list-style: none;
  display: none;
  padding: 2px 0 6px 0;
}
.nav-items li { }
.nav-items a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px 6px 36px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.nav-items a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-items a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-items a .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.nav-items a.active .dot { background: var(--accent); }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.content-header {
  padding: 28px 40px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.content-header h1 { font-size: 1.5rem; color: var(--text); margin-top: 4px; }

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

.content-body {
  padding: 32px 40px 60px;
  max-width: 900px;
}

.content-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Typography ===== */
h2 {
  font-size: 1.35rem;
  margin: 32px 0 16px;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
h2:first-child { margin-top: 0; }
h3 {
  font-size: 1.1rem;
  margin: 24px 0 12px;
  color: var(--text);
}
h4 {
  font-size: 1rem;
  margin: 16px 0 8px;
  color: var(--text);
}
p { margin: 8px 0; color: var(--text-secondary); }
strong { color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--cyan);
}
pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 12px 0;
}
pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.88rem;
}
thead { background: var(--bg-secondary); }
th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tr:hover td { background: rgba(255,255,255,0.02); }
td:first-child, th:first-child { border-radius: 0; }

/* ===== Info Boxes ===== */
.info-box {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 0.88rem;
  line-height: 1.6;
  border-left: 4px solid var(--blue);
  background: var(--blue-soft);
}
.info-box.tip {
  border-left-color: var(--green);
  background: var(--green-soft);
}
.info-box.warning {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}
.info-box.danger {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.info-box strong { display: block; margin-bottom: 4px; }

/* ===== Cards ===== */
.subsection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin: 16px 0 24px;
}
.subsection-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.2s;
}
.subsection-card:hover { border-color: var(--text-muted); }
.subsection-card h4 { margin: 0 0 6px; font-size: 0.92rem; }
.subsection-card p { margin: 0; font-size: 0.82rem; }

/* ===== Diagrams ===== */
.diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px 0;
  text-align: center;
  font-size: 0.85rem;
}

/* ===== Comparison Grid ===== */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
.comparison-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.comparison-col h4 {
  margin-top: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.comparison-col ul {
  list-style: none;
  padding: 0;
}
.comparison-col li {
  padding: 6px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.comparison-col li::before {
  content: "•";
  color: var(--accent);
  margin-right: 8px;
}

/* ===== Flow Steps ===== */
.flow-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 12px 0;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.flow-step .num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.flow-step .step-content { flex: 1; }
.flow-step .step-content strong { display: block; margin-bottom: 2px; }
.flow-step .step-content p { margin: 0; font-size: 0.84rem; }

/* ===== Side-by-Side Code ===== */
.code-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0;
}
.code-compare pre { margin: 0; }

/* ===== KV List ===== */
.kv-list {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2px 16px;
  margin: 12px 0;
  font-size: 0.88rem;
}
.kv-list dt {
  color: var(--text);
  font-weight: 600;
  padding: 6px 0;
}
.kv-list dd {
  color: var(--text-secondary);
  padding: 6px 0;
}

/* ===== Tags/Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }

/* ===== Code Tabs ===== */
.code-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: -1px;
}
.code-tab {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
}
.code-tab.active {
  background: var(--bg-card);
  color: var(--text);
  border-bottom: 1px solid var(--bg-card);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content-body { padding: 20px 16px; }
  .content-header { padding: 20px 16px 12px; }
  .comparison-grid, .code-compare { grid-template-columns: 1fr; }
}
