/**
 * Additional Document Added Email Template
 * 
 * Sent when a document is added to a request by:
 * - Initiator → Notifies spectators and current approver
 * - Spectator → Notifies initiator and current approver
 * - Approver → Notifies initiator and spectators
 */

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

export function getAdditionalDocumentAddedEmail(data: AdditionalDocumentAddedData): 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>Additional Document Added</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">
                    <!-- Header -->
                    ${getEmailHeader(getBrandedHeader({
                      title: 'Additional Document Added',
                      ...HeaderStyles.info
                    }))}
                    
                    <!-- Content -->
                    <tr>
                        <td class="email-content">
                            <p style="margin: 0 0 20px; color: #333333; font-size: 16px; line-height: 1.6;">
                                Dear <strong style="color: #667eea;">${data.recipientName}</strong>,
                            </p>
                            
                            <p style="margin: 0 0 30px; color: #666666; font-size: 16px; line-height: 1.6;">
                                <strong>${data.addedByName}</strong> has added an additional document to the following request:
                            </p>
                            
                            <!-- Request Details Box -->
                            <table role="presentation" style="width: 100%; border-collapse: collapse; background-color: #f8f9fa; border-radius: 6px; margin-bottom: 30px;" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td class="detail-box" style="padding: 30px;">
                                        <h2 style="margin: 0 0 25px; color: #333333; font-size: 20px; font-weight: 600;">Request Details</h2>
                                        
                                        <table role="presentation" class="detail-table" style="width: 100%; border-collapse: collapse;" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td class="detail-label" style="padding: 10px 0; color: #666666; font-size: 15px;">
                                                    <strong>Request ID:</strong>
                                                </td>
                                                <td style="padding: 10px 0; color: #333333; font-size: 15px;">
                                                    ${data.requestNumber || data.requestId}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="detail-label" style="padding: 10px 0; color: #666666; font-size: 15px;">
                                                    <strong>Title:</strong>
                                                </td>
                                                <td style="padding: 10px 0; color: #333333; font-size: 15px;">
                                                    ${data.requestTitle || 'N/A'}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="detail-label" style="padding: 10px 0; color: #666666; font-size: 15px;">
                                                    <strong>Document Name:</strong>
                                                </td>
                                                <td style="padding: 10px 0; color: #333333; font-size: 15px;">
                                                    ${data.documentName}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="detail-label" style="padding: 10px 0; color: #666666; font-size: 15px;">
                                                    <strong>File Size:</strong>
                                                </td>
                                                <td style="padding: 10px 0; color: #333333; font-size: 15px;">
                                                    ${data.fileSize}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="detail-label" style="padding: 10px 0; color: #666666; font-size: 15px;">
                                                    <strong>Added By:</strong>
                                                </td>
                                                <td style="padding: 10px 0; color: #333333; font-size: 15px;">
                                                    ${data.addedByName}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="detail-label" style="padding: 10px 0; color: #666666; font-size: 15px;">
                                                    <strong>Added On:</strong>
                                                </td>
                                                <td style="padding: 10px 0; color: #333333; font-size: 15px;">
                                                    ${data.addedDate} at ${data.addedTime}
                                                </td>
                                            </tr>
                                            ${data.source ? `
                                            <tr>
                                                <td class="detail-label" style="padding: 10px 0; color: #666666; font-size: 15px;">
                                                    <strong>Source:</strong>
                                                </td>
                                                <td style="padding: 10px 0; color: #333333; font-size: 15px;">
                                                    ${data.source}
                                                </td>
                                            </tr>
                                            ` : ''}
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            
                            <!-- Information Box -->
                            <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 This Means</h3>
                                <p style="margin: 0; color: #004085; font-size: 14px; line-height: 1.8;">
                                    A new document has been added to this request. Please review the document in the request details page to stay updated with the latest information.
                                </p>
                            </div>
                            
                            <!-- View Details Button -->
                            <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 using the ${data.companyName} Workflow System.
                            </p>
                        </td>
                    </tr>
                    
                    ${getEmailFooter(data.companyName)}
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
  `;
}

