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 renderGlossary(): 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="glossar.title">Patentglossar &mdash; Paliad</title>
        <link rel="stylesheet" href="/assets/global.css" />
      </head>
      <body className="has-sidebar">
        <Sidebar currentPath="/glossary" />
        <BottomNav currentPath="/glossary" />

        <main>
          <section className="tool-page">
            <div className="container">
              <div className="tool-header">
                <div className="glossar-header-row">
                  <div>
                    <h1 data-i18n="glossar.heading">Patentglossar</h1>
                    <p className="tool-subtitle" data-i18n="glossar.subtitle">
                      Zweisprachiges Glossar der wichtigsten Begriffe im Patentrecht.
                    </p>
                  </div>
                  <button className="btn-suggest" id="btn-suggest-new" type="button">
                    <span className="btn-suggest-icon">+</span>
                    <span data-i18n="glossar.suggest">Begriff vorschlagen</span>
                  </button>
                </div>
              </div>

              <div className="glossar-controls">
                <div className="glossar-search-wrap">
                  <svg className="glossar-search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <circle cx="11" cy="11" r="8" />
                    <line x1="21" y1="21" x2="16.65" y2="16.65" />
                  </svg>
                  <input
                    type="text"
                    id="glossar-search"
                    className="glossar-search"
                    placeholder="Suchen / Search..."
                    data-i18n-placeholder="glossar.search.placeholder"
                    autocomplete="off"
                  />
                  <span className="glossar-count" id="glossar-count" />
                </div>
                <div className="glossar-filters" id="glossar-filters">
                  <button className="filter-pill active" data-category="all" type="button" data-i18n="glossar.filter.all">Alle</button>
                  <button className="filter-pill" data-category="Litigation" type="button" data-i18n="glossar.filter.litigation">Streitsachen</button>
                  <button className="filter-pill" data-category="Prosecution" type="button" data-i18n="glossar.filter.prosecution">Erteilungsverfahren</button>
                  <button className="filter-pill" data-category="UPC" type="button">UPC</button>
                  <button className="filter-pill" data-category="EPA" type="button">EPA</button>
                  <button className="filter-pill" data-category="SEP/FRAND" type="button">SEP/FRAND</button>
                  <button className="filter-pill" data-category="General" type="button" data-i18n="glossar.filter.general">Allgemein</button>
                </div>
              </div>

              <div className="glossar-table-wrap">
                <table className="glossar-table" id="glossar-table">
                  <thead>
                    <tr>
                      <th data-i18n="glossar.col.de">Deutsch</th>
                      <th data-i18n="glossar.col.en">English</th>
                      <th data-i18n="glossar.col.definition">Definition</th>
                      <th className="glossar-col-actions" />
                    </tr>
                  </thead>
                  <tbody id="glossar-body" />
                </table>
              </div>

              <div className="glossar-empty" id="glossar-empty" style="display:none">
                <p data-i18n="glossar.empty">Keine Treffer.</p>
              </div>

              {/* Suggestion modal */}
              <div className="modal-overlay" id="suggest-modal" style="display:none">
                <div className="modal-card">
                  <div className="modal-header">
                    <h2 id="modal-title" data-i18n="glossar.suggest.title">Begriff vorschlagen</h2>
                    <button className="modal-close" id="modal-close" type="button">&times;</button>
                  </div>
                  <form id="suggest-form">
                    <input type="hidden" id="suggest-type" value="new" />
                    <input type="hidden" id="suggest-existing" value="" />
                    <div className="form-field">
                      <label htmlFor="suggest-de" data-i18n="glossar.suggest.de">Deutscher Begriff</label>
                      <input type="text" id="suggest-de" required />
                    </div>
                    <div className="form-field">
                      <label htmlFor="suggest-en" data-i18n="glossar.suggest.en">English term</label>
                      <input type="text" id="suggest-en" required />
                    </div>
                    <div className="form-field">
                      <label htmlFor="suggest-def" data-i18n="glossar.suggest.definition">Definition (optional)</label>
                      <textarea id="suggest-def" rows={3} />
                    </div>
                    <div className="form-field">
                      <label htmlFor="suggest-cat" data-i18n="glossar.suggest.category">Kategorie</label>
                      <select id="suggest-cat" required>
                        <option value="Litigation" data-i18n="glossar.filter.litigation">Streitsachen</option>
                        <option value="Prosecution" data-i18n="glossar.filter.prosecution">Erteilungsverfahren</option>
                        <option value="UPC">UPC</option>
                        <option value="EPA">EPA</option>
                        <option value="SEP/FRAND">SEP/FRAND</option>
                        <option value="General" data-i18n="glossar.filter.general">Allgemein</option>
                      </select>
                    </div>
                    <div className="form-actions">
                      <button type="button" className="btn-cancel" id="modal-cancel" data-i18n="glossar.suggest.cancel">Abbrechen</button>
                      <button type="submit" className="btn-submit" data-i18n="glossar.suggest.submit">Absenden</button>
                    </div>
                    <p className="form-msg" id="suggest-msg" />
                  </form>
                </div>
              </div>
            </div>
          </section>
        </main>

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