import { Layout } from './Layout';
import { Button } from './components/Button';
import { colors } from './components/theme';

export interface MessageProps {
    recipientName: string;
    senderName: string;
    jobTitle: string;
    messagePreview: string;
    applicationId: string;
    companyName?: string; // Optional if sender is an employer
}

export function NewMessageTemplate({ recipientName, senderName, jobTitle, messagePreview, applicationId, companyName }: MessageProps) {
    const messageUrl = `${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/dashboard/messages/${applicationId}`;

    const senderDisplay = companyName ? `${senderName} at ${companyName}` : senderName;

    const content = `
    <span class="badge" style="display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; background-color: #f3f4f6; color: #1f2937; border: 1px solid #e5e7eb; margin-bottom: 16px;">
      🔔 NEW MESSAGE
    </span>

    <h1 style="font-size: 24px; font-weight: 700; margin-bottom: 16px; color: ${colors.foreground}; letter-spacing: -0.02em;">
      New message regarding ${jobTitle}
    </h1>
    
    <p style="margin-bottom: 16px;">Hi ${recipientName},</p>
    
    <p style="margin-bottom: 24px;"><strong>${senderDisplay}</strong> has sent you a new message on the Proten platform.</p>

    <div class="box" style="background-color: ${colors.secondary}; border-left: 4px solid ${colors.primary}; padding: 20px 24px; margin-bottom: 24px; font-style: italic; color: ${colors.textMuted}; font-size: 15px; border-radius: 0 6px 6px 0;">
      "${messagePreview}"
    </div>

    ${Button({ text: 'Reply to Message →', url: messageUrl, variant: 'primary' })}

    <p style="margin-top: 32px; color: ${colors.textMuted}; font-size: 13px; margin-bottom: 0;">
      For your security and to keep all communication in one place, please reply directly through the platform by clicking the button above.
    </p>
  `;

    return Layout({
        title: `New message from ${senderName}`,
        previewText: `${senderName} sent you a message: "${messagePreview}"`,
        content
    });
}
