<!DOCTYPE html>
<html lang="nl">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Architectuur Diagrammen — Mek-Tech</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">
  <script src="https://unpkg.com/lucide@latest"></script>
  <style>
    .arch-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:1rem;flex-wrap:wrap}
    .arch-header h1{font-size:1.3rem;font-weight:700;display:flex;align-items:center;gap:.5rem}
    .filter-bar{display:flex;gap:.4rem;align-items:center;flex-wrap:wrap;margin-bottom:1rem;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:.5rem .65rem}
    .filter-bar input,.filter-bar select{background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:.3rem .5rem;font-size:.75rem;color:var(--text);font-family:inherit}
    .filter-bar input{flex:1;min-width:120px}
    .filter-bar select{width:auto;min-width:100px}
    .filter-bar .f-stat{font-size:.68rem;color:var(--text-dim);margin-left:auto;white-space:nowrap}
    .btn{display:inline-flex;align-items:center;gap:.3rem;padding:.4rem .75rem;border-radius:var(--radius);font-size:.78rem;font-weight:500;cursor:pointer;text-decoration:none;transition:all .12s;font-family:inherit;border:none}
    .btn-primary{background:var(--accent);color:#fff}
    .btn-primary:hover{background:var(--accent-hover);opacity:.9}
    .btn-ghost{background:var(--bg);color:var(--text-muted);border:1px solid var(--border)}
    .btn-ghost:hover{border-color:var(--text-dim);color:var(--text)}
    .btn-red{background:var(--red-bg);color:var(--red)}
    .btn-red:hover{background:#4d1a1a}
    .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:.65rem}
    .card{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:0;overflow:hidden;transition:all .15s;position:relative}
    .card:hover{border-color:var(--accent);box-shadow:0 4px 20px rgba(88,166,255,.08)}
    .card-top{height:6px}
    .card-top.data_architecture{background:var(--accent)}
    .card-top.network_topology{background:#34d399}
    .card-top.system_architecture{background:var(--purple)}
    .card-body{padding:.9rem 1rem}
    .card-body h3{font-size:.88rem;font-weight:600;color:var(--text);margin:0 0 .2rem}
    .card-body .c-meta{font-size:.68rem;color:var(--text-muted);display:flex;gap:.5rem;flex-wrap:wrap;align-items:center}
    .card-body .c-meta span{display:flex;align-items:center;gap:.25rem}
    .card-body .c-desc{font-size:.7rem;color:var(--text-dim);margin-top:.3rem;line-height:1.3}
    .card-actions{display:flex;gap:.3rem;padding:.5rem 1rem;border-top:1px solid var(--border-light)}
    .card-actions .btn{font-size:.65rem;padding:.2rem .5rem}
    .empty-state{border:2px dashed var(--border);border-radius:var(--radius-lg);padding:2rem;text-align:center}
    .empty-state i{font-size:2rem;color:var(--text-dim);margin-bottom:.5rem;display:block}
    .empty-state h3{font-size:1rem;color:var(--text);margin-bottom:.3rem}
    .empty-state p{font-size:.78rem;color:var(--text-muted)}
    .badge{font-size:.6rem;padding:.1rem .45rem;border-radius:999px;font-weight:500}
    .badge-data_architecture{background:rgba(88,166,255,.15);color:var(--accent)}
    .badge-network_topology{background:rgba(52,211,153,.15);color:#34d399}
    .badge-system_architecture{background:rgba(168,85,247,.15);color:var(--purple)}
    .type-label{font-size:.68rem;display:flex;align-items:center;gap:.25rem}
    @media(max-width:600px){.filter-bar{flex-direction:column}.filter-bar input{width:100%}}
  </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="container" style="padding-top:1rem">
    <div class="arch-header">
      <h1><i data-lucide="layers" style="width:20px;height:20px"></i> Architectuur Diagrammen</h1>
      <a href="/architecture/new" class="btn btn-primary"><i data-lucide="plus" style="width:14px;height:14px"></i> Nieuw Diagram</a>
    </div>

    <form method="GET" action="/architecture">
    <div class="filter-bar">
      <input type="text" name="search" placeholder="Zoek op naam of beschrijving..." value="<%= filters.search || '' %>" oninput="this.form.submit()">
      <select name="client_id" onchange="this.form.submit()">
        <option value="">Alle cliënten</option>
        <% clients.forEach(function(c){ %>
        <option value="<%= c.id %>" <%= filters.client_id == c.id ? 'selected' : '' %>><%= c.name %></option>
        <% }) %>
      </select>
      <select name="diagram_type" onchange="this.form.submit()">
        <option value="">Alle types</option>
        <option value="data_architecture" <%= filters.diagram_type === 'data_architecture' ? 'selected' : '' %>>Data Architectuur</option>
        <option value="network_topology" <%= filters.diagram_type === 'network_topology' ? 'selected' : '' %>>Netwerk Topologie</option>
        <option value="system_architecture" <%= filters.diagram_type === 'system_architecture' ? 'selected' : '' %>>Systeem Architectuur</option>
        <option value="application_flow" <%= filters.diagram_type === 'application_flow' ? 'selected' : '' %>>Applicatie Flow</option>
        <option value="application_landscape" <%= filters.diagram_type === 'application_landscape' ? 'selected' : '' %>>Applicatie Landschap</option>
      </select>
      <span class="f-stat"><%= diagrams.length %> diagram<%= diagrams.length !== 1 ? 'men' : '' %></span>
      <% if (filters.search || filters.client_id || filters.diagram_type) { %>
      <a href="/architecture" class="btn btn-ghost" style="font-size:.65rem;padding:.2rem .5rem"><i data-lucide="x" style="width:12px;height:12px"></i> Wis filters</a>
      <% } %>
    </div>
    </form>

    <% if (diagrams.length === 0) { %>
    <div class="empty-state">
      <i data-lucide="file-text"></i>
      <h3>Geen diagrammen gevonden</h3>
      <% if (filters.search || filters.client_id || filters.diagram_type) { %>
      <p>Probeer andere filters of <a href="/architecture" class="link">wis alle filters</a>.</p>
      <% } else { %>
      <p>Maak je eerste architectuur-diagram om data pipelines, netwerken en systemen te ontwerpen.</p>
      <a href="/architecture/new" class="btn btn-primary" style="margin-top:.75rem"><i data-lucide="plus" style="width:14px;height:14px"></i> Nieuw Diagram</a>
      <% } %>
    </div>
    <% } else { %>
    <div class="grid">
      <% diagrams.forEach(function(d) { %>
      <div class="card">
        <div class="card-top <%= d.diagram_type %>"></div>
        <a href="/architecture/<%= d.id %>" style="text-decoration:none;color:inherit">
        <div class="card-body">
          <h3><%= d.name %></h3>
          <div class="c-meta">
            <span><i data-lucide="building" style="width:12px;height:12px"></i> <%= d.client_name %></span>
            <span class="badge-<%= d.diagram_type %> badge"><%= d.diagram_type.replace('_',' ') %></span>
            <span><i data-lucide="box" style="width:12px;height:12px"></i> <%= d.node_count || 0 %> comp.</span>
          </div>
          <% if (d.description) { %>
          <div class="c-desc"><%= d.description.length > 100 ? d.description.substring(0,100) + '...' : d.description %></div>
          <% } %>
        </div>
        </a>
        <div class="card-actions">
          <a href="/architecture/<%= d.id %>" class="btn btn-ghost"><i data-lucide="edit-3" style="width:12px;height:12px"></i> Bewerk</a>
          <a href="/architecture/report/<%= d.id %>" class="btn btn-ghost"><i data-lucide="file-text" style="width:12px;height:12px"></i> Rapport</a>
          <form method="POST" action="/architecture/<%= d.id %>/delete" style="margin-left:auto" onsubmit="return confirm('Diagram \"<%= d.name %>\" verwijderen?')">
            <button class="btn btn-red" type="submit"><i data-lucide="trash-2" style="width:12px;height:12px"></i></button>
          </form>
        </div>
      </div>
      <% }) %>
    </div>
    <% } %>
  </div>
  <script>lucide.createIcons()</script>
<script src="/js/theme.js"></script></body>
</html>
