<?php

if (! function_exists('renewal_email_subject')) {
    function renewal_email_subject(string $serviceName, string $locale): string
    {
        return $locale === 'ar'
            ? "تنبيه تجديد: {$serviceName}"
            : "Renewal Reminder: {$serviceName}";
    }
}

if (! function_exists('renewal_email_body')) {
    function renewal_email_body(array $service, int $days, string $locale): string
    {
        if ($locale === 'ar') {
            $type = $service['type'] === 'hosting' ? 'خدمة الاستضافة' : 'النطاق';
            return "مرحباً،\n\n{$type} \"{$service['name']}\" على وشك الانتهاء خلال {$days} يوم.\n"
                . "تاريخ التجديد: {$service['renewal_date']}\nالقيمة: {$service['price']} {$service['currency']}\n\n"
                . "يرجى الدخول لبوابة العميل لمتابعة حسابك.\nشكراً لتعاملكم معنا.";
        }

        $type = $service['type'] === 'hosting' ? 'Hosting service' : 'Domain';
        return "Hello,\n\nYour {$type} \"{$service['name']}\" is expiring in {$days} day(s).\n"
            . "Renewal date: {$service['renewal_date']}\nPrice: {$service['price']} {$service['currency']}\n\n"
            . "Please log in to your client portal to review your account.\nThank you.";
    }
}

if (! function_exists('invoice_email_subject')) {
    function invoice_email_subject(string $invoiceNumber, string $locale): string
    {
        return $locale === 'ar'
            ? "فاتورة مستحقة قريباً رقم {$invoiceNumber}"
            : "Invoice #{$invoiceNumber} due soon";
    }
}

if (! function_exists('invoice_email_body')) {
    function invoice_email_body(array $invoice, int $days, string $locale): string
    {
        if ($locale === 'ar') {
            return "مرحباً،\n\nفاتورتك رقم {$invoice['invoice_number']} مستحقة الدفع خلال {$days} يوم.\n"
                . "المبلغ: {$invoice['amount']} {$invoice['currency']}\nتاريخ الاستحقاق: {$invoice['due_date']}\n\n"
                . "يرجى الدخول لبوابة العميل لعرض الفاتورة.\nشكراً لتعاملكم معنا.";
        }

        return "Hello,\n\nYour invoice #{$invoice['invoice_number']} is due in {$days} day(s).\n"
            . "Amount: {$invoice['amount']} {$invoice['currency']}\nDue date: {$invoice['due_date']}\n\n"
            . "Please log in to your client portal to view the invoice.\nThank you.";
    }
}
