<?php
/**
 * Email template: Site reactivated after invoice payment
 * Sent to the customer when WHMCS fires the invoice-paid webhook and
 * enable_site() successfully brings the site back online.
 *
 * @param array $data Associative array with keys:
 *   - username   (string) WHP username / site identifier
 *   - site_url   (string) URL to the customer panel for this site
 *   - invoice_id (string) WHMCS invoice ID (informational, shown in footer)
 * @return string Rendered HTML email
 */
function render_site_reactivated(array $data): string {
    $username   = htmlspecialchars($data['username']   ?? '',  ENT_QUOTES, 'UTF-8');
    $site_url   = htmlspecialchars($data['site_url']   ?? '#', ENT_QUOTES, 'UTF-8');
    $invoice_id = htmlspecialchars($data['invoice_id'] ?? '',  ENT_QUOTES, 'UTF-8');

    $html = <<<HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your hosting site has been reactivated</title>
</head>
<body style="margin:0; padding:0; background-color:#f4f5f7; font-family:Arial, Helvetica, sans-serif; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%;">

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f5f7;">
<tr><td align="center" style="padding:24px 16px;">

<!-- Main container -->
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="max-width:600px; width:100%; background-color:#ffffff; border-radius:8px; overflow:hidden; box-shadow:0 1px 3px rgba(0,0,0,0.08);">

<!-- Header -->
<tr>
<td style="background-color:#1a1a2e; padding:24px 32px;">
    <table role="presentation" width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td style="color:#ffffff; font-size:20px; font-weight:bold; letter-spacing:0.5px;">WHP Hosting Panel</td>
        <td align="right" style="color:#a0a0b8; font-size:13px;">Account Notice</td>
    </tr>
    </table>
</td>
</tr>

<!-- Site name bar -->
<tr>
<td style="background-color:#f0f1f3; padding:12px 32px; border-bottom:1px solid #e2e3e5;">
    <span style="font-size:13px; color:#6c757d;">Site:</span>
    <span style="font-size:13px; color:#212529; font-weight:600;">{$username}</span>
</td>
</tr>

<!-- Status badge -->
<tr>
<td style="padding:28px 32px 16px 32px;">
    <span style="display:inline-block; padding:4px 12px; border-radius:4px; font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; color:#ffffff; background-color:#198754;">Reactivated</span>
</td>
</tr>

<!-- Body copy -->
<tr>
<td style="padding:0 32px 20px 32px;">
    <h1 style="margin:0 0 12px 0; font-size:20px; font-weight:700; color:#212529; line-height:1.4;">Your hosting site is back online</h1>
    <p style="margin:0 0 12px 0; font-size:15px; color:#495057; line-height:1.6;">
        Thank you for your payment. Your hosting site <strong>{$username}</strong> has been
        automatically reactivated and is now fully accessible.
    </p>
    <p style="margin:0; font-size:15px; color:#495057; line-height:1.6;">
        No further action is needed on your part. If you have any questions or notice
        any issues, please contact our support team.
    </p>
</td>
</tr>

<!-- CTA button -->
<tr>
<td align="center" style="padding:8px 32px 32px 32px;">
    <a href="{$site_url}" style="display:inline-block; padding:12px 28px; background-color:#1a1a2e; color:#ffffff; font-size:14px; font-weight:600; text-decoration:none; border-radius:6px;">Go to your control panel</a>
</td>
</tr>

<!-- Footer -->
<tr>
<td style="background-color:#f8f9fa; padding:20px 32px; border-top:1px solid #e9ecef;">
    <p style="margin:0; font-size:12px; color:#868e96; line-height:1.5; text-align:center;">
        This message was sent automatically after invoice {$invoice_id} was marked paid.<br>
        If you did not expect this email, please contact support immediately.
    </p>
</td>
</tr>

</table>
<!-- /Main container -->

</td></tr>
</table>

</body>
</html>
HTML;

    return $html;
}
