<!DOCTYPE html>
<html lang="nl">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Taken — Mek-Tech Consulting</title>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&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" type="image/svg+xml">
</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="container">
    <a href="javascript:history.back()" class="back-link"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg> Terug</a>
<div class="page-header">
      <h1>Tasks</h1>
    </div>

    <% if (tasks.length === 0) { %>
    <div class="empty-state"><p>Geen openstaande taken.</p></div>
    <% } else { %>
    <div class="task-list full">
      <% tasks.forEach(function(t) { %>
      <div class="task-item <%= t.status %>">
        <form action="/tasks/<%= t.id %>/status" method="POST" class="task-status-form">
          <select name="status" onchange="this.form.submit()">
            <option value="todo" <%= t.status === 'todo' ? 'selected' : '' %>>Todo</option>
            <option value="in_progress" <%= t.status === 'in_progress' ? 'selected' : '' %>>Bezig</option>
            <option value="done" <%= t.status === 'done' ? 'selected' : '' %>>Done</option>
          </select>
        </form>
        <div class="task-body">
          <span class="task-title"><%= t.title %></span>
          <% if (t.description) { %><span class="task-desc"><%= t.description %></span><% } %>
          <span class="task-meta"><%= t.client_name %> — <%= t.engagement_title %></span>
        </div>
        <span class="task-prio <%= t.priority %>"><%= t.priority %></span>
        <% if (t.due_date) { %>
        <span class="task-due <%= new Date(t.due_date) < new Date() && t.status !== 'done' ? 'overdue' : '' %>">
          <%= new Date(t.due_date).toLocaleDateString('nl-NL') %>
        </span>
        <% } %>
        <form action="/tasks/<%= t.id %>/delete" method="POST" style="display:inline">
          <button class="btn-small danger" type="submit">×</button>
        </form>
      </div>
      <% }) %>
    </div>
    <% } %>
  </div>
<script src="/js/theme.js"></script></body>
</html>
