# ERGON — Email templates Supabase Auth

Templates branded ERGON v1.0 para Supabase Authentication.

## Archivos

| Archivo | Supabase template | Asunto sugerido |
|---|---|---|
| `confirm_signup.html` | Confirm signup | Confirma tu cuenta en ERGON |
| `magic_link.html` | Magic Link | Tu enlace de acceso a ERGON |
| `reset_password.html` | Reset Password | Restablece tu password ERGON |
| `change_email.html` | Change Email Address | Confirma tu nuevo email en ERGON |
| `invite.html` | Invite user | Te invitamos a ERGON |

## Placeholders Supabase soportados

Sintaxis Go template — `{{ .Nombre }}`:

| Placeholder | Disponible en | Valor |
|---|---|---|
| `{{ .ConfirmationURL }}` | Todos | Link de acción (confirmar / reset / magic / invite) |
| `{{ .Token }}` | Todos | Token raw (6 dígitos OTP por defecto) |
| `{{ .TokenHash }}` | Todos | Hash del token (uso interno) |
| `{{ .SiteURL }}` | Todos | Site URL configurado en Supabase (`https://app.ergonpy.com`) |
| `{{ .RedirectTo }}` | Todos | Redirect URL del flow |
| `{{ .Email }}` | Todos | Email destinatario |
| `{{ .NewEmail }}` | change_email | Nuevo email a confirmar |
| `{{ .Data.<campo> }}` | Todos | Metadata custom usuario (ej. `Data.full_name`, `Data.empresa`) |

## Configuración Supabase Dashboard

1. Authentication → Email Templates → seleccionar tipo
2. Subject: copiar del cuadro arriba
3. Message body: pegar contenido HTML del template correspondiente
4. Save changes

## Configuración Site URL + Sender

- Authentication → URL Configuration:
  - Site URL: `https://app.ergonpy.com`
  - Redirect URLs (whitelist): `https://app.ergonpy.com/**`, `https://ergonpy.com/**`
- Authentication → Email → SMTP Settings (opcional Sprint 6, default Supabase SMTP funciona para Sprint 5):
  - Sender email: `noreply@ergonpy.com`
  - Sender name: `ERGON Platform`

## Carga vía Management API (automatizable)

Endpoint: `PATCH https://api.supabase.com/v1/projects/{ref}/config/auth`

Body parcial:
```json
{
  "mailer_subjects_confirmation": "Confirma tu cuenta en ERGON",
  "mailer_subjects_recovery": "Restablece tu password ERGON",
  "mailer_subjects_magic_link": "Tu enlace de acceso a ERGON",
  "mailer_subjects_email_change": "Confirma tu nuevo email en ERGON",
  "mailer_subjects_invite": "Te invitamos a ERGON",
  "mailer_templates_confirmation_content": "<html>...</html>",
  "mailer_templates_recovery_content": "<html>...</html>",
  ...
}
```

Autenticación: `Authorization: Bearer <SUPABASE_ACCESS_TOKEN>` (personal access token de
`https://supabase.com/dashboard/account/tokens`).

Script de carga: `scripts/load_supabase_templates.py` (TBD).

## Diseño base

- Paleta v1.0: grafito `#1F1C18` · crema `#EDE5D7` · bronce `#D4B370` · cianotipo `#2E4A6B`
- Tipografía: IBM Plex Serif (display) + IBM Plex Sans (UI) — con fallback Georgia / system-sans
- Logotipo ERGΘN: Theta italic bronce (Plex Sans porque Plex Serif no tiene greek)
- Layout: tabla 600px center, mobile responsive con media query 480px
- Botón principal: bronce `#D4B370` sobre grafito, border-radius 3px
- Línea de cota: separador editorial canónico
- Sin imágenes (peso < 12KB, mejor deliverability)
