{% extends "ui/templates/base/layout.html" %}
{% block content %}
<div class="max-w-5xl">
  <h1 class="text-2xl font-semibold">Preview Firm Creation</h1>
  <p class="mt-1 text-sm text-slate-500">Review the details. Nothing is saved until you click Confirm.</p>

  <form class="mt-5" method="post" action="/wizards/system/firm/confirm">
    <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
    {% for key, value in form.items() %}
      {% if value is sameas true %}
        <input type="hidden" name="{{ key }}" value="on" />
      {% elif value is not sameas false and value is not none %}
        <input type="hidden" name="{{ key }}" value="{{ value }}" />
      {% endif %}
    {% endfor %}

    <div class="grid gap-5 lg:grid-cols-2">
      <section class="rounded-2xl border bg-white p-5 shadow-soft">
        <h2 class="text-lg font-semibold">Firm</h2>
        <dl class="mt-4 space-y-2 text-sm">
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Code</dt><dd class="font-medium">{{ form.tenant_code }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Name</dt><dd class="font-medium">{{ form.tenant_name }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Type</dt><dd class="font-medium">{{ form.firm_type }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Timezone</dt><dd class="font-medium">{{ form.default_timezone }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Storage</dt><dd class="font-medium">{{ form.default_storage_mode }}</dd></div>
        </dl>
      </section>

      <section class="rounded-2xl border bg-white p-5 shadow-soft">
        <h2 class="text-lg font-semibold">Primary Branch</h2>
        <dl class="mt-4 space-y-2 text-sm">
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Code</dt><dd class="font-medium">{{ form.branch_code }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Name</dt><dd class="font-medium">{{ form.branch_name }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">City / State</dt><dd class="font-medium">{{ form.branch_city or '-' }}{% if form.branch_state %}, {{ form.branch_state }}{% endif %}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">PAN</dt><dd class="font-medium">{{ form.branch_pan or '-' }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">GSTIN</dt><dd class="font-medium">{{ form.branch_gstin or '-' }}</dd></div>
        </dl>
      </section>

      <section class="rounded-2xl border bg-white p-5 shadow-soft">
        <h2 class="text-lg font-semibold">Primary Firm Admin</h2>
        <dl class="mt-4 space-y-2 text-sm">
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Name</dt><dd class="font-medium">{{ form.admin_full_name }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Email</dt><dd class="font-medium">{{ form.admin_email }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Mobile</dt><dd class="font-medium">{{ form.admin_mobile or '-' }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Role</dt><dd class="font-medium">Firm Admin</dd></div>
        </dl>
      </section>

      <section class="rounded-2xl border bg-white p-5 shadow-soft">
        <h2 class="text-lg font-semibold">Financial Year</h2>
        {% if form.create_financial_year %}
        <dl class="mt-4 space-y-2 text-sm">
          <div class="flex justify-between gap-4"><dt class="text-slate-500">FY</dt><dd class="font-medium">{{ form.fy_year_code }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">AY</dt><dd class="font-medium">{{ form.fy_assessment_year }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Dates</dt><dd class="font-medium">{{ form.fy_start_date }} to {{ form.fy_end_date }}</dd></div>
          <div class="flex justify-between gap-4"><dt class="text-slate-500">Current</dt><dd class="font-medium">{{ 'Yes' if form.fy_is_current else 'No' }}</dd></div>
        </dl>
        {% else %}
        <p class="mt-4 text-sm text-slate-500">No financial year will be created now.</p>
        {% endif %}
      </section>
    </div>

    <div class="mt-5 rounded-2xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900">
      Confirming will create the tenant, head office branch, Firm Admin user, invite token and optional financial year.
    </div>

    <div class="mt-5 flex gap-3">
      <button class="rounded-xl bg-slate-900 px-5 py-2.5 text-sm font-medium text-white hover:bg-slate-800" type="submit">Confirm & Create Firm</button>
      <button class="rounded-xl border border-slate-300 px-5 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-50" type="button" onclick="history.back()">Back to Edit</button>
      <a class="rounded-xl border border-slate-300 px-5 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-50" href="/system-settings">Cancel</a>
    </div>
  </form>
</div>
{% endblock %}
