/* ─── FacilFlow Docs ─── */
/* Sleek, minimal, blue accent */

:root {
  --accent: #1520a7;
  --accent-light: #4055dd;
  --accent-subtle: rgba(21, 32, 167, 0.06);
  --accent-border: rgba(21, 32, 167, 0.15);

  --bg: #f5f5f7;
  --bg-surface: #ffffff;
  --bg-sidebar: #f5f5f7;
  --bg-topbar: rgba(245, 245, 247, 0.85);
  --bg-code: #f0f0f3;
  --bg-hover: rgba(0, 0, 0, 0.03);

  --text: #1a1a1f;
  --text-secondary: #6e6e78;
  --text-muted: #9898a0;

  --border: rgba(0, 0, 0, 0.06);
  --radius: 8px;

  --sidebar-w: 260px;
  --topbar-h: 52px;

  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

[data-theme='dark'] {
  --accent: #4055dd;
  --accent-light: #818cf8;
  --accent-subtle: rgba(64, 85, 221, 0.08);
  --accent-border: rgba(129, 140, 248, 0.2);

  --bg: #111113;
  --bg-surface: #19191c;
  --bg-sidebar: #111113;
  --bg-topbar: rgba(17, 17, 19, 0.85);
  --bg-code: #1e1e22;
  --bg-hover: rgba(255, 255, 255, 0.04);

  --text: #e8e8ec;
  --text-secondary: #9898a0;
  --text-muted: #6e6e78;

  --border: rgba(255, 255, 255, 0.07);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body { min-height: 100vh; }

a { color: var(--accent-light); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent); }

/* ─── Topbar ─── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.topbar-brand:hover { color: var(--text); }

.topbar-logo { flex-shrink: 0; height: 38px; width: auto; }
.logo-dark { display: none; }
[data-theme='dark'] .logo-light { display: none; }
[data-theme='dark'] .logo-dark { display: block; }

.version-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }

.theme-toggle, .mobile-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover, .mobile-menu-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Sun/Moon toggle */
[data-theme='dark'] .icon-sun { display: none; }
[data-theme='dark'] .icon-moon { display: block; }
:root .icon-sun { display: block; }
:root .icon-moon { display: none; }
[data-theme='light'] .icon-sun { display: block; }
[data-theme='light'] .icon-moon { display: none; }

.mobile-menu-toggle { display: none; }

/* ─── Layout ─── */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  overflow-y: auto;
  padding: 1.25rem 0.75rem;
  z-index: 50;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar { display: none; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }

.nav-section { margin-top: 1rem; }
.nav-section:first-child { margin-top: 0; }

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem 0.25rem;
}

.nav-link {
  display: block;
  padding: 0.35rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 450;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}

.nav-link:hover {
  background: var(--accent-subtle);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-subtle);
  color: var(--accent-light);
  font-weight: 550;
  border-left-color: transparent;
}

.nav-home {
  font-weight: 550;
  margin-bottom: 0.25rem;
}

/* ─── Content ─── */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2.5rem 3rem 4rem;
  max-width: 820px;
}

/* ─── Prose ─── */
.prose h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.prose h2 {
  font-size: 1.25rem;
  font-weight: 650;
  margin-top: 2.25rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.prose h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.4rem;
}

.prose h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.3rem;
  color: var(--text-secondary);
}

.prose p { margin-bottom: 1rem; }

.prose ul, .prose ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.prose li { margin-bottom: 0.3rem; }

.prose li::marker { color: var(--text-muted); }

.prose strong { font-weight: 600; }

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: var(--accent-subtle);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
}

/* ─── Code ─── */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

.prose pre.code-block {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-code);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}

.prose pre.code-block code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* ─── Tables ─── */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.85rem;
}

.prose thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-light);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--accent-border);
}

.prose tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.prose tbody tr:last-child td { border-bottom: none; }

/* ─── Images ─── */
.prose img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1rem 0;
}

