/**
 * HTML templates for the static docs site generator.
 * Provides layout, CSS, navigation, and shared HTML utilities.
 */
// eslint-disable-next-line max-lines-per-function -- CSS template is inherently long
export function getStyles() {
    return `
:root {
  --bg: #0f1117;
  --bg-card: #1a1d29;
  --bg-sidebar: #141620;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #a855f7;
  --border: #2d3348;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --sidebar-width: 250px;
  --content-max: 900px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #f1f5f9;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
  }
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}
.sidebar h2 {
  font-size: 1.1rem;
  padding: 0 1.25rem;
  margin-bottom: 1rem;
  color: var(--accent);
}
.sidebar ul { list-style: none; }
.sidebar li a {
  display: block;
  padding: 0.4rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.sidebar li a:hover { background: var(--bg-card); color: var(--text); text-decoration: none; }
.sidebar li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-card);
}
.sidebar .nav-section {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.8rem 1.25rem 0.3rem;
  font-weight: 600;
}

/* Main */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: calc(var(--content-max) + 5rem);
}
.main h1 { font-size: 2rem; margin-bottom: 1rem; }
.main h2 { font-size: 1.5rem; margin-top: 2rem; margin-bottom: 0.75rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.main h3 { font-size: 1.2rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}
th, td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
}
th { background: var(--bg-card); font-weight: 600; }

/* Progress bar */
.progress-bar {
  background: var(--border);
  border-radius: 6px;
  height: 22px;
  overflow: hidden;
  position: relative;
  margin: 0.5rem 0;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s;
}
.progress-bar .label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}
.progress-green .fill { background: var(--green); }
.progress-amber .fill { background: var(--amber); }
.progress-red .fill { background: var(--red); }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-draft { background: #374151; color: #d1d5db; }
.badge-review { background: #78350f; color: var(--amber); }
.badge-approved { background: #1e3a5f; color: var(--accent); }
.badge-implementing { background: #3b1f6e; color: var(--purple); }
.badge-done { background: #14532d; color: var(--green); }

/* Code */
pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 1rem 0;
}
code { font-family: var(--font-mono); font-size: 0.88em; }
p code, li code {
  background: var(--bg-card);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Checkboxes */
.criteria-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3rem 0;
}
.criteria-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}
.criteria-check.checked { background: var(--green); border-color: var(--green); color: #fff; }

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: 0 6px 6px 0;
}

/* Mermaid */
.mermaid {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  text-align: center;
}

/* Search */
.search-box {
  padding: 0.5rem 1.25rem;
  margin-bottom: 0.5rem;
}
.search-box input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  body { flex-direction: column; }
  .main { margin-left: 0; padding: 1.5rem 1rem; }
}
`;
}
export function renderNav(items, activePath) {
    const sections = {};
    for (const item of items) {
        const parts = item.path.split('/');
        const section = parts[0] ?? 'General';
        const existing = sections[section];
        if (existing) {
            existing.push(item);
        }
        else {
            sections[section] = [item];
        }
    }
    let html = '<div class="search-box"><input type="text" id="nav-search" placeholder="Search..." /></div>';
    for (const [section, sectionItems] of Object.entries(sections)) {
        html += `<div class="nav-section">${escapeHtml(section)}</div><ul>`;
        for (const item of sectionItems) {
            const activeClass = activePath === item.path ? ' class="active"' : '';
            const icon = item.icon ? `${item.icon} ` : '';
            html += `<li data-searchable="${escapeAttr(item.title)}"><a href="${escapeAttr(item.path)}.html"${activeClass}>${icon}${escapeHtml(item.title)}</a></li>`;
        }
        html += '</ul>';
    }
    return html;
}
export function wrapPage(title, content, navItems) {
    const styles = getStyles();
    const nav = renderNav(navItems, title);
    const searchScript = renderSearchScript();
    return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${escapeHtml(title)} - Planu Docs</title>
<style>${styles}</style>
</head>
<body>
<aside class="sidebar">
<h2>Planu Docs</h2>
${nav}
</aside>
<main class="main">
${content}
</main>
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>mermaid.initialize({startOnLoad:true,theme:'dark'});</script>
<script>${searchScript}</script>
</body>
</html>`;
}
export function renderProgressBar(done, total) {
    const pct = total > 0 ? Math.round((done / total) * 100) : 0;
    let colorClass;
    if (pct >= 80) {
        colorClass = 'progress-green';
    }
    else if (pct >= 40) {
        colorClass = 'progress-amber';
    }
    else {
        colorClass = 'progress-red';
    }
    return `<div class="progress-bar ${colorClass}"><div class="fill" style="width:${String(pct)}%"></div><div class="label">${String(done)}/${String(total)} (${String(pct)}%)</div></div>`;
}
export function renderStatusBadge(status) {
    const normalized = status.toLowerCase().trim();
    const classMap = {
        draft: 'badge-draft',
        review: 'badge-review',
        approved: 'badge-approved',
        implementing: 'badge-implementing',
        done: 'badge-done',
    };
    const badgeClass = classMap[normalized] ?? 'badge-draft';
    return `<span class="badge ${badgeClass}">${escapeHtml(normalized)}</span>`;
}
export function renderSearchScript() {
    return `(function(){
  var input = document.getElementById('nav-search');
  if (!input) return;
  input.addEventListener('keyup', function() {
    var query = this.value.toLowerCase();
    var items = document.querySelectorAll('[data-searchable]');
    for (var i = 0; i < items.length; i++) {
      var text = (items[i].getAttribute('data-searchable') || '').toLowerCase();
      items[i].style.display = text.indexOf(query) !== -1 ? '' : 'none';
    }
  });
})();`;
}
function escapeHtml(text) {
    return text
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;');
}
function escapeAttr(text) {
    return escapeHtml(text).replace(/'/g, '&#39;');
}
//# sourceMappingURL=html-templates.js.map