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

interface WelcomeProps {
  name: string;
  loginUrl: string;
}

export function WelcomeTemplate({ name, loginUrl }: WelcomeProps) {
  const content = `
    <h1 style="font-size: 24px; font-weight: 700; margin-bottom: 16px; color: ${colors.foreground}; letter-spacing: -0.02em;">Welcome to Proten Job Board!</h1>
    
    <p style="margin-bottom: 16px;">Hi ${name},</p>
    
    <p style="margin-bottom: 24px;">Your account has been successfully created. We are excited to help you manage your hiring journey and connect with top talent (or find your next great opportunity!).</p>
    
    <div class="box" style="background-color: ${colors.secondary}; border: 1px solid ${colors.border}; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
      <h3 style="font-size: 16px; font-weight: 600; margin-bottom: 12px; margin-top: 0;">Next Steps to get started:</h3>
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td valign="top" style="padding-bottom: 12px; padding-right: 12px; width: 24px;"><strong>1.</strong></td>
          <td valign="top" style="padding-bottom: 12px;"><strong>Complete your profile.</strong> A 100% complete profile stands out significantly more.</td>
        </tr>
        <tr>
          <td valign="top" style="padding-bottom: 12px; padding-right: 12px; width: 24px;"><strong>2.</strong></td>
          <td valign="top" style="padding-bottom: 12px;"><strong>Set up notifications.</strong> Ensure you never miss a message or application update.</td>
        </tr>
        <tr>
          <td valign="top" style="padding-right: 12px; width: 24px;"><strong>3.</strong></td>
          <td valign="top"><strong>Start browsing.</strong> Dive into the dashboard and see what's waiting for you!</td>
        </tr>
      </table>
    </div>

    ${Button({ text: 'Access Your Dashboard →', url: loginUrl, variant: 'primary' })}
    
    <p style="margin-top: 24px; margin-bottom: 0;">If you run into any issues, our support team is always here to help.</p>
  `;

  return Layout({
    title: 'Welcome to Proten Job Board',
    previewText: 'Your account has been successfully created. Here are your next steps.',
    content
  });
}

export function ApplicationUpdateTemplate({ jobTitle, status }: { jobTitle: string, status: string }) {
  const content = `
    <h1 style="font-size: 24px; font-weight: 700; margin-bottom: 16px; color: ${colors.foreground};">Application Update</h1>
    <p style="margin-bottom: 24px;">Your application for <strong>${jobTitle}</strong> has been updated to: <strong style="color: ${colors.text};">${status}</strong>.</p>
    <p style="margin-bottom: 0;">Log in to your dashboard for more details.</p>
  `;
  return Layout({ title: 'Application Update', previewText: `Your application for ${jobTitle} has been updated to ${status}`, content });
}

export function NotificationTemplate({ title, message, actionLink }: { title: string, message: string, actionLink?: string }) {
  const content = `
    <h1 style="font-size: 24px; font-weight: 700; margin-bottom: 16px; color: ${colors.foreground};">${title}</h1>
    <p style="margin-bottom: 24px; line-height: 1.5;">${message}</p>
    ${actionLink ? Button({ text: 'View Details', url: actionLink }) : ''}
    <p style="color: ${colors.textMuted}; font-size: 12px; margin-top: 32px;">You are receiving this email based on your notification settings. Update preferences in your Dashboard.</p>
  `;
  return Layout({ title, previewText: title, content });
}

export function JobAlertTemplate({ alertName, jobsCount, jobsHtml }: { alertName: string, jobsCount: number, jobsHtml: string }) {
  const content = `
    <h1 style="font-size: 24px; font-weight: 700; margin-bottom: 16px; color: ${colors.foreground};">New Job Matches Found!</h1>
    <p style="margin-bottom: 24px;">We found <strong>${jobsCount}</strong> new jobs that match your saved search <em>"${alertName}"</em>:</p>
    ${jobsHtml}
    <p style="color: ${colors.textMuted}; font-size: 12px; margin-top: 32px;">You are receiving this email because you set up a job alert on your Dashboard.</p>
  `;
  return Layout({ title: 'New Job Matches', previewText: `New jobs for your alert: "${alertName}"`, content });
}
