<?php
$active = 'home';
$pageTitle = $department['name'];
require __DIR__ . '/../layout/workspace_header.php';
?>
<div class="topbar">
  <div>
    <h1><?= htmlspecialchars($department['name']) ?></h1>
    <div class="crumbs"><a href="/workspace" style="color:var(--blue-600);">Workspace</a> → <?= htmlspecialchars($department['name']) ?></div>
  </div>
  <div class="user-chip"><span class="dot"></span> <?= htmlspecialchars($user['name']) ?></div>
</div>

<div class="card">
  <h3>Projects in this Department</h3>
  <?php if (empty($projects)): ?>
    <p style="color:var(--text-muted);font-size:13px;">No projects assigned to you in this department.</p>
  <?php else: ?>
    <div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px;">
      <?php foreach ($projects as $p): ?>
        <a href="/project?id=<?= $p['id'] ?>" style="display:block;border:1px solid var(--border);border-radius:12px;padding:16px;">
          <div style="font-weight:700;margin-bottom:4px;"><?= htmlspecialchars($p['name']) ?></div>
          <span class="badge badge-manager"><?= htmlspecialchars($p['status'] ?? 'active') ?></span>
        </a>
      <?php endforeach; ?>
    </div>
  <?php endif; ?>
</div>

<?php require __DIR__ . '/../layout/admin_footer.php'; ?>
