/* ============================================
   ThreatMeld Docs — Premium Dark Theme
   ============================================ */

:root {
  --bg-primary: #0a0b0f;
  --bg-secondary: #111318;
  --bg-tertiary: #181a22;
  --bg-elevated: #1e2028;
  --bg-hover: #252730;
  --bg-active: #2a2d38;
  --border-subtle: #1e2028;
  --border-default: #2a2d38;
  --border-emphasis: #363944;
  --text-primary: #e8eaed;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;
  --text-link: #818cf8;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --accent-glow-strong: rgba(99, 102, 241, 0.25);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --code-bg: #161822;
  --sidebar-width: 280px;
  --toc-width: 220px;
  --topbar-height: 60px;
  --content-max-width: 820px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 15px;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-emphasis); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ---- Top Bar ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-height);
  background: rgba(10, 11, 15, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-center { flex: 1; max-width: 480px; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.sidebar-toggle {
  display: none; background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 4px; border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }

.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-text { font-weight: 700; font-size: 17px; color: var(--text-primary); white-space: nowrap; }
.logo-docs { color: var(--accent-primary); font-weight: 600; }

.btn-app {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 16px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff; font-size: 13px; font-weight: 600; text-decoration: none;
  transition: var(--transition); white-space: nowrap;
}
.btn-app:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 15px var(--accent-glow-strong); }

/* ---- Search ---- */
.search-wrapper {
  position: relative; display: flex; align-items: center;
  background: var(--bg-tertiary); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 0 12px; transition: var(--transition);
}
.search-wrapper:focus-within {
  border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-icon { color: var(--text-tertiary); flex-shrink: 0; }
#searchInput {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-family: var(--font-sans);
  font-size: 14px; padding: 8px 8px; min-width: 0;
}
#searchInput::placeholder { color: var(--text-tertiary); }
.search-kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 6px;
  background: var(--bg-elevated); border: 1px solid var(--border-default);
  border-radius: 4px; color: var(--text-tertiary); flex-shrink: 0;
}
.search-results {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  max-height: 400px; overflow-y: auto; z-index: 200;
}
.search-results.active { display: block; }
.search-result-item {
  display: block; padding: 12px 16px; text-decoration: none;
  border-bottom: 1px solid var(--border-subtle); cursor: pointer;
  transition: var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: var(--bg-hover); }
.search-result-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.search-result-section { font-size: 12px; color: var(--accent-primary); }
.search-result-snippet { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.search-result-snippet mark { background: var(--accent-glow-strong); color: var(--accent-primary); border-radius: 2px; padding: 0 2px; }
.search-no-results { padding: 24px 16px; text-align: center; color: var(--text-tertiary); font-size: 14px; }

/* ---- Sidebar ---- */
.sidebar {
  position: fixed; top: var(--topbar-height); left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto; padding: 20px 0; z-index: 90;
  transition: transform 0.3s ease;
}
.sidebar-nav { padding: 0 12px; }

.nav-section { margin-bottom: 8px; }
.nav-section-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-tertiary); cursor: pointer;
  border-radius: var(--radius-sm); transition: var(--transition);
  user-select: none;
}
.nav-section-title:hover { color: var(--text-secondary); background: var(--bg-hover); }
.nav-section-title .nav-chevron {
  transition: transform 0.2s ease; width: 16px; height: 16px;
}
.nav-section.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-section.collapsed .nav-section-items { display: none; }

.nav-section-items { padding: 2px 0; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 20px; font-size: 14px; color: var(--text-secondary);
  text-decoration: none; border-radius: var(--radius-sm);
  transition: var(--transition); cursor: pointer;
  border-left: 2px solid transparent; margin-left: 8px;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-item.active {
  color: var(--accent-primary); background: var(--accent-glow);
  border-left-color: var(--accent-primary); font-weight: 500;
}
.nav-item .nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }

/* ---- Sidebar Overlay ---- */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 85;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  display: flex; min-height: calc(100vh - var(--topbar-height));
}
.content-wrapper {
  flex: 1; min-width: 0;
  padding: 32px 48px 80px;
  max-width: calc(var(--content-max-width) + 96px);
}

/* ---- Breadcrumbs ---- */
.breadcrumbs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-tertiary); margin-bottom: 24px;
}
.breadcrumbs a { color: var(--text-tertiary); text-decoration: none; transition: var(--transition); }
.breadcrumbs a:hover { color: var(--text-link); }
.breadcrumbs .sep { opacity: 0.5; }
.breadcrumbs .current { color: var(--text-secondary); }

/* ---- TOC Sidebar ---- */
.toc-sidebar {
  position: sticky; top: calc(var(--topbar-height) + 32px);
  width: var(--toc-width); flex-shrink: 0; padding: 0 20px;
  max-height: calc(100vh - var(--topbar-height) - 64px);
  overflow-y: auto; align-self: flex-start;
}
.toc-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-tertiary); margin-bottom: 12px;
}
.toc-nav a {
  display: block; padding: 4px 0 4px 12px; font-size: 13px;
  color: var(--text-tertiary); text-decoration: none;
  border-left: 2px solid var(--border-subtle); transition: var(--transition);
  line-height: 1.5;
}
.toc-nav a:hover { color: var(--text-secondary); border-left-color: var(--border-emphasis); }
.toc-nav a.active { color: var(--accent-primary); border-left-color: var(--accent-primary); }
.toc-nav a.toc-h3 { padding-left: 24px; font-size: 12px; }

