<?php
require_once __DIR__ . '/../../includes/email.php';

$details = [
    'Time'      => $logintime ?? '—',
    'IP Address' => $ip ?? '—',
    'Device'    => $device ?? '—',
    'Browser'   => $browser ?? '—',
];

try {
    sendBankEmail(
        $chap,
        'New Login Detected',
        $name ?? 'Valued Customer',
        'New Login Detected',
        '<p>A new login to your account was detected. If this was you, no further action is needed.</p>',
        null, null,
        $details,
        '<p style="color:#cc0000;font-weight:700;padding:0 40px;">If this was NOT you, please change your password immediately and contact our support team.</p>'
    );
} catch (Exception $e) {
    error_log('Email send failed: ' . $e->getMessage());
}
