{% extends "ui/templates/base/layout.html" %}
{% block content %}
{% include "modules/managers/templates/managers/_manager_tabs.html" %}

<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 Balances</h2><p class="text-sm text-slate-500">View and adjust employee leave balances branch-wise.</p></div><a href="/employees/leave" class="rounded-xl border border-slate-300 px-4 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Leave Requests</a></div><form method="post" action="/employees/leave-balances/adjust" 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">Adjust Balance</h3><div class="mt-4 grid gap-3 md:grid-cols-5"><select name="employee_id" required class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><option value="">Select employee</option>{% for emp in employees %}<option value="{{ emp.id }}">{{ emp.full_name }} - {{ emp.employee_code }}</option>{% endfor %}</select><select name="leave_type_id" required class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><option value="">Leave type</option>{% for lt in leave_types %}<option value="{{ lt.id }}">{{ lt.code }} - {{ lt.name }}</option>{% endfor %}</select><input type="number" name="adjusted_days" value="0" class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><input name="notes" placeholder="Notes" class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><button class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-700">Save</button></div></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">Employee</th><th class="px-4 py-3">Leave Type</th><th class="px-4 py-3">Opening</th><th class="px-4 py-3">Credit</th><th class="px-4 py-3">Availed</th><th class="px-4 py-3">Adjust</th><th class="px-4 py-3">Balance</th></tr></thead><tbody class="divide-y divide-slate-100">{% for row in rows %}<tr><td class="px-4 py-3">{{ row.employee.full_name if row.employee else row.employee_id }}</td><td class="px-4 py-3">{{ row.leave_type.code if row.leave_type else row.leave_type_id }}</td><td class="px-4 py-3">{{ row.opening_days }}</td><td class="px-4 py-3">{{ row.credited_days }}</td><td class="px-4 py-3">{{ row.availed_days }}</td><td class="px-4 py-3">{{ row.adjusted_days }}</td><td class="px-4 py-3 font-semibold">{{ row.balance_days }}</td></tr>{% else %}<tr><td colspan="7" class="px-4 py-8 text-center text-slate-500">No leave balances found. Balances are created when leave is approved or adjusted.</td></tr>{% endfor %}</tbody></table></div></div>

{% endblock %}
