{{define "content"}}
<div class="page-header">
  <div>
    <h1 class="page-title">Active Directory</h1>
    <p class="page-sub">{{len .Computers}} Computer-Objekte aus {{.Domain}}</p>
  </div>
</div>

{{if not .ADEnabled}}
<div style="background:rgba(232,162,58,.08);border:1px solid rgba(232,162,58,.3);border-radius:var(--r-lg);padding:20px 24px;margin-bottom:20px;">
  <div style="font-weight:600;color:var(--warning);margin-bottom:6px;">AD Sync nicht konfiguriert</div>
  <div style="font-size:13px;color:var(--text-2);">Trage Server, Bind-DN und Passwort in der <a href="/settings" style="color:var(--teal);">config.yaml</a> ein und aktiviere das Modul.</div>
</div>
{{end}}

<!-- Stats -->
<div class="stats-grid" style="grid-template-columns:repeat(3,1fr);margin-bottom:20px;">
  <div class="stat">
    <div class="stat-label">Computer in AD</div>
    <div class="stat-value">{{len .Computers}}</div>
    <div class="stat-delta neutral">{{.Domain}}</div>
  </div>
  <div class="stat">
    <div class="stat-label">Im Netzwerk gesehen</div>
    <div class="stat-value" style="color:var(--success);">{{.SeenCount}}</div>
    <div class="stat-delta up">↑ aktiv erreichbar</div>
  </div>
  <div class="stat">
    <div class="stat-label">Nicht gesehen</div>
    <div class="stat-value" style="{{if gt .MissingCount 0}}color:var(--warning);{{end}}">{{.MissingCount}}</div>
    <div class="stat-delta {{if gt .MissingCount 0}}down{{else}}neutral{{end}}">offline oder abwesend</div>
  </div>
</div>

<div class="card">
  <table>
    <thead>
      <tr>
        <th>Computer-Name</th>
        <th>Abteilung / OU</th>
        <th>Betriebssystem</th>
        <th>Letzter Login (AD)</th>
        <th>Im Netzwerk</th>
      </tr>
    </thead>
    <tbody>
      {{range .Computers}}
      <tr>
        <td style="font-weight:600;">{{.CN}}</td>
        <td style="color:var(--text-2);">{{if .Department}}{{.Department}}{{else}}<span style="color:var(--text-3);">—</span>{{end}}</td>
        <td style="color:var(--text-2);font-size:12px;">{{if .OS}}{{.OS}}{{else}}<span style="color:var(--text-3);">—</span>{{end}}</td>
        <td style="color:var(--text-3);font-size:12px;">
          {{if not .LastLogon.IsZero}}{{formatTime .LastLogon}}{{else}}—{{end}}
        </td>
        <td>
          {{if .SeenInNetwork}}
          <span class="badge badge-green"><span class="dot green" style="width:5px;height:5px;margin-right:4px;"></span>Online</span>
          {{else}}
          <span class="badge badge-yellow">Nicht gesehen</span>
          {{end}}
        </td>
      </tr>
      {{else}}
      <tr><td colspan="5" style="text-align:center;padding:48px;color:var(--text-3);">
        Noch keine AD-Daten — AD Sync ausführen.
      </td></tr>
      {{end}}
    </tbody>
  </table>
</div>
{{end}}
