<%- include('partials/page-start', { pageTitle, activePage }) %>

<section class="grid gap-6 xl:grid-cols-[1fr_380px]">
  <form method="post" action="<%= adminUrl('/settings') %>" class="panel" data-confirm="Save admin system settings?">
    <input type="hidden" name="_csrf" value="<%= csrfToken %>">
    <div class="panel-header"><div><h2 class="panel-title">System settings</h2><p class="panel-subtitle">These values are stored in <code>admin_settings</code>.</p></div></div>
    <div class="space-y-4">
      <label class="flex cursor-pointer items-center justify-between gap-4 rounded-xl border border-slate-800 bg-slate-950/35 p-4"><div><div class="font-medium text-white">Enable OxaPay payments</div><div class="mt-1 text-xs text-slate-500">Your checkout code must read this setting before creating invoices.</div></div><input class="h-5 w-5 rounded border-slate-600 bg-slate-900 text-sky-500" type="checkbox" name="oxapay_enabled" value="1" <%= String(settings.oxapay_enabled || '1') === '1' ? 'checked' : '' %>></label>
      <label class="flex cursor-pointer items-center justify-between gap-4 rounded-xl border border-slate-800 bg-slate-950/35 p-4"><div><div class="font-medium text-white">Test mode</div><div class="mt-1 text-xs text-slate-500">Use only if your payment integration supports a test workflow.</div></div><input class="h-5 w-5 rounded border-slate-600 bg-slate-900 text-sky-500" type="checkbox" name="oxapay_test_mode" value="1" <%= String(settings.oxapay_test_mode || '0') === '1' ? 'checked' : '' %>></label>
      <div class="grid gap-4 sm:grid-cols-2">
        <label class="field"><span>Minimum test payment (USD)</span><input class="input" type="number" min="0" step="0.01" name="minimum_test_payment" value="<%= settings.minimum_test_payment || '0.50' %>"></label>
        <label class="field"><span>Price data retention (days)</span><input class="input" type="number" min="1" max="3650" name="price_retention_days" value="<%= settings.price_retention_days || '90' %>"></label>
      </div>
      <label class="field"><span>Payment help text</span><textarea class="input min-h-36 resize-y" name="payment_help_text" maxlength="5000"><%= settings.payment_help_text || '' %></textarea></label>
    </div>
    <button class="btn btn-primary mt-6" type="submit">Save settings</button>
  </form>

  <aside class="space-y-6">
    <div class="panel">
      <h2 class="panel-title">OxaPay key status</h2><p class="panel-subtitle mt-1">The full key is never rendered in HTML.</p>
      <div class="mt-5 rounded-xl border border-slate-800 bg-slate-950/50 p-4"><div class="text-xs uppercase tracking-wide text-slate-500">OXAPAY_MERCHANT_API_KEY</div><div class="mt-2 break-all font-mono text-sm text-slate-200"><%= maskedMerchantKey %></div></div>
    </div>
    <div class="panel border-amber-500/20"><h2 class="panel-title text-amber-100">Integration note</h2><p class="mt-2 text-sm leading-6 text-slate-400">Saving a toggle here does not automatically modify an existing checkout controller. Connect your payment creation code to <code>admin_settings</code> before relying on these controls.</p></div>
  </aside>
</section>

<%- include('partials/page-end', { activePage }) %>
