/* TallySale Documentation Theme
   Brand: Indigo (#4318FF) | Clean docs-focused layout
   Fonts: System font stack (no external CDN — avoids CSP restrictions) */

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

:root {
  --brand: #4318FF;
  --brand-dark: #3311cc;
  --brand-light: #EEF2FF;
  --brand-muted: #6366f1;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --bg: #f8fafc;
  --bg-white: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --sidebar-width: 280px;
  --topbar-height: 60px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 12px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --mono: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
}

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

/* ── Top Bar ───────────────────────────────────────────── */
.tm-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.tm-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
}
.tm-logo img { height: 32px; }
.tm-logo-text { font-size: 1rem; font-weight: 700; color: var(--text); }
.tm-logo-badge {
  font-size: 11px; font-weight: 600;
  background: var(--brand-light); color: var(--brand);
  padding: 2px 8px; border-radius: 99px;
  letter-spacing: .04em; text-transform: uppercase;
}
.tm-topbar-right {
  margin-left: auto; display: flex; align-items: center; gap: 0.75rem;
}
.tm-topbar-link {
  font-size: 13px; color: var(--text-secondary);
  text-decoration: none; display: flex; align-items: center; gap: 4px;
  transition: color .15s;
}
.tm-topbar-link:hover { color: var(--brand); }

/* ── Mobile Menu Toggle ───────────────────────────────── */
.tm-menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.tm-menu-toggle:hover { background: var(--bg); }

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

/* ── Sidebar ───────────────────────────────────────────── */
.tm-sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  transition: transform .2s ease;
}
.tm-sidebar-inner { padding: 1.25rem 0 4rem; }

/* ── Sidebar Navigation ────────────────────────────────── */
.tm-nav { list-style: none; }
.tm-nav-section {
  padding: 1rem 1.25rem .25rem;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
}
.tm-nav-section:first-child { padding-top: 0.5rem; }

.tm-nav li a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 1.25rem;
  font-size: 13.5px; font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0;
  transition: background .12s, color .12s;
  border-left: 2px solid transparent;
  text-transform: capitalize;
}
.tm-nav li a:hover {
  background: var(--brand-light);
  color: var(--brand);
}
.tm-nav li.active > a,
.tm-nav li a.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
  border-left: 2px solid var(--brand);
}
/* Folder/section links — bold */
.tm-nav li.folder > a {
  font-weight: 600; color: var(--text);
  padding-top: 8px;
}
.tm-nav li.folder.active > a,
.tm-nav li.folder.activeParent > a {
  color: var(--brand); background: var(--brand-light);
  border-left: 2px solid var(--brand);
}

/* Sub nav (chapter children) */
.tm-nav ul { list-style: none; }
.tm-nav ul li a {
  padding-left: 2rem;
  font-size: 13px;
}

/* Sidebar footer */
.tm-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1rem;
}
.tm-sidebar-footer-card {
  background: var(--brand-light);
  border-radius: var(--radius);
  padding: .75rem 1rem;
}
.tm-sidebar-footer-card p { font-size: 12px; color: var(--brand-muted); margin: 0; }
.tm-sidebar-footer-card p:first-child { font-weight: 600; color: var(--brand); }

/* ── Main Content ──────────────────────────────────────── */
.tm-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}
.tm-content-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 2.5rem 3rem 4rem;
}

/* ── Breadcrumb ────────────────────────────────────────── */
.tm-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-muted);
  margin-bottom: 2rem;
}
.tm-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.tm-breadcrumb a:hover { color: var(--brand); }
.tm-breadcrumb svg { width: 12px; height: 12px; flex-shrink: 0; }
.tm-breadcrumb .current { color: var(--text-secondary); font-weight: 500; }

/* ── Article / Prose ───────────────────────────────────── */
article h1 {
  font-size: 2rem; font-weight: 700;
  color: var(--text); line-height: 1.25;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
article h2 {
  font-size: 1.35rem; font-weight: 600;
  color: var(--text); margin: 2.5rem 0 .75rem;
}
article h3 {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text); margin: 2rem 0 .5rem;
}
article h4 {
  font-size: 1rem; font-weight: 600;
  color: var(--text); margin: 1.5rem 0 .5rem;
}
article p { margin-bottom: 1rem; color: var(--text); }
article ul, article ol {
  margin: .5rem 0 1rem 1.5rem;
}
article li { margin-bottom: .35rem; }
article li::marker { color: var(--brand); }

article a { color: var(--brand); text-decoration: none; }
article a:hover { text-decoration: underline; }

article strong { font-weight: 600; color: var(--text); }

/* Tables */
article table {
  width: 100%; border-collapse: collapse;
  margin: 1.25rem 0; font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
article th {
  background: var(--bg); font-weight: 600;
  text-align: left; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
}
article td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
article tr:last-child td { border-bottom: none; }
article tr:hover td { background: var(--bg); }

/* Code */
article code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--brand-light);
  color: var(--brand);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
article pre {
  background: #1e293b;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  border: 1px solid #334155;
}
article pre code {
  background: none; color: #e2e8f0;
  padding: 0; border-radius: 0;
  font-size: 13.5px; line-height: 1.65;
}

/* Blockquotes / Notes */
article blockquote {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .75rem 1rem;
  margin: 1.25rem 0;
  color: #92400e;
  font-size: 13.5px;
}
article blockquote p { margin: 0; }
article blockquote strong { color: #78350f; }

/* Images */
article img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin: 1rem 0;
}

/* Horizontal rule */
article hr {
  border: none; border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── Prev / Next ───────────────────────────────────────── */
.tm-pager {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-top: 3rem; padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.tm-pager a {
  display: flex; align-items: center; gap: 6px;
  padding: .6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  color: var(--text-secondary); text-decoration: none;
  transition: all .15s;
  max-width: 48%;
}
.tm-pager a:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.tm-pager a.prev { flex-direction: row; }
.tm-pager a.next { flex-direction: row-reverse; text-align: right; margin-left: auto; }
.tm-pager a svg { width: 16px; height: 16px; flex-shrink: 0; }
.tm-pager a .label { font-size: 11px; color: var(--text-muted); display: block; }
.tm-pager a .name { display: block; }

/* ── Page Footer ───────────────────────────────────────── */
.tm-footer {
  margin-top: 2rem; padding: 1.5rem 0 0;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-muted);
}

/* ── Mobile ────────────────────────────────────────────── */
.tm-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 49;
}

@media (max-width: 900px) {
  .tm-menu-toggle { display: flex; align-items: center; justify-content: center; }
  .tm-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .tm-sidebar.open { transform: translateX(0); }
  .tm-overlay.open { display: block; }
  .tm-main { margin-left: 0; }
  .tm-content-wrap { padding: 1.5rem 1.25rem 3rem; }
  article h1 { font-size: 1.6rem; }
}
@media (max-width: 480px) {
  .tm-logo-badge { display: none; }
  .tm-topbar-link span { display: none; }
  .tm-pager { flex-direction: column; }
  .tm-pager a { max-width: 100%; }
}

/* ── 404 ───────────────────────────────────────────────── */
.tm-404 {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh; text-align: center;
  padding: 2rem;
}
.tm-404 h1 { font-size: 5rem; font-weight: 800; color: var(--brand-light); }
.tm-404 h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
.tm-404 p { color: var(--text-secondary); margin-bottom: 1.5rem; }
.tm-404 a {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff;
  padding: .65rem 1.5rem; border-radius: var(--radius);
  font-weight: 600; text-decoration: none; font-size: 14px;
  transition: background .15s;
}
.tm-404 a:hover { background: var(--brand-dark); }
