using ColaFlow.Modules.Identity.Application.Services;

namespace ColaFlow.Modules.Identity.Infrastructure.Services;

/// <summary>
/// Service for rendering HTML email templates
/// </summary>
public sealed class EmailTemplateService : IEmailTemplateService
{
    public string RenderVerificationEmail(string recipientName, string verificationUrl)
    {
        return $@"
<!DOCTYPE html>
<html>
<head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>Verify Your Email</title>
    <style>
        body {{ font-family: Arial, sans-serif; line-height: 1.6; color: #333; }}
        .container {{ max-width: 600px; margin: 0 auto; padding: 20px; }}
        .header {{ background-color: #4F46E5; color: white; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; }}
        .content {{ background-color: #f9fafb; padding: 30px; border-radius: 0 0 8px 8px; }}
        .button {{ display: inline-block; background-color: #4F46E5; color: white; padding: 12px 30px; text-decoration: none; border-radius: 6px; margin: 20px 0; }}
        .footer {{ text-align: center; margin-top: 20px; font-size: 12px; color: #666; }}
    </style>
</head>
<body>
    <div class=""container"">
        <div class=""header"">
            <h1>ColaFlow</h1>
        </div>
        <div class=""content"">
            <h2>Welcome to ColaFlow, {recipientName}!</h2>
            <p>Thank you for registering. Please verify your email address by clicking the button below:</p>
            <div style=""text-align: center;"">
                <a href=""{verificationUrl}"" class=""button"">Verify Email Address</a>
            </div>
            <p>Or copy and paste this link into your browser:</p>
            <p style=""word-break: break-all; color: #4F46E5;"">{verificationUrl}</p>
            <p>This link will expire in 24 hours.</p>
            <p>If you didn't create an account, you can safely ignore this email.</p>
        </div>
        <div class=""footer"">
            <p>&copy; 2025 ColaFlow. All rights reserved.</p>
        </div>
    </div>
</body>
</html>";
    }

    public string RenderPasswordResetEmail(string recipientName, string resetUrl)
    {
        return $@"
<!DOCTYPE html>
<html>
<head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>Reset Your Password</title>
    <style>
        body {{ font-family: Arial, sans-serif; line-height: 1.6; color: #333; }}
        .container {{ max-width: 600px; margin: 0 auto; padding: 20px; }}
        .header {{ background-color: #DC2626; color: white; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; }}
        .content {{ background-color: #f9fafb; padding: 30px; border-radius: 0 0 8px 8px; }}
        .button {{ display: inline-block; background-color: #DC2626; color: white; padding: 12px 30px; text-decoration: none; border-radius: 6px; margin: 20px 0; }}
        .footer {{ text-align: center; margin-top: 20px; font-size: 12px; color: #666; }}
        .warning {{ background-color: #FEF3C7; border-left: 4px solid #F59E0B; padding: 12px; margin: 20px 0; }}
    </style>
</head>
<body>
    <div class=""container"">
        <div class=""header"">
            <h1>ColaFlow</h1>
        </div>
        <div class=""content"">
            <h2>Password Reset Request</h2>
            <p>Hi {recipientName},</p>
            <p>We received a request to reset your password. Click the button below to create a new password:</p>
            <div style=""text-align: center;"">
                <a href=""{resetUrl}"" class=""button"">Reset Password</a>
            </div>
            <p>Or copy and paste this link into your browser:</p>
            <p style=""word-break: break-all; color: #DC2626;"">{resetUrl}</p>
            <div class=""warning"">
                <strong>Important:</strong> This link will expire in 1 hour for security reasons.
            </div>
            <p>If you didn't request a password reset, please ignore this email or contact support if you have concerns.</p>
        </div>
        <div class=""footer"">
            <p>&copy; 2025 ColaFlow. All rights reserved.</p>
        </div>
    </div>
</body>
</html>";
    }

    public string RenderInvitationEmail(
        string recipientName,
        string tenantName,
        string inviterName,
        string invitationUrl)
    {
        return $@"
<!DOCTYPE html>
<html>
<head>
    <meta charset=""utf-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>You've Been Invited</title>
    <style>
        body {{ font-family: Arial, sans-serif; line-height: 1.6; color: #333; }}
        .container {{ max-width: 600px; margin: 0 auto; padding: 20px; }}
        .header {{ background-color: #10B981; color: white; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; }}
        .content {{ background-color: #f9fafb; padding: 30px; border-radius: 0 0 8px 8px; }}
        .button {{ display: inline-block; background-color: #10B981; color: white; padding: 12px 30px; text-decoration: none; border-radius: 6px; margin: 20px 0; }}
        .footer {{ text-align: center; margin-top: 20px; font-size: 12px; color: #666; }}
        .info-box {{ background-color: #E0F2FE; border-left: 4px solid #0EA5E9; padding: 12px; margin: 20px 0; }}
    </style>
</head>
<body>
    <div class=""container"">
        <div class=""header"">
            <h1>ColaFlow</h1>
        </div>
        <div class=""content"">
            <h2>You've Been Invited!</h2>
            <p>Hi {recipientName},</p>
            <p><strong>{inviterName}</strong> has invited you to join the <strong>{tenantName}</strong> workspace on ColaFlow.</p>
            <div class=""info-box"">
                <strong>Workspace:</strong> {tenantName}<br>
                <strong>Invited by:</strong> {inviterName}
            </div>
            <p>Click the button below to accept the invitation and get started:</p>
            <div style=""text-align: center;"">
                <a href=""{invitationUrl}"" class=""button"">Accept Invitation</a>
            </div>
            <p>Or copy and paste this link into your browser:</p>
            <p style=""word-break: break-all; color: #10B981;"">{invitationUrl}</p>
            <p>This invitation will expire in 7 days.</p>
            <p>If you don't know {inviterName} or weren't expecting this invitation, you can safely ignore this email.</p>
        </div>
        <div class=""footer"">
            <p>&copy; 2025 ColaFlow. All rights reserved.</p>
        </div>
    </div>
</body>
</html>";
    }
}
