<!DOCTYPE html>
<html lang="nl">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><%= device.name %> — 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">
      <div>
        <a href="/networking" class="back-link">← Netwerk</a>
        </a>
<h1><%= device.name %></h1>
        <p class="subtitle"><%= device.device_type %> — <%= device.client_name %></p>
      </div>
      <div class="header-actions">
        <a href="/networking/devices/<%= device.id %>/edit" class="btn btn-primary">Bewerk</a>
        <a href="/networking/connections/new" class="btn btn-secondary">+ Connectie</a>
      </div>
    </div>

    <div class="detail-grid">
      <div class="detail-card">
        <h3>Device Info</h3>
        <table class="info-table">
          <tr><td>Type</td><td><span class="engagement-type <%= device.device_type %>"><%= device.device_type %></span></td></tr>
          <tr><td>Model</td><td><%= device.model || '-' %></td></tr>
          <tr><td>Manufacturer</td><td><%= device.manufacturer || '-' %></td></tr>
          <tr><td>IP Adres</td><td><code><%= device.ip_address || '-' %></code></td></tr>
          <tr><td>Mgmt IP</td><td><code><%= device.mgmt_ip || '-' %></code></td></tr>
          <tr><td>Poorten</td><td><%= device.ports_count %></td></tr>
          <tr><td>OS</td><td><%= device.os_version || '-' %></td></tr>
          <tr><td>Status</td><td><span class="status-badge <%= device.status %>"><%= device.status %></span></td></tr>
        </table>
      </div>
      <div class="detail-card">
        <h3>Connecties (<%= connections.length %>)</h3>
        <% if (connections.length === 0) { %>
        <p class="client-meta">Geen connecties</p>
        <% } else { %>
        <div class="conn-list">
          <% connections.forEach(function(c) { %>
          <div class="conn-item">
            <span class="conn-name"><%= c.name || 'Connectie' %></span>
            <span class="conn-path">
              <% if (c.from_type === 'network_device' && c.from_id == device.id) { %>
                Poort <%= c.from_port || '?' %> → <%= c.to_type %> <%= c.to_id || '?' %> poort <%= c.to_port || '?' %>
              <% } else { %>
                <%= c.from_type %> <%= c.from_id || '?' %> poort <%= c.from_port || '?' %> → Poort <%= c.to_port || '?' %>
              <% } %>
            </span>
            <span class="conn-meta"><%= c.speed %> · <%= c.media_type %></span>
          </div>
          <% }) %>
        </div>
        <% } %>
      </div>
    </div>

    <% if (device.notes) { %>
    <section class="section">
      <h3 class="section-title">Notities</h3>
      <div class="card"><p><%= device.notes %></p></div>
    </section>
    <% } %>
  </div>
<script src="/js/theme.js"></script></body>
</html>