/* ---- Article Content ---- */
.article { line-height: 1.8; }
.article h1 {
  font-size: 2rem; font-weight: 700; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.article .subtitle {
  font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 32px;
  line-height: 1.6;
}
.article h2 {
  font-size: 1.45rem; font-weight: 700; color: var(--text-primary);
  margin: 48px 0 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.article h2:first-of-type { margin-top: 32px; }
.article h3 { font-size: 1.15rem; font-weight: 600; color: var(--text-primary); margin: 32px 0 12px; }
.article p { margin-bottom: 16px; color: var(--text-secondary); }
.article a { color: var(--text-link); text-decoration: none; transition: var(--transition); }
.article a:hover { text-decoration: underline; }

.article ul, .article ol { margin: 0 0 16px 24px; color: var(--text-secondary); }
.article li { margin-bottom: 6px; }
.article li::marker { color: var(--accent-primary); }

.article strong { color: var(--text-primary); font-weight: 600; }
.article em { color: var(--text-secondary); }

.article img { max-width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--border-default); margin: 16px 0; }

/* Code */
.article code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--code-bg); color: #c4b5fd; padding: 2px 6px;
  border-radius: 4px; border: 1px solid var(--border-subtle);
}
.article pre {
  position: relative; margin: 16px 0 24px; padding: 20px 24px;
  background: var(--code-bg); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); overflow-x: auto;
}
.article pre code {
  background: none; border: none; padding: 0; font-size: 13px;
  line-height: 1.7; color: var(--text-secondary);
}
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: var(--bg-hover); border: 1px solid var(--border-default);
  color: var(--text-tertiary); padding: 4px 10px; font-size: 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font-sans);
  transition: var(--transition); opacity: 0;
}
.article pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--bg-active); color: var(--text-primary); }
.copy-btn.copied { color: var(--success); }

/* Callouts / Admonitions */
.callout {
  display: flex; gap: 12px; padding: 16px 20px; margin: 20px 0;
  border-radius: var(--radius-md); border-left: 3px solid;
}
.callout-icon { flex-shrink: 0; font-size: 18px; line-height: 1.5; }
.callout-content { font-size: 14px; }
.callout-content p { margin-bottom: 4px; }
.callout-content p:last-child { margin-bottom: 0; }
.callout.info { background: rgba(96, 165, 250, 0.08); border-color: var(--info); }
.callout.info .callout-icon { color: var(--info); }
.callout.warning { background: rgba(251, 191, 36, 0.08); border-color: var(--warning); }
.callout.warning .callout-icon { color: var(--warning); }
.callout.danger { background: rgba(248, 113, 113, 0.08); border-color: var(--danger); }
.callout.danger .callout-icon { color: var(--danger); }
.callout.tip { background: rgba(52, 211, 153, 0.08); border-color: var(--success); }
.callout.tip .callout-icon { color: var(--success); }

