import { h } from "./jsx";
import { Sidebar } from "./components/Sidebar";
import { PaliadinWidget } from "./components/PaliadinWidget";
import { BottomNav } from "./components/BottomNav";
import { Footer } from "./components/Footer";
import { PWAHead } from "./components/PWAHead";

export function renderChecklists(): string {
  return "<!DOCTYPE html>" + (
    <html lang="de">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
        <meta name="theme-color" content="#BFF355" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="default" />
        <PWAHead />
        <title data-i18n="checklisten.title">Checklisten &mdash; Paliad</title>
        <link rel="stylesheet" href="/assets/global.css" />
      </head>
      <body className="has-sidebar">
        <Sidebar currentPath="/checklists" />
        <BottomNav currentPath="/checklists" />

        <main>
          <section className="tool-page">
            <div className="container">
              <div className="tool-header">
                <h1 data-i18n="checklisten.heading">Checklisten</h1>
                <p className="tool-subtitle" data-i18n="checklisten.subtitle">
                  Interaktive Checklisten f&uuml;r typische Verfahrensschritte vor UPC, BPatG und EPA.
                </p>
              </div>

              <nav className="entity-tabs" id="checklists-tabs" aria-label="Checklisten-Ansichten">
                <a className="entity-tab active" data-tab="templates" href="/checklists" data-i18n="checklisten.tab.templates">Vorlagen</a>
                <a className="entity-tab" data-tab="instances" href="/checklists?tab=instances" data-i18n="checklisten.tab.instances">Vorhandene Instanzen</a>
              </nav>

              {/* Templates tab — pick a template to inspect / instantiate */}
              <section className="entity-tab-panel" id="tab-templates">
                <div className="checklist-filters" id="checklist-filters">
                  <button className="filter-pill active" data-regime="all" type="button" data-i18n="checklisten.filter.all">Alle</button>
                  <button className="filter-pill" data-regime="UPC" type="button">UPC</button>
                  <button className="filter-pill" data-regime="DE" type="button" data-i18n="checklisten.filter.de">DE</button>
                  <button className="filter-pill" data-regime="EPA" type="button">EPA</button>
                </div>

                <div className="checklist-grid" id="checklist-grid" />
              </section>

              {/* Instances tab — every visible instance across templates */}
              <section className="entity-tab-panel" id="tab-instances" style="display:none">
                <p className="entity-events-empty" id="checklists-instances-loading" data-i18n="checklisten.instances.all.loading">L&auml;dt&hellip;</p>
                <p className="entity-events-empty" id="checklists-instances-empty" style="display:none" data-i18n="checklisten.instances.all.empty">
                  Noch keine Checklisten-Instanzen erfasst. Legen Sie eine &uuml;ber den Vorlagen-Tab an.
                </p>
                <div className="entity-table-wrap" id="checklists-instances-tablewrap" style="display:none">
                  <table className="entity-table">
                    <thead>
                      <tr>
                        <th data-i18n="checklisten.instances.all.col.template">Vorlage</th>
                        <th data-i18n="checklisten.instances.all.col.name">Name</th>
                        <th data-i18n="checklisten.instances.all.col.project">Projekt</th>
                        <th data-i18n="checklisten.instances.all.col.progress">Fortschritt</th>
                        <th data-i18n="checklisten.instances.all.col.created">Angelegt</th>
                      </tr>
                    </thead>
                    <tbody id="checklists-instances-body" />
                  </table>
                </div>
              </section>
            </div>
          </section>
        </main>

        <Footer />
        <PaliadinWidget />
        <script src="/assets/checklists.js"></script>
      </body>
    </html>
  );
}
