/**
 * Workflow Resumed Email Template
 */

import { WorkflowResumedData } from './types';
import { getEmailFooter, getEmailHeader, HeaderStyles, getActionRequiredSection, getResponsiveStyles, getEmailContainerStyles } from './helpers';
import { getBrandedHeader } from './branding.config';

export function getWorkflowResumedEmail(data: WorkflowResumedData): string {
  return `
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="format-detection" content="telephone=no">
    <title>Workflow Resumed</title>
    ${getResponsiveStyles()}
</head>
<body style="margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; background-color: #f4f4f4;">
    <table role="presentation" style="width: 100%; border-collapse: collapse; background-color: #f4f4f4;" cellpadding="0" cellspacing="0">
        <tr>
            <td style="padding: 40px 0;">
                <table role="presentation" class="email-container" style="${getEmailContainerStyles()}" cellpadding="0" cellspacing="0">
                    ${getEmailHeader(getBrandedHeader({
                      title: 'Workflow Resumed',
                      ...HeaderStyles.success
                    }))}
                    
                    <tr>
                        <td style="padding: 40px 30px;">
                            <p style="margin: 0 0 20px; color: #333333; font-size: 16px; line-height: 1.6;">
                                Dear <strong style="color: #28a745;">${data.recipientName}</strong>,
                            </p>
                            
                            <p style="margin: 0 0 30px; color: #666666; font-size: 16px; line-height: 1.6;">
                                Good news! The following request has been <strong style="color: #28a745;">resumed</strong> ${data.resumedByText}. The approval process is now active again and requires your attention.
                            </p>
                            
                            <table role="presentation" style="width: 100%; border-collapse: collapse; background-color: #d4edda; border: 1px solid #c3e6cb; border-radius: 6px; margin-bottom: 30px;" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td style="padding: 25px;">
                                        <h2 style="margin: 0 0 20px; color: #155724; font-size: 18px; font-weight: 600;">Request Details</h2>
                                        
                                        <table role="presentation" style="width: 100%; border-collapse: collapse;" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px; width: 140px;">
                                                    <strong>Request ID:</strong>
                                                </td>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    ${data.requestId}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    <strong>Title:</strong>
                                                </td>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    ${data.requestTitle || 'N/A'}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    <strong>Resumed On:</strong>
                                                </td>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    ${data.resumedDate} at ${data.resumedTime}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    <strong>Paused Duration:</strong>
                                                </td>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    ${data.pausedDuration}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    <strong>Current Approver:</strong>
                                                </td>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    <strong>${data.currentApprover}</strong>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    <strong>New TAT Deadline:</strong>
                                                </td>
                                                <td style="padding: 8px 0; color: #155724; font-size: 14px;">
                                                    <strong>${data.newTATDeadline}</strong>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            
                            ${getActionRequiredSection(data.isApprover)}
                            
                            <div style="padding: 20px; background-color: #e7f3ff; border-left: 4px solid #0066cc; border-radius: 4px; margin-bottom: 30px;">
                                <h3 style="margin: 0 0 10px; color: #004085; font-size: 16px; font-weight: 600;">What Happens Now</h3>
                                <ul style="margin: 10px 0 0 0; padding-left: 20px; color: #004085; font-size: 14px; line-height: 1.8;">
                                    <li>The approval process has restarted</li>
                                    <li>TAT timers are now active again</li>
                                    <li>The approver can now take action on this request</li>
                                    <li>All stakeholders have been notified</li>
                                </ul>
                            </div>
                            
                            <table role="presentation" style="width: 100%; border-collapse: collapse; margin-bottom: 20px;" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td style="text-align: center;">
                                        <a href="${data.viewDetailsLink}" class="cta-button" style="display: inline-block; padding: 15px 40px; background-color: #1a1a1a; color: #ffffff; text-decoration: none; text-align: center; border-radius: 6px; font-size: 16px; font-weight: 600; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); min-width: 200px;">
                                            View Request Details
                                        </a>
                                    </td>
                                </tr>
                            </table>
                            
                            <p style="margin: 0; color: #666666; font-size: 14px; line-height: 1.6; text-align: center;">
                                Thank you for your patience during the pause period.
                            </p>
                        </td>
                    </tr>
                    
                    ${getEmailFooter(data.companyName)}
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
  `;
}