/* Tables */
.article table {
  width: 100%; border-collapse: collapse; margin: 16px 0 24px;
  font-size: 14px;
}
.article thead th {
  text-align: left; padding: 10px 16px;
  background: var(--bg-tertiary); border-bottom: 2px solid var(--border-default);
  font-weight: 600; color: var(--text-primary); font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.article tbody td {
  padding: 10px 16px; border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.article tbody tr:hover { background: var(--bg-hover); }

/* Feature grid on home */
.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px; margin: 24px 0;
}
.feature-card {
  padding: 24px; background: var(--bg-tertiary);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  transition: var(--transition); cursor: pointer; text-decoration: none; display: block;
}
.feature-card:hover {
  border-color: var(--accent-primary); transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}
.feature-card-icon { font-size: 28px; margin-bottom: 12px; }
.feature-card-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.feature-card-desc { font-size: 13px; color: var(--text-tertiary); line-height: 1.5; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  font-size: 11px; font-weight: 600; border-radius: 9999px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-pro { background: rgba(139, 92, 246, 0.15); color: var(--accent-secondary); }
.badge-team { background: rgba(99, 102, 241, 0.15); color: var(--accent-primary); }
.badge-new { background: rgba(52, 211, 153, 0.15); color: var(--success); }

/* Pricing table */
.pricing-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px; margin: 24px 0;
}
.pricing-card {
  padding: 28px 24px; background: var(--bg-tertiary);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  text-align: center;
}
.pricing-card.featured { border-color: var(--accent-primary); box-shadow: 0 0 30px var(--accent-glow); }
.pricing-card-name { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.pricing-card-price { font-size: 32px; font-weight: 700; color: var(--accent-primary); margin: 12px 0 4px; }
.pricing-card-price span { font-size: 14px; color: var(--text-tertiary); font-weight: 400; }
.pricing-card-note { font-size: 12px; color: var(--text-tertiary); margin-bottom: 20px; }
.pricing-card-features { text-align: left; list-style: none; padding: 0; margin: 0; }
.pricing-card-features li { padding: 6px 0; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.pricing-card-features li::before { content: "✓"; color: var(--success); font-weight: 700; }

/* ---- Chatbot ---- */
.chatbot-widget { position: fixed; bottom: 24px; right: 24px; z-index: 200; }
.chatbot-toggle {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: var(--transition);
}
.chatbot-toggle:hover { transform: scale(1.05); box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5); }
.chatbot-toggle .chat-icon-close { display: none; }
.chatbot-widget.open .chatbot-toggle .chat-icon-open { display: none; }
.chatbot-widget.open .chatbot-toggle .chat-icon-close { display: block; }

.chatbot-panel {
  display: none; position: absolute; bottom: 72px; right: 0;
  width: 380px; max-height: 520px;
  background: var(--bg-secondary); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; flex-direction: column;
}
.chatbot-widget.open .chatbot-panel { display: flex; }

.chatbot-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-default);
}
.chatbot-header-info { display: flex; align-items: center; gap: 12px; }
.chatbot-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.chatbot-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.chatbot-subtitle { font-size: 11px; color: var(--text-tertiary); }
.chatbot-close {
  background: none; border: none; color: var(--text-tertiary);
  cursor: pointer; padding: 4px; border-radius: var(--radius-sm);
}
.chatbot-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.chatbot-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 300px; max-height: 360px;
}
.chatbot-message { display: flex; gap: 8px; }
.chatbot-message-content {
  max-width: 85%; padding: 10px 14px; border-radius: var(--radius-md);
  font-size: 13px; line-height: 1.6;
}
.chatbot-message.bot .chatbot-message-content {
  background: var(--bg-tertiary); color: var(--text-secondary);
  border-bottom-left-radius: 4px;
}
.chatbot-message.user { justify-content: flex-end; }
.chatbot-message.user .chatbot-message-content {
  background: var(--accent-primary); color: #fff;
  border-bottom-right-radius: 4px;
}

.chatbot-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0;
}
.suggestion-btn {
  padding: 6px 12px; font-size: 12px; font-family: var(--font-sans);
  background: var(--bg-tertiary); border: 1px solid var(--border-default);
  color: var(--text-secondary); border-radius: 9999px; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.suggestion-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

.chatbot-typing {
  display: flex; align-items: center; gap: 4px; padding: 10px 14px;
  background: var(--bg-tertiary); border-radius: var(--radius-md);
  border-bottom-left-radius: 4px; width: fit-content;
}
.chatbot-typing span {
  width: 6px; height: 6px; background: var(--text-tertiary);
  border-radius: 50%; animation: typing 1.4s infinite;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chatbot-input-wrapper {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border-default);
  background: var(--bg-tertiary);
}
.chatbot-input {
  flex: 1; background: var(--bg-elevated); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 8px 12px; font-size: 13px;
  font-family: var(--font-sans); color: var(--text-primary); outline: none;
  transition: var(--transition);
}
.chatbot-input::placeholder { color: var(--text-tertiary); }
.chatbot-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 2px var(--accent-glow); }
.chatbot-send {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: var(--accent-primary); border: none; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
.chatbot-send:hover { background: var(--accent-secondary); }

/* ---- Home page hero ---- */
.hero {
  text-align: center; padding: 48px 0 40px;
}
.hero h1 {
  font-size: 2.5rem; font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-primary) 70%, var(--accent-secondary) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 16px;
}
.hero p { font-size: 1.15rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto; }

/* ---- Responsive ---- */
@media (max-width: 1200px) {
  .toc-sidebar { display: none; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); z-index: 95; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .content-wrapper { padding: 24px 20px 80px; }
  .topbar-center { max-width: 200px; }
  .search-kbd { display: none; }
  .btn-app { display: none; }
  .chatbot-panel { width: calc(100vw - 32px); right: -8px; }
  .hero h1 { font-size: 1.8rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .article h1 { font-size: 1.6rem; }
  .article h2 { font-size: 1.25rem; }
}

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.article { animation: fadeIn 0.3s ease; }

/* Version badge */
.version-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border-default); border-radius: 9999px;
  font-size: 12px; color: var(--text-tertiary); margin-top: 12px;
}
.version-badge .dot { width: 6px; height: 6px; background: var(--success); border-radius: 50%; }

/* Step list */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 16px 0; }
.steps li {
  counter-increment: step; position: relative;
  padding: 0 0 24px 48px; color: var(--text-secondary); font-size: 14px;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-glow-strong); color: var(--accent-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.steps li::after {
  content: ''; position: absolute; left: 15px; top: 36px; bottom: 0;
  width: 2px; background: var(--border-default);
}
.steps li:last-child::after { display: none; }
.steps li:last-child { padding-bottom: 0; }
