<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Payroll Signature Report</title>

    <style>
        @page {
            margin: 140px 20px 80px 20px;
        }

        body {
            font-family: DejaVu Sans, sans-serif;
            font-size: 12px;
            margin: 0;
        }

        /* =========================
           HEADER
        ========================== */
        .header {
            position: fixed;
            top: -120px;
            left: 0;
            right: 0;
            height: 100px;
        }

        .header-left {
            float: left;
            width: 70%;
        }

        .header-right {
            float: right;
            width: 30%;
            text-align: right;
        }

        .report-name {
            font-size: 15px;
            font-weight: bold;
        }

        .company-name {
            font-size: 13px;
            font-weight: bold;
        }

        .small-text {
            font-size: 11px;
        }

       .footer {
            position: fixed;
            bottom: -60px;
            left: 0;
            right: 0;
            height: 50px;
            font-size: 10px;
        }

        .footer-left {
            float: left;
            width: 33%;
            text-align: left;
        }

        .footer-center {
            float: left;
            width: 34%;
            text-align: center;
        }

        .footer-right {
            float: right;
            width: 33%;
            text-align: right;
        }

        .page-number:before {
            content: "Page " counter(page) " / " counter(pages);
        }

        /* =========================
           TABLE
        ========================== */
        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 10px;
        }

        th, td {
            border: 1px solid #000;
            padding: 5px 4px;
        }

        th {
            background: #f2f2f2;
            font-weight: bold;
            text-align: left;
        }

        td.number {
            text-align: right;
        }

        td.center {
            text-align: center;
        }

        .signature-column {
            width: 120px;
            min-height: 30px;
        }

        .clearfix::after {
            content: "";
            display: table;
            clear: both;
        }
    </style>
</head>
<body>

<!-- ================= HEADER ================= -->
<div class="header">
    <div class="header-left">
        <div class="report-name">
            Payroll Signature Report
        </div>
        <div class="company-name">
            {{ $company->legal_name ?? $company->display_name ?? '' }}
        </div>
        <div class="small-text">
            {{ trim(implode(', ', array_filter([$company->address_line1 ?? null, $company->address_line2 ?? null]))) }}
        </div>
        <div class="small-text">
            @if(!empty($filters['from_date']) && !empty($filters['to_date']))
                Period: {{ \Carbon\Carbon::parse($filters['from_date'])->format('d M Y') }} to {{ \Carbon\Carbon::parse($filters['to_date'])->format('d M Y') }}
            @endif
        </div>
    </div>

    <div class="header-right">
        @if(!empty($company->logo))
            <img src="{{ public_path($company->logo) }}" height="70">
        @endif
    </div>
</div>

<!-- ================= FOOTER ================= -->
<div class="footer">
    <div class="footer-left">
        LaraOffice
    </div>

    <div class="footer-center">
        <span class="page-number"></span>
    </div>

    <div class="footer-right">
        Printed: {{ now()->format('Y-m-d H:i') }}
    </div>
</div>

<!-- ================= CONTENT ================= -->
@php
    $currency = optional($company->baseCurrency)->symbol ?? 'Rs.';
@endphp

<table>
    <thead>
        <tr>
            <th style="width: 8%;">Emp Code</th>
            <th style="width: 10%;">EPF No</th>
            <th style="width: 25%;">Employee Name</th>
            <th style="width: 15%;">Department</th>
            <th style="width: 15%;">Designation</th>
            <th style="width: 12%;" class="number">Net Salary<br>({{ $currency }})</th>
            <th style="width: 15%;">Signature</th>
        </tr>
    </thead>
    <tbody>
        @foreach($employees as $item)
        <tr>
            <td>{{ $item['employee_code'] }}</td>
            <td>{{ $item['epf_no'] }}</td>
            <td>{{ $item['employee_name'] }}</td>
            <td>{{ $item['department'] }}</td>
            <td>{{ $item['designation'] }}</td>
            <td class="number">{{ number_format($item['net_salary'], 2) }}</td>
            <td class="signature-column"></td>
        </tr>
        @endforeach
    </tbody>
</table>

@if(count($employees) == 0)
    <div style="text-align: center; padding: 50px; font-size: 14px; color: #999;">
        No payroll records found for the selected filters.
    </div>
@endif

</body>
</html>
