<?php
// admin_email_templates.php

function get_email_header($title)
{
    return "
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset='UTF-8'>
        <meta name='viewport' content='width=device-width, initial-scale=1.0'>
        <style>
            body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 1.6; color: #334155; margin: 0; padding: 0; background-color: #f1f5f9; }
            .container { max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); margin-top: 40px; margin-bottom: 40px; }
            .header { background-color: #1e3a8a; padding: 30px; text-align: center; }
            .content { padding: 40px 30px; }
            .footer { background-color: #f8fafc; padding: 20px; text-align: center; font-size: 12px; color: #94a3b8; border-top: 1px solid #e2e8f0; }
            .button { display: inline-block; background-color: #2563eb; color: #ffffff; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: bold; margin-top: 20px; }
            .status-badge { display: inline-block; padding: 6px 12px; border-radius: 4px; font-weight: bold; font-size: 14px; margin-bottom: 20px; }
            .status-approved { background-color: #dcfce7; color: #166534; }
            .status-action { background-color: #fee2e2; color: #991b1b; }
        </style>
    </head>
    <body>
        <div class='container'>
            <div class='header'>
                <h1 style='color: #ffffff; margin: 0; font-size: 24px;'>SaniBook Kenya</h1>
            </div>
            <div class='content'>
                <h2 style='color: #0f172a; margin-top: 0;'>$title</h2>
    ";
}

function get_email_footer()
{
    return "
            </div>
            <div class='footer'>
                <p>&copy; " . date('Y') . " SaniBook Kenya. All rights reserved.</p>
                <p>Nairobi, Kenya</p>
            </div>
        </div>
    </body>
    </html>
    ";
}

function get_approval_email($org_name, $title, $notes = '')
{
    $body = "
        <div class='status-badge status-approved'>Approved</div>
        <p>Hello <strong>$org_name</strong>,</p>
        <p>We are pleased to inform you that your submission \"<strong>$title</strong>\" has been reviewed and approved for publication on SaniBook Kenya.</p>
    ";

    if (!empty($notes)) {
        $body .= "
            <div style='background: #f8fafc; border-left: 4px solid #3b82f6; padding: 15px; margin: 20px 0; border-radius: 0 8px 8px 0;'>
                <p style='margin: 0; font-weight: bold; color: #475569;'>Editor's Notes:</p>
                <p style='margin: 5px 0 0 0; color: #64748b; font-style: italic;'>\"$notes\"</p>
            </div>";
    }

    $body .= "
        <p>It is now visible to other users and stakeholders in the repository.</p>
        <div style='text-align: center; margin-top: 30px;'>
            <a href='https://sanibook.ke/login.php' class='button' style='color: #ffffff;'>View Submission</a>
        </div>
        <p style='margin-top: 30px;'>Thank you for contributing to the sanitation community.</p>
    ";

    return get_email_header("Submission Approved") . $body . get_email_footer();
}

function get_rejection_email($org_name, $title, $reason = '')
{
    $body = "
        <div class='status-badge status-action'>Action Required</div>
        <p>Hello <strong>$org_name</strong>,</p>
        <p>Thank you for your submission \"<strong>$title</strong>\".</p>
        <p>Upon review, we found that some adjustments are needed before we can publish this content.</p>
    ";

    if (!empty($reason)) {
        $body .= "
            <div style='background: #fff1f2; border-left: 4px solid #ef4444; padding: 15px; margin: 20px 0; border-radius: 0 8px 8px 0;'>
                <p style='margin: 0; font-weight: bold; color: #991b1b;'>Reason for Rejection / Required Changes:</p>
                <p style='margin: 5px 0 0 0; color: #b91c1c;'>$reason</p>
            </div>";
    }

    $body .= "
        <div style='text-align: center; margin-top: 30px;'>
            <a href='https://sanibook.ke/login.php' class='button' style='color: #ffffff; background-color: #ef4444;'>Review & Edit</a>
        </div>
        <p style='margin-top: 30px;'>You can log in to your dashboard to edit and resubmit Your Data once these points have been addressed.</p>
        <p>We look forward to sharing your work soon.</p>
    ";

    return get_email_header("Action Required") . $body . get_email_footer();
}
?>
