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

interface InterviewProps {
    candidateName: string;
    positionTitle: string;
    companyName: string;
    interviewDate: string;
    interviewTime: string;
    interviewFormat: string;
    interviewerName: string;
    interviewLink?: string; // Optional if it's an in-person interview
    joinUrl: string; // The URL to click "Join Interview ->" or "View Details ->"
}

export function InterviewInvitationTemplate(props: InterviewProps) {
    const content = `
    <span class="badge" style="display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; background-color: #dbeafe; color: #1e40af; margin-bottom: 16px;">
      INTERVIEW INVITATION
    </span>

    <h1 style="font-size: 24px; font-weight: 700; margin-bottom: 16px; color: ${colors.foreground}; letter-spacing: -0.02em;">
      You're Invited to Interview!
    </h1>
    
    <p style="margin-bottom: 24px;">Hi ${props.candidateName},</p>
    
    <p style="margin-bottom: 24px;">Congratulations! <strong>${props.companyName}</strong> would like to invite you to an interview for the <strong>${props.positionTitle}</strong> position.</p>
    
    <div class="box" style="background-color: ${colors.secondary}; border: 1px solid ${colors.border}; border-radius: 6px; padding: 24px; margin-bottom: 24px;">
      <h3 style="font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: ${colors.textMuted}; margin-top: 0; margin-bottom: 16px;">Interview Details</h3>
      
      <table border="0" cellpadding="0" cellspacing="0" width="100%" style="font-size: 15px;">
        <tr>
          <td style="padding-bottom: 12px; width: 120px; color: ${colors.textMuted};">Role:</td>
          <td style="padding-bottom: 12px; font-weight: 500;">${props.positionTitle}</td>
        </tr>
        <tr>
          <td style="padding-bottom: 12px; color: ${colors.textMuted};">Date & Time:</td>
          <td style="padding-bottom: 12px; font-weight: 500;">${props.interviewDate} at ${props.interviewTime}</td>
        </tr>
        <tr>
          <td style="padding-bottom: 12px; color: ${colors.textMuted};">Format:</td>
          <td style="padding-bottom: 12px; font-weight: 500;">${props.interviewFormat}</td>
        </tr>
        <tr>
          <td style="padding-bottom: 12px; color: ${colors.textMuted};">Interviewer:</td>
          <td style="padding-bottom: 12px; font-weight: 500;">${props.interviewerName}</td>
        </tr>
        ${props.interviewLink ? `
        <tr>
          <td style="padding-bottom: 0px; color: ${colors.textMuted};">Resource Link:</td>
          <td style="padding-bottom: 0px;"><a href="${props.interviewLink}" style="color: ${colors.primary}; text-decoration: underline;">Open Link</a></td>
        </tr>
        ` : ''}
      </table>
    </div>

    ${Button({ text: 'Accept & View Details →', url: props.joinUrl, variant: 'primary' })}

    <div style="margin-top: 32px; padding-top: 24px; border-top: 1px solid ${colors.border};">
      <h4 style="font-size: 15px; font-weight: 600; margin-top: 0; margin-bottom: 12px;">Quick Tips:</h4>
      <ul style="margin: 0; padding-left: 20px; color: ${colors.textMuted}; font-size: 14px; line-height: 1.6;">
        <li>Test your technical setup 15 minutes prior to the start time.</li>
        <li>Have a copy of your resume close by.</li>
        <li>Prepare 2-3 questions for your interviewer.</li>
      </ul>
      <p style="margin-top: 16px; margin-bottom: 0; font-size: 14px; color: ${colors.textMuted};">
        Need to reschedule? <a href="${process.env.NEXT_PUBLIC_APP_URL}/dashboard/interviews" style="color: ${colors.primary}; text-decoration: underline;">Manage your interview here.</a>
      </p>
    </div>
  `;

    return Layout({
        title: `Interview Invitation: ${props.companyName}`,
        previewText: `Congratulations! ${props.companyName} would like to interview you for the ${props.positionTitle} role.`,
        content
    });
}