/* ─── highlight.js overrides ─── */
.hljs { background: transparent !important; color: var(--text); }
.hljs-keyword, .hljs-selector-tag { color: var(--accent-light); }
.hljs-string, .hljs-attr { color: #2e8b57; }
[data-theme='dark'] .hljs-string, [data-theme='dark'] .hljs-attr { color: #86efac; }
.hljs-comment { color: var(--text-muted); font-style: italic; }
.hljs-number { color: #c2410c; }
[data-theme='dark'] .hljs-number { color: #fb923c; }
.hljs-built_in { color: #0d9488; }
[data-theme='dark'] .hljs-built_in { color: #5eead4; }

/* ─── Search trigger button ─── */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 1rem;
  min-width: 210px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
  height: 35px;
}

.search-trigger:hover {
  border-color: var(--accent-border);
  color: var(--text-secondary);
}

.search-trigger-label { font-weight: 450; flex: 1; text-align: left; }

.search-trigger-kbd {
  font-family: var(--font);
  font-size: 0.72rem;
  margin-left: auto;
  font-weight: 500;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  line-height: 1;
}

@media (max-width: 600px) {
  .search-trigger-label, .search-trigger-kbd { display: none; }
  .search-trigger { padding: 0.35rem; }
}

/* ─── Search overlay & modal ─── */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.search-overlay.open { display: flex; }

.search-modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: searchIn 0.15s ease;
}

@keyframes searchIn {
  from { opacity: 0; transform: scale(0.97) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
}

.search-input-wrap input::placeholder { color: var(--text-muted); }

.search-esc {
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  line-height: 1;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.search-result {
  display: block;
  padding: 0.65rem 1rem;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}

.search-result:last-child { border-bottom: none; }

.search-result:hover { background: var(--accent-subtle); }

.search-result-title {
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--text);
  margin-bottom: 0.1rem;
}

.search-result-page {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent-light);
  margin-bottom: 0.2rem;
}

.search-result-snippet {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.search-result-snippet mark {
  background: rgba(64, 85, 221, 0.15);
  color: var(--accent-light);
  border-radius: 2px;
  padding: 0 0.1em;
}

[data-theme='dark'] .search-result-snippet mark {
  background: rgba(129, 140, 248, 0.2);
}

.search-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Table of Contents ─── */
.toc {
  position: fixed;
  top: calc(var(--topbar-h) + 1.5rem);
  right: 1.5rem;
  width: 200px;
  max-height: calc(100vh - var(--topbar-h) - 3rem);
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 40;
}

.toc::-webkit-scrollbar { display: none; }

.toc-title {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.toc a {
  display: block;
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 430;
  color: var(--text-muted);
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
  line-height: 1.4;
}

.toc a:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.toc a.toc-h3 {
  padding-left: 1rem;
  font-size: 0.74rem;
}

.toc a.toc-active {
  color: var(--accent-light);
  font-weight: 550;
}

/* Adjust content max-width when TOC is present */
@media (min-width: 1200px) {
  .content { max-width: 720px; }
}

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

/* ─── Pagination ─── */
.pagination {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
}

.pagination a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  min-width: 0;
}

.pagination a:hover {
  border-color: var(--accent-border);
  box-shadow: 0 2px 8px rgba(64, 85, 221, 0.08);
  color: var(--accent-light);
}

.pagination a .pagination-dir {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.pagination a.pagination-next {
  margin-left: auto;
  text-align: right;
}

.pagination a.pagination-prev {
  margin-right: auto;
}

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .mobile-menu-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    background: var(--bg-surface);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }

  .sidebar.open { transform: translateX(0); }

  .content {
    margin-left: 0;
    padding: 1.5rem 1.25rem 3rem;
  }
}

@media (max-width: 480px) {
  .prose h1 { font-size: 1.4rem; }
  .prose h2 { font-size: 1.1rem; }
  .content { padding: 1.25rem 1rem 2.5rem; }
}
