@php
    $brandName = setting('general.application_name', config('app.name', 'RemoteMatch'));
    $supportEmail = setting('general.support_email', setting('email.reply_to_email', 'support@example.com'));
    $brandTagline = setting('general.application_tagline', 'AI-powered remote job matching.');
    $logoUrl = \App\Support\Branding::assetUrl(setting('branding.logo'));
@endphp
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ $subject ?? $brandName }}</title>
</head>
<body style="margin:0;background:#f8fafc;color:#0f172a;font-family:Inter,Segoe UI,Arial,sans-serif;">
    <div style="display:none;max-height:0;overflow:hidden;color:transparent;opacity:0;">
        {{ $preheader ?? $brandTagline }}
    </div>

    <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background:#f8fafc;padding:28px 12px;">
        <tr>
            <td align="center">
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width:640px;border-collapse:separate;border-spacing:0;">
                    <tr>
                        <td style="padding:0 0 18px;">
                            @if ($logoUrl)
                                <img src="{{ $logoUrl }}" alt="{{ $brandName }}" style="display:block;max-width:180px;max-height:54px;object-fit:contain;">
                            @else
                                <div style="display:inline-block;border-radius:16px;background:#0f766e;color:#ffffff;font-weight:700;font-size:14px;letter-spacing:.06em;padding:13px 15px;">{{ \App\Support\Branding::initials($brandName) }}</div>
                            @endif
                        </td>
                    </tr>
                    <tr>
                        <td style="border:1px solid #e2e8f0;border-radius:28px;background:#ffffff;box-shadow:0 22px 60px rgba(15,23,42,.08);overflow:hidden;">
                            <div style="height:8px;background:linear-gradient(90deg,#0f766e,#14b8a6,#38bdf8);"></div>
                            <div style="padding:30px 24px 28px;">
                                @yield('content')
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding:18px 6px 0;color:#64748b;font-size:12px;line-height:1.7;">
                            <p style="margin:0 0 8px;">{{ $brandName }} helps applicants discover relevant remote job opportunities. Hiring decisions are made by employers.</p>
                            @isset($unsubscribeUrl)
                                <p style="margin:0 0 8px;"><a href="{{ $unsubscribeUrl }}" style="color:#0f766e;text-decoration:underline;">Unsubscribe from job alerts</a></p>
                            @endisset
                            @if ($supportEmail)
                                <p style="margin:0;">Need help? Contact <a href="mailto:{{ $supportEmail }}" style="color:#0f766e;text-decoration:underline;">{{ $supportEmail }}</a>.</p>
                            @endif
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
