<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Warranty Expiry Digest</title>
</head>
<body style="margin:0; padding:0; background-color:#f4f5f7; font-family: Helvetica, Arial, sans-serif; color:#16181d;">
    <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f5f7; padding:24px 0;">
        <tr>
            <td align="center">
                <table role="presentation" width="600" cellpadding="0" cellspacing="0" style="background-color:#ffffff; border-radius:8px; overflow:hidden;">
                    <tr>
                        <td style="background-color:#0d9488; padding:20px 28px;">
                            <span style="font-size:16px; font-weight:600; color:#ffffff;">Aumni AMS</span>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding:28px;">
                            <h1 style="margin:0 0 8px; font-size:18px;">Warranty Expiry Digest</h1>
                            <p style="margin:0 0 24px; font-size:13px; color:#5a6270;">
                                The following coverage periods are due for renewal.
                            </p>

                            @forelse ($windows as $days => $warranties)
                                @if ($warranties->isNotEmpty())
                                    <h2 style="font-size:14px; margin:20px 0 8px; color:#16181d;">
                                        Expiring in {{ $days }} {{ Str::plural('day', $days) }}
                                    </h2>
                                    <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="border-collapse:collapse; margin-bottom:8px;">
                                        <tr style="text-align:left; font-size:11px; text-transform:uppercase; color:#8891a0;">
                                            <th style="padding:6px 8px; border-bottom:1px solid #e5e7eb;">Asset</th>
                                            <th style="padding:6px 8px; border-bottom:1px solid #e5e7eb;">Type</th>
                                            <th style="padding:6px 8px; border-bottom:1px solid #e5e7eb;">Provider</th>
                                            <th style="padding:6px 8px; border-bottom:1px solid #e5e7eb;">Expires</th>
                                        </tr>
                                        @foreach ($warranties as $warranty)
                                            <tr style="font-size:13px;">
                                                <td style="padding:8px; border-bottom:1px solid #f1f2f4;">
                                                    {{ $warranty->asset->asset_tag }} — {{ $warranty->asset->name }}
                                                </td>
                                                <td style="padding:8px; border-bottom:1px solid #f1f2f4;">{{ $warranty->type->label() }}</td>
                                                <td style="padding:8px; border-bottom:1px solid #f1f2f4;">{{ $warranty->provider ?? '—' }}</td>
                                                <td style="padding:8px; border-bottom:1px solid #f1f2f4;">{{ $warranty->end_date->format('d M Y') }}</td>
                                            </tr>
                                        @endforeach
                                    </table>
                                @endif
                            @empty
                            @endforelse

                            <p style="margin:24px 0 0; font-size:12px; color:#8891a0;">
                                Sign in to Aumni AMS and open Warranty → Expiring Soon to renew any of these.
                            </p>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
