<?php
// includes/mail/EmailTemplates.php

class EmailTemplates {
    /**
     * Generate HTML email template for registration confirmation
     * 
     * @param array $details
     * @return string HTML content
     */
    public static function getRegistrationConfirmation($details) {
        $fullName = htmlspecialchars($details['fullName'] ?? 'Participant');
        $eventTitle = htmlspecialchars($details['eventTitle'] ?? 'Event');
        $registrationId = htmlspecialchars($details['registrationId'] ?? 'N/A');
        $paymentStatus = htmlspecialchars($details['paymentStatus'] ?? 'SUCCESSFUL');
        $eventDate = htmlspecialchars($details['eventDate'] ?? '21-22 August 2026');
        $venue = htmlspecialchars($details['venue'] ?? 'MGM University Campus');
        $reportingTime = htmlspecialchars($details['reportingTime'] ?? '09:00 AM');
        $supportContact = htmlspecialchars($details['supportContact'] ?? 'support@supernova2026.com');
        $appName = 'Supernova 2.0';

        return "
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset='UTF-8'>
            <meta name='viewport' content='width=device-width, initial-scale=1.0'>
            <title>Registration Confirmed - Supernova 2.0</title>
            <style>
                body { font-family: 'Helvetica Neue', Arial, sans-serif; background-color: #020617; color: #cbd5e1; margin: 0; padding: 0; }
                .email-wrapper { width: 100%; padding: 40px 0; background-color: #020617; }
                .email-card { max-width: 600px; margin: 0 auto; background-color: #0f172a; border-radius: 16px; border: 1px solid #1e293b; overflow: hidden; }
                .email-header { background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%); padding: 30px; text-align: center; }
                .email-header h1 { color: #020617; font-size: 28px; margin: 0; font-weight: 800; letter-spacing: 1px; }
                .email-body { padding: 40px 30px; line-height: 1.6; }
                .greeting { font-size: 18px; font-weight: bold; color: #f1f5f9; margin-bottom: 20px; }
                .details-box { background-color: #020617; border: 1px solid #334155; border-radius: 12px; padding: 24px; margin: 25px 0; }
                .detail-row { display: flex; justify-content: space-between; border-bottom: 1px solid #1e293b; padding: 10px 0; font-size: 14px; }
                .detail-row:last-child { border-bottom: none; }
                .detail-label { color: #64748b; font-weight: 600; }
                .detail-value { color: #f1f5f9; font-weight: bold; text-align: right; }
                .reg-id { color: #06b6d4; font-family: monospace; font-size: 18px; }
                .success-badge { color: #10b981; background-color: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); padding: 2px 8px; border-radius: 4px; }
                .footer { padding: 30px; background-color: #020617; border-top: 1px solid #1e293b; text-align: center; font-size: 12px; color: #475569; }
                .footer a { color: #06b6d4; text-decoration: none; }
            </style>
        </head>
        <body>
            <div class='email-wrapper'>
                <div class='email-card'>
                    <div class='email-header'>
                        <h1>SUPERNOVA 2.0</h1>
                    </div>
                    <div class='email-body'>
                        <div class='greeting'>Hello {$fullName},</div>
                        <p>Your registration for the event <strong>{$eventTitle}</strong> at Supernova 2.0 has been successfully confirmed!</p>
                        <p>Please present the Registration ID below at the venue check-in desk for entry.</p>
                        
                        <div class='details-box'>
                            <div class='detail-row'>
                                <span class='detail-label'>Registration ID</span>
                                <span class='detail-value reg-id'>{$registrationId}</span>
                            </div>
                            <div class='detail-row'>
                                <span class='detail-label'>Payment Status</span>
                                <span class='detail-value'><span class='success-badge'>{$paymentStatus}</span></span>
                            </div>
                            <div class='detail-row'>
                                <span class='detail-label'>Event Date</span>
                                <span class='detail-value'>{$eventDate}</span>
                            </div>
                            <div class='detail-row'>
                                <span class='detail-label'>Venue</span>
                                <span class='detail-value'>{$venue}</span>
                            </div>
                            <div class='detail-row'>
                                <span class='detail-label'>Reporting Time</span>
                                <span class='detail-value'>{$reportingTime}</span>
                            </div>
                        </div>

                        <p>If you have any questions or require assistance, reach out to us at <a href='mailto:{$supportContact}' style='color: #06b6d4;'>{$supportContact}</a>.</p>
                        <p>See you at the festival!</p>
                    </div>
                    <div class='footer'>
                        <p>This is an automated email from MGM University School of Engineering & Technology.</p>
                        <p>&copy; 2026 {$appName}. All rights reserved.</p>
                    </div>
                </div>
            </div>
        </body>
        </html>
        ";
    }

    /**
     * Generate HTML email template for generic notification
     * 
     * @param string $subject
     * @param string $messageBody
     * @return string HTML content
     */
    public static function getGenericTemplate($subject, $messageBody) {
        $subjectHtml = htmlspecialchars($subject);
        return "
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset='UTF-8'>
            <meta name='viewport' content='width=device-width, initial-scale=1.0'>
            <title>{$subjectHtml}</title>
            <style>
                body { font-family: 'Helvetica Neue', Arial, sans-serif; background-color: #020617; color: #cbd5e1; margin: 0; padding: 0; }
                .email-wrapper { width: 100%; padding: 40px 0; background-color: #020617; }
                .email-card { max-width: 600px; margin: 0 auto; background-color: #0f172a; border-radius: 16px; border: 1px solid #1e293b; overflow: hidden; }
                .email-header { background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%); padding: 30px; text-align: center; }
                .email-header h1 { color: #020617; font-size: 28px; margin: 0; font-weight: 800; letter-spacing: 1px; }
                .email-body { padding: 40px 30px; line-height: 1.6; color: #cbd5e1; }
                .footer { padding: 30px; background-color: #020617; border-top: 1px solid #1e293b; text-align: center; font-size: 12px; color: #475569; }
            </style>
        </head>
        <body>
            <div class='email-wrapper'>
                <div class='email-card'>
                    <div class='email-header'>
                        <h1>SUPERNOVA 2.0</h1>
                    </div>
                    <div class='email-body'>
                        " . nl2br($messageBody) . "
                    </div>
                    <div class='footer'>
                        <p>&copy; 2026 Supernova 2.0. All rights reserved.</p>
                    </div>
                </div>
            </div>
        </body>
        </html>
        ";
    }
}
