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

        <main>
          <section className="tool-page">
            <div className="container">
              <div className="tool-header">
                <div className="links-header-row">
                  <div>
                    <h1 data-i18n="links.heading">Links</h1>
                    <p className="tool-subtitle" data-i18n="links.subtitle">
                      N&uuml;tzliche externe Links f&uuml;r die t&auml;gliche Patentpraxis.
                    </p>
                  </div>
                  <div className="links-header-actions">
                    <span className="links-pending-badge" id="pending-badge" style="display:none"></span>
                    <button className="links-suggest-btn" id="suggest-btn" type="button" data-i18n="links.suggest.btn">
                      Link vorschlagen
                    </button>
                  </div>
                </div>
              </div>

              <div className="gerichte-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="links-search"
                    className="glossar-search"
                    placeholder="Suchen / Search..."
                    data-i18n-placeholder="links.search.placeholder"
                    autocomplete="off"
                  />
                  <span className="glossar-count" id="links-count" />
                </div>

                <div className="links-filters" id="category-filters">
                  <button className="links-filter-btn active" data-category="all" type="button" data-i18n="links.filter.all">Alle</button>
                </div>
              </div>

              <div className="links-grid" id="links-grid">
              </div>
            </div>
          </section>
        </main>

        <div className="modal-overlay" id="suggest-modal" style="display:none">
          <div className="modal-content">
            <h2 data-i18n="links.suggest.title">Link vorschlagen</h2>
            <form id="suggest-form">
              <div className="form-field">
                <label htmlFor="suggest-title" data-i18n="links.suggest.name">Titel</label>
                <input type="text" id="suggest-title" required />
              </div>
              <div className="form-field">
                <label htmlFor="suggest-url">URL</label>
                <input type="url" id="suggest-url" required placeholder="https://..." />
              </div>
              <div className="form-field">
                <label htmlFor="suggest-category" data-i18n="links.suggest.category">Kategorie</label>
                <select id="suggest-category" required>
                </select>
              </div>
              <div className="form-field">
                <label htmlFor="suggest-desc" data-i18n="links.suggest.desc">Beschreibung</label>
                <textarea id="suggest-desc" rows="3"></textarea>
              </div>
              <div className="form-actions">
                <button type="button" className="btn-secondary" id="suggest-cancel" data-i18n="links.suggest.cancel">Abbrechen</button>
                <button type="submit" className="btn-primary" data-i18n="links.suggest.submit">Absenden</button>
              </div>
              <p className="form-message" id="suggest-message"></p>
            </form>
          </div>
        </div>

        <div className="modal-overlay" id="feedback-modal" style="display:none">
          <div className="modal-content modal-content-sm">
            <h2 data-i18n="links.feedback.title">Feedback</h2>
            <form id="feedback-form">
              <input type="hidden" id="feedback-link-id" />
              <div className="form-field">
                <label htmlFor="feedback-type" data-i18n="links.feedback.type">Art</label>
                <select id="feedback-type" required>
                  <option value="broken" data-i18n="links.feedback.broken">Link defekt</option>
                  <option value="outdated" data-i18n="links.feedback.outdated">Veraltet</option>
                  <option value="update" data-i18n="links.feedback.update">Aktualisierung n&ouml;tig</option>
                  <option value="other" data-i18n="links.feedback.other">Sonstiges</option>
                </select>
              </div>
              <div className="form-field">
                <label htmlFor="feedback-message" data-i18n="links.feedback.message">Nachricht</label>
                <textarea id="feedback-message" rows="2" data-i18n-placeholder="links.feedback.placeholder"></textarea>
              </div>
              <div className="form-actions">
                <button type="button" className="btn-secondary" id="feedback-cancel" data-i18n="links.suggest.cancel">Abbrechen</button>
                <button type="submit" className="btn-primary" data-i18n="links.feedback.submit">Absenden</button>
              </div>
              <p className="form-message" id="feedback-message-status"></p>
            </form>
          </div>
        </div>

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