<!DOCTYPE html><html lang="nl"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Email Accounts — Mek-Tech</title><link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet"><link rel="stylesheet" href="/css/style.css"><link rel="stylesheet" href="/css/dynamic.css"><link rel="icon" href="/img/favicon.svg"><script src="https://unpkg.com/lucide@latest"></script>
<style>
body{background:var(--bg);font-family:'Inter',-apple-system,sans-serif;min-height:100vh}
.em-wrap{max-width:680px;margin:0 auto;padding:1.25rem 1.5rem 3rem}
.em-hdr{margin-bottom:1.5rem}.em-hdr h1{font-size:1.4rem;font-weight:800;color:var(--text);display:flex;align-items:center;gap:.5rem}.em-hdr h1 svg{width:22px;height:22px;color:var(--accent)}.em-hdr p{font-size:.75rem;color:var(--text-muted);margin-top:.2rem}
.em-card{background:var(--bg-card);border:1px solid var(--border);border-radius:10px;padding:1.1rem;margin-bottom:1rem}
.em-card h3{font-size:.72rem;color:var(--text-muted);text-transform:uppercase;letter-spacing:.4px;margin-bottom:.75rem;font-weight:600}
.em-account{display:flex;align-items:center;justify-content:space-between;padding:.55rem 0;border-bottom:1px solid var(--border-light);gap:.5rem}
.em-account:last-child{border-bottom:none}
.em-account-info{flex:1;min-width:0}
.em-account-info strong{font-size:.82rem;color:var(--text)}
.em-account-info span{font-size:.65rem;color:var(--text-dim);display:block}
.em-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:.65rem}
@media(max-width:600px){.em-form-grid{grid-template-columns:1fr}}
.em-form-grid .field-full{grid-column:1/-1}
.field label{display:block;font-size:.65rem;font-weight:600;color:var(--text-muted);margin-bottom:.2rem;text-transform:uppercase;letter-spacing:.3px}
.field input,.field select{width:100%;padding:.4rem .55rem;background:var(--bg);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:.78rem;font-family:inherit}
.field input:focus,.field select:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px rgba(88,166,255,.08)}
.alert{padding:.4rem .7rem;border-radius:7px;font-size:.72rem;margin-bottom:.75rem;font-weight:500}
.alert-error{background:var(--red-bg);color:var(--red);border:1px solid var(--red)}
.alert-success{background:var(--green-bg);color:var(--green);border:1px solid var(--green)}
.btn{display:inline-flex;align-items:center;gap:.3rem;padding:.4rem .8rem;border-radius:7px;font-size:.72rem;font-weight:500;cursor:pointer;border:none;font-family:inherit;text-decoration:none;transition:all .15s}
.btn-primary{background:var(--accent);color:#fff}.btn-primary:hover{background:var(--accent-hover)}
.btn-secondary{background:var(--border-light);color:var(--text-muted)}.btn-secondary:hover{color:var(--text)}
.btn-danger{background:transparent;color:var(--red);border:1px solid transparent}.btn-danger:hover{background:var(--red-bg);border-color:var(--red)}
</style></head><body>
<nav class="navbar"><div class="nav-inner"><a href="/" class="nav-brand"><img src="/img/logo.svg" class="nav-logo" alt="Mek-Tech"></a><div style="display:flex;align-items:center;gap:.4rem"><a href="/" class="nav-icon-btn" title="Dashboard"><i data-lucide="layout-dashboard" style="width:15px;height:15px"></i> Dashboard</a><button class="theme-toggle" id="themeToggle" onclick="toggleTheme()"></button><a href="/auth/logout" class="nav-icon-btn" style="color:var(--red)"><i data-lucide="log-out" style="width:15px;height:15px"></i> Uitloggen</a></div></div></nav>
<div class="em-wrap">
<a href="/email" class="back-link">← Terug naar inbox</a>
<div class="em-hdr"><h1><i data-lucide="at-sign"></i> Email Accounts</h1><p>Configureer IMAP/SMTP voor het ontvangen en versturen van e-mail</p></div>
<% if (saved) { %><div class="alert alert-success">Account succesvol opgeslagen</div><% } %>
<% if (error) { %><div class="alert alert-error"><%= error %></div><% } %>

<% if (accounts.length > 0) { %>
<div class="em-card"><h3>Bestaande Accounts</h3>
<% accounts.forEach(function(a){ %>
<div class="em-account">
<div class="em-account-info"><strong><%= a.email %></strong><span>IMAP: <%= a.imap_host %> · SMTP: <%= a.smtp_host %></span></div>
<form method="POST" action="/email/settings/<%= a.id %>/delete" style="flex-shrink:0"><button class="btn btn-danger" style="font-size:.65rem">✕</button></form>
</div>
<% }) %>
</div>
<% } %>

<div class="em-card">
<h3><%= accounts.length > 0 ? 'Account Toevoegen' : 'Eerste Account Configureren' %></h3>
<form method="POST" action="/email/settings">
<div class="em-form-grid">
<div class="field field-full"><label>E-mailadres</label><input type="email" name="email" required placeholder="uw@bedrijf.nl"></div>
<div class="field"><label>Weergavenaam</label><input type="text" name="name" placeholder="Uw Naam"></div>
<div class="field"><label>IMAP Server</label><input type="text" name="imap_host" required placeholder="imap.bedrijf.nl"></div>
<div class="field"><label>IMAP Poort</label><input type="number" name="imap_port" value="993"></div>
<div class="field"><label>IMAP SSL</label><select name="imap_secure"><option value="1">SSL (993)</option><option value="0">Geen (143)</option></select></div>
<div class="field"><label>IMAP Gebruiker</label><input type="text" name="imap_user" required placeholder="uw@bedrijf.nl"></div>
<div class="field"><label>IMAP Wachtwoord</label><input type="password" name="imap_pass" required></div>
<div class="field"><label>SMTP Server</label><input type="text" name="smtp_host" placeholder="smtp.bedrijf.nl"></div>
<div class="field"><label>SMTP Poort</label><input type="number" name="smtp_port" value="587"></div>
<div class="field"><label>SMTP SSL</label><select name="smtp_secure"><option value="0">STARTTLS (587)</option><option value="1">SSL (465)</option></select></div>
<div class="field"><label>SMTP Gebruiker</label><input type="text" name="smtp_user" placeholder="Zelfde als IMAP"></div>
<div class="field"><label>SMTP Wachtwoord</label><input type="password" name="smtp_pass" placeholder="Zelfde als IMAP"></div>
</div>
<div style="margin-top:.75rem;display:flex;gap:.5rem"><button class="btn btn-primary">Opslaan & Synchroniseren</button><a href="/email" class="btn btn-secondary">Annuleren</a></div>
</form></div>
</div>
<script>lucide.createIcons()</script><script src="/js/theme.js"></script></body></html>