{% extends "ui/templates/base/layout.html" %}
{% block content %}
<div class="space-y-6">
  <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
    <div>
      <h1 class="text-2xl font-semibold text-slate-900">Platform Billing</h1>
      <p class="mt-1 text-sm text-slate-500">SaaS billing for Audit Firms, compliance-dashboard clients, consultants and future marketplace customers.</p>
    </div>
    <div class="flex flex-wrap gap-2">
      {% if can_manage_plans %}<a href="/platform-billing/plans/new" class="rounded-xl border border-slate-300 bg-white px-4 py-2 text-sm font-medium text-slate-700 shadow-sm">New Plan</a>{% endif %}
      {% if can_generate_platform_billing_flag %}<a href="/platform-billing/audit-firm-subscriptions/generate" class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white shadow-soft">Generate Audit Firm Bills</a>{% endif %}
      {% if can_generate_platform_billing_flag %}<a href="/platform-billing/client-dashboard-subscriptions/generate" class="rounded-xl border border-brand-200 bg-white px-4 py-2 text-sm font-semibold text-brand-700 shadow-sm">Generate Client Dashboard Bills</a>{% endif %}
      {% if can_generate_platform_billing_flag %}<a href="/platform-billing/consultant-subscriptions/generate" class="rounded-xl border border-slate-300 bg-white px-4 py-2 text-sm font-semibold text-slate-700 shadow-sm">Generate Consultant Bills</a>{% endif %}
      {% if can_create_invoice %}<a href="/platform-billing/invoices/new" class="rounded-xl border border-slate-300 bg-white px-4 py-2 text-sm font-medium text-slate-700 shadow-sm">New Platform Invoice</a>{% endif %}
    </div>
  </div>
  <div class="grid gap-4 md:grid-cols-5">
    <a href="/platform-billing/accounts" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft"><div class="text-sm text-slate-500">Accounts</div><div class="mt-2 text-3xl font-semibold">{{ accounts|length }}</div></a>
    <a href="/platform-billing/plans" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft"><div class="text-sm text-slate-500">Plans</div><div class="mt-2 text-3xl font-semibold">{{ plans|length }}</div></a>
    <a href="/platform-billing/audit-firm-subscriptions" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft"><div class="text-sm text-slate-500">Audit Firm Billing</div><div class="mt-2 text-3xl font-semibold">{{ audit_firm_accounts|length }}</div></a>
    <a href="/platform-billing/client-dashboard-subscriptions" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft"><div class="text-sm text-slate-500">Client Dashboard Billing</div><div class="mt-2 text-3xl font-semibold">{{ client_dashboard_accounts|length }}</div></a>
    <a href="/platform-billing/consultant-subscriptions" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft"><div class="text-sm text-slate-500">Consultant Billing</div><div class="mt-2 text-3xl font-semibold">{{ consultant_billing_accounts|length }}</div></a>
  </div>
  <div class="grid gap-4 lg:grid-cols-2">
    <div class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft">
      <h2 class="font-semibold">Revenue Channels</h2>
      <div class="mt-4 grid gap-3 text-sm text-slate-700">
        <a href="/platform-billing/audit-firm-subscriptions" class="rounded-xl bg-slate-50 p-3 hover:bg-slate-100">Audit Firm subscription billing</a>
        <a href="/platform-billing/client-dashboard-subscriptions" class="rounded-xl bg-slate-50 p-3 hover:bg-slate-100">Client compliance dashboard access billing</a>
        <a href="/platform-billing/consultant-subscriptions" class="rounded-xl bg-slate-50 p-3 hover:bg-slate-100">Consultant SaaS/tool access billing</a>
        <div class="rounded-xl bg-slate-50 p-3">Marketplace lead / commission billing foundation</div>
      </div>
    </div>
    <div class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft">
      <h2 class="font-semibold">Quick Links</h2>
      <div class="mt-4 flex flex-wrap gap-2 text-sm">
        <a href="/platform-billing/accounts" class="rounded-xl border px-3 py-2">Billing Accounts</a>
        <a href="/platform-billing/plans" class="rounded-xl border px-3 py-2">Plans</a>
        <a href="/platform-billing/audit-firm-subscriptions" class="rounded-xl border px-3 py-2">Audit Firm Subscriptions</a>
        <a href="/platform-billing/client-dashboard-subscriptions" class="rounded-xl border px-3 py-2">Client Dashboard Subscriptions</a>
        <a href="/platform-billing/consultant-subscriptions" class="rounded-xl border px-3 py-2">Consultant Subscriptions</a>
        <a href="/platform-billing/subscriptions" class="rounded-xl border px-3 py-2">All Subscriptions</a>
        <a href="/platform-billing/invoices" class="rounded-xl border px-3 py-2">Platform Invoices</a>
      </div>
    </div>
  </div>
</div>
{% endblock %}
