{% extends "ui/templates/base/layout.html" %}
{% block content %}

<div class="space-y-6">
  <div class="flex flex-wrap items-center justify-between gap-3"><div><h2 class="text-xl font-semibold text-slate-900">Leave Types</h2><p class="text-sm text-slate-500">Configure branch-wise leave masters such as CL, SL, EL and LOP.</p></div><form method="post" action="/employees/leave-types/defaults"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><button class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-700">Create Defaults</button></form></div>
  <form method="post" action="/employees/leave-types/new" class="rounded-2xl border border-slate-200 bg-white p-4 shadow-soft"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><h3 class="font-semibold text-slate-900">Add Leave Type</h3><div class="mt-4 grid gap-3 md:grid-cols-4"><input name="code" required placeholder="Code e.g. CL" class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><input name="name" required placeholder="Name" class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><input type="number" name="annual_quota_days" value="0" min="0" class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><input name="description" placeholder="Description" class="rounded-xl border border-slate-300 px-3 py-2 text-sm"></div><div class="mt-3 flex flex-wrap gap-4 text-sm text-slate-700"><label><input type="checkbox" name="requires_approval" checked> Requires approval</label><label><input type="checkbox" name="is_paid" checked> Paid leave</label><label><input type="checkbox" name="carry_forward_allowed"> Carry forward</label><label><input type="checkbox" name="allow_negative_balance"> Allow negative balance</label><label><input type="checkbox" name="is_active" checked> Active</label></div><button class="mt-4 rounded-xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-700">Save Leave Type</button></form>
  <div class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-soft"><table class="min-w-full divide-y divide-slate-200 text-sm"><thead class="bg-slate-50 text-left text-xs font-semibold uppercase tracking-wide text-slate-500"><tr><th class="px-4 py-3">Code</th><th class="px-4 py-3">Name</th><th class="px-4 py-3">Quota</th><th class="px-4 py-3">Rules</th><th class="px-4 py-3">Status</th><th class="px-4 py-3">Edit</th></tr></thead><tbody class="divide-y divide-slate-100">{% for row in rows %}<tr><td class="px-4 py-3 font-semibold">{{ row.code }}</td><td class="px-4 py-3">{{ row.name }}</td><td class="px-4 py-3">{{ row.annual_quota_days }}</td><td class="px-4 py-3 text-slate-600">{{ 'Approval' if row.requires_approval else 'Auto approve' }} · {{ 'Paid' if row.is_paid else 'Unpaid' }}{% if row.allow_negative_balance %} · Negative allowed{% endif %}</td><td class="px-4 py-3">{{ 'Active' if row.is_active else 'Inactive' }}</td><td class="px-4 py-3"><details><summary class="cursor-pointer text-brand-700">Edit</summary><form method="post" action="/employees/leave-types/{{ row.id }}/edit" class="mt-3 grid gap-2"><input type="hidden" name="csrf_token" value="{{ csrf_token }}"><input name="name" value="{{ row.name }}" class="rounded-lg border px-2 py-1"><input type="number" name="annual_quota_days" value="{{ row.annual_quota_days }}" class="rounded-lg border px-2 py-1"><input name="description" value="{{ row.description or '' }}" class="rounded-lg border px-2 py-1"><label><input type="checkbox" name="requires_approval" {% if row.requires_approval %}checked{% endif %}> Requires approval</label><label><input type="checkbox" name="is_paid" {% if row.is_paid %}checked{% endif %}> Paid</label><label><input type="checkbox" name="carry_forward_allowed" {% if row.carry_forward_allowed %}checked{% endif %}> Carry forward</label><label><input type="checkbox" name="allow_negative_balance" {% if row.allow_negative_balance %}checked{% endif %}> Negative allowed</label><label><input type="checkbox" name="is_active" {% if row.is_active %}checked{% endif %}> Active</label><button class="rounded-lg bg-slate-900 px-3 py-1.5 text-xs text-white">Update</button></form></details></td></tr>{% else %}<tr><td colspan="6" class="px-4 py-8 text-center text-slate-500">No leave types found.</td></tr>{% endfor %}</tbody></table></div>
</div>

{% endblock %}
