
export function generateEmailHtml(language: string, content: {
    title: string;
    body: string;
    code?: string;
    actionUrl?: string;
    actionText?: string;
}) {
    const isDe = language === 'de';
    const footerText = isDe
        ? "Diese E-Mail wurde automatisch gesendet. Bitte antworten Sie nicht darauf."
        : "This email was sent automatically. Please do not reply.";

    const siteUrl = process.env.VITE_PUBLIC_APP_URL || "http://localhost:5001";
    const logoUrl = `${siteUrl}/icon-256.png`;

    return `
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
      background-color: #09090b; /* zinc-950 */
      color: #fafafa; /* zinc-50 */
      margin: 0;
      padding: 0;
    }
    .container {
      max-width: 600px;
      margin: 0 auto;
      padding: 40px 20px;
    }
    .logo {
      text-align: center;
      margin-bottom: 32px;
    }
    .logo img {
      width: 48px;
      height: 48px;
    }
    .card {
      background-color: #18181b; /* zinc-900 */
      border: 1px solid #27272a; /* zinc-800 */
      border-radius: 12px;
      padding: 32px;
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    h1 {
      margin: 0 0 16px;
      font-size: 24px;
      font-weight: 600;
      color: #ffffff;
      text-align: center;
    }
    p {
      margin: 0 0 16px;
      line-height: 1.6;
      color: #a1a1aa; /* zinc-400 */
    }
    .code-container {
      text-align: center;
      margin: 32px 0;
    }
    .code {
      font-family: monospace;
      font-size: 32px;
      font-weight: 700;
      letter-spacing: 4px;
      color: #ffffff;
      background: #27272a; /* zinc-800 */
      padding: 16px 24px;
      border-radius: 8px;
      display: inline-block;
    }
    .btn-container {
        text-align: center;
        margin: 32px 0;
    }
    .btn {
        display: inline-block;
        background-color: #ffffff;
        color: #09090b;
        font-weight: 600;
        padding: 12px 24px;
        border-radius: 6px;
        text-decoration: none;
        transition: background-color 0.2s;
    }
    .btn:hover {
        background-color: #e4e4e7;
    }
    .footer {
      text-align: center;
      margin-top: 32px;
      font-size: 12px;
      color: #52525b; /* zinc-600 */
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="logo">
      <img src="${logoUrl}" alt="TaskFlow" style="border-radius: 12px;" width="56" height="56">
    </div>
    <div class="card">
      <h1>${content.title}</h1>
      <p>${content.body}</p>
      
      ${content.code ? `
        <div class="code-container">
          <div class="code">${content.code}</div>
        </div>
      ` : ''}

      ${content.actionUrl ? `
        <div class="btn-container">
            <a href="${content.actionUrl}" class="btn">${content.actionText || 'Click here'}</a>
        </div>
      ` : ''}

      <p style="margin-top: 24px; font-size: 14px;">
        ${isDe ? 'Dieser Code läuft in 10 Minuten ab.' : 'This code expires in 10 minutes.'}
      </p>
    </div>
    <div class="footer">
      <p>&copy; ${new Date().getFullYear()} TaskFlow. ${footerText}</p>
    </div>
  </div>
</body>
</html>
`;
}
