<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Payslip</title>

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

        body {
            font-family: DejaVu Sans, sans-serif;
            font-size: 11px;
            color: #0f172a;
        }

        .header {
            text-align: center;
            margin-bottom: 16px;
        }

        .title {
            font-size: 18px;
            font-weight: bold;
        }

        .subtitle {
            font-size: 10px;
            color: #64748b;
            margin-top: 2px;
        }

        .box {
            border: 1px solid #cbd5e1;
            padding: 10px;
            margin-bottom: 12px;
        }

        .row {
            margin-bottom: 4px;
        }

        .label {
            width: 40%;
            display: inline-block;
            color: #64748b;
        }

        .value {
            width: 58%;
            display: inline-block;
            font-weight: bold;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 6px;
        }

        th, td {
            border: 1px solid #cbd5e1;
            padding: 6px;
        }

        th {
            background: #f1f5f9;
            font-size: 10px;
        }

        td {
            font-size: 10px;
        }

        .text-right {
            text-align: right;
        }

        .total {
            font-weight: bold;
            background: #f8fafc;
        }

        .footer {
            margin-top: 30px;
            font-size: 10px;
            color: #64748b;
            text-align: center; /* ✅ CENTER FIX */
        }
    </style>
</head>

<body>

    {{-- Header --}}
    <div class="header">
        <div class="title">Salary Payslip</div>
        <div class="subtitle">
            Payroll Period:
            {{ sprintf('%02d', $payroll->payroll_month) }}-{{ $payroll->payroll_year }}
        </div>
    </div>

    {{-- Employee Info --}}
    <div class="box">
        <div class="row">
            <span class="label">Employee Name</span>
            <span class="value">{{ $employee->name }}</span>
        </div>

        <div class="row">
            <span class="label">Employee Code</span>
            <span class="value">{{ $employee->employee_code }}</span>
        </div>

        <div class="row">
            <span class="label">Employee Type</span>
            <span class="value">
                {{ $employee->employee_type === 'monthly' ? 'Monthly Salary' : 'Daily Roz' }}
            </span>
        </div>

        <div class="row">
            <span class="label">Payroll Date</span>
            <span class="value">
                {{ optional($payroll->payroll_date)->format('d M Y') }}
            </span>
        </div>
    </div>

    {{-- Salary Table --}}
    <table>
        <thead>
            <tr>
                <th>Description</th>
                <th class="text-right">Amount</th>
            </tr>
        </thead>

        <tbody>
            <tr>
                <td>Gross Salary</td>
                <td class="text-right">{{ number_format($item->gross_salary, 2) }}</td>
            </tr>

            <tr>
                <td>Overtime Amount</td>
                <td class="text-right">{{ number_format($item->overtime_amount, 2) }}</td>
            </tr>

            <tr>
                <td>Deduction</td>
                <td class="text-right">{{ number_format($item->deduction_amount, 2) }}</td>
            </tr>

            <tr>
                <td>Advance Adjusted</td>
                <td class="text-right">{{ number_format($item->advance_adjusted, 2) }}</td>
            </tr>

            <tr class="total">
                <td>Net Salary</td>
                <td class="text-right">{{ number_format($item->net_salary, 2) }}</td>
            </tr>

            <tr>
                <td>Paid Amount</td>
                <td class="text-right">{{ number_format($item->paid_amount, 2) }}</td>
            </tr>

            <tr>
                <td>Due Amount</td>
                <td class="text-right">{{ number_format($item->due_amount, 2) }}</td>
            </tr>
        </tbody>
    </table>

    {{-- Footer --}}
    <div class="footer">
        Generated from HisabSeba.com
    </div>

</body>
</html>