<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Live Inventory CDC Demo — FLÓ</title>

<script>
(function () {
  var stored = localStorage.getItem('poc-theme');
  var theme = stored || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'tokyo' : 'light');
  document.documentElement.setAttribute('data-theme', theme);
})();
</script>

<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>

<header>
  <a href="https://fló.fo" class="back-link">FLÓ.FO</a>
  <span class="brand">FLÓ <span class="brand-sep">/</span> <span class="brand-sub">CDC POC</span></span>
</header>

<main id="main" class="workbench">
  <section class="interaction-pane">
    <section class="inventory-shell">
      <div class="section-heading">
        <h2>Inventory</h2>
        <span id="inventory-note" class="muted">Loading products...</span>
      </div>
      <div id="inventory-grid" class="inventory-grid"></div>
    </section>

    <section class="control-deck">
      <select id="selected-item" name="id" class="visually-hidden" aria-label="Selected item"></select>

      <section id="selected-summary" class="selected-summary">
        <span class="summary-kicker">Active product</span>
        <div>
          <strong id="selected-name">No product selected</strong>
          <span id="selected-meta" class="muted">Pick a product above.</span>
        </div>
      </section>

      <form id="edit-form" class="action-form selected-actions">
        <div class="primary-action-row">
          <button type="button" id="sell-one" class="primary-stock-action">
            <span>Sell</span>
            <strong>1</strong>
          </button>
          <button type="button" id="restock-five" class="primary-stock-action">
            <span>Restock</span>
            <strong>5</strong>
          </button>
        </div>

        <details class="more-actions">
          <summary>More actions</summary>
          <div class="more-actions-panel">
            <fieldset class="edit-actions">
              <legend>Rename or move</legend>
              <div class="compact-form-grid">
                <label>Name <input name="name" placeholder="leave unchanged"></label>
                <label>Location <input name="location" placeholder="leave unchanged"></label>
              </div>
              <button type="submit">Save changes</button>
            </fieldset>

            <fieldset class="danger-actions">
              <legend>Remove</legend>
              <button type="button" id="delete-item" class="danger">Delete product</button>
            </fieldset>
          </div>
        </details>
      </form>

      <form id="create-form" class="action-form create-actions">
        <fieldset>
          <legend>Create product</legend>
          <p id="slot-note" class="muted">Create a product in the selected empty slot.</p>
          <div class="create-form-grid">
            <label>SKU <input name="sku" value="FL-440" required></label>
            <label>Name <input name="name" value="USB barcode scanner" required></label>
            <label>Quantity <input name="quantity" type="number" value="4" min="0" required></label>
            <label>Location <input name="location" value="Torshavn" required></label>
            <button type="submit">Create product</button>
          </div>
        </fieldset>
      </form>
    </section>
  </section>

  <aside class="cdc-pane" aria-label="CDC trace">
    <div class="section-heading cdc-heading">
      <h2>CDC trace</h2>
      <span class="muted">Debezium -> NATS -> browser</span>
    </div>

    <section class="event-grid">
      <fieldset>
        <legend>Command sent</legend>
        <pre><code id="command-json">No command sent yet.</code></pre>
      </fieldset>

      <fieldset>
        <legend>CDC event received</legend>
        <div id="event-summary" class="event-summary">Waiting for Debezium/NATS event...</div>
      </fieldset>

      <div class="detail-panel">
        <div class="detail-tabs" role="tablist" aria-label="CDC details">
          <button type="button" class="detail-tab active" data-detail-tab="raw">Raw JSON</button>
          <button type="button" class="detail-tab" data-detail-tab="audit">Audit trail</button>
        </div>
        <div class="detail-view active" data-detail-view="raw">
          <pre class="json-output"><code id="raw-json">{}</code></pre>
        </div>
        <div class="detail-view" data-detail-view="audit">
          <div id="audit-list" class="audit-list">
            <p class="muted">CDC events will appear here.</p>
          </div>
        </div>
      </div>
    </section>
  </aside>
</main>

<footer>
  <span>&copy; <script>document.write(new Date().getFullYear())</script> <a href="https://fló.fo">FLÓ.FO</a> | {{ .Version }}</span>
</footer>

<button class="theme-toggle" id="theme-toggle" aria-label="Toggle theme"></button>

<script src="/static/js/theme.js"></script>
<script src="/static/js/app.js"></script>
</body>
</html>
