<!doctype html>
<html lang="vi">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><%= title %> | Robot Installer</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="/vendor/notiflix/notiflix-<%= notiflixVersion %>.min.css">
  <link rel="stylesheet" href="/css/styles.css">
</head>
<body class="app-shell" <% if (notice) { %>data-notice-type="<%= notice.type %>" data-notice="<%= notice.message %>"<% } %>>
  <aside id="appSidebar" class="sidebar" aria-label="Main navigation">
    <div class="brand-block">
      <div class="brand-mark">
        <span class="material-symbols-outlined">precision_manufacturing</span>
      </div>
      <div class="brand-copy">
        <strong>Robot Installer</strong>
        <span>Package Console</span>
      </div>
    </div>

    <nav class="nav-section" aria-label="Workspace">
      <span class="nav-label">Workspace</span>
      <% navItems.forEach((item) => { %>
        <a href="<%= item.href %>" class="nav-item <%= active === item.id ? 'active' : '' %>">
          <span class="material-symbols-outlined"><%= item.icon %></span>
          <span><%= item.label %></span>
        </a>
      <% }) %>
    </nav>

    <div class="sidebar-status">
      <span class="status-dot"></span>
      <div>
        <strong>SQL Server</strong>
        <span><%= databaseLabel %></span>
      </div>
    </div>
  </aside>

  <button id="sidebarBackdrop" type="button" aria-label="Đóng menu"></button>

  <main id="appMain" class="main-shell">
    <header class="topbar">
      <div class="topbar-left">
        <button id="mobileMenuBtn" class="icon-button" type="button" aria-label="Mở menu" aria-expanded="false">
          <span class="material-symbols-outlined">menu</span>
        </button>
      </div>

      <div class="topbar-actions">
        <button class="icon-button" type="button" title="Đồng bộ dữ liệu" data-refresh-page>
          <span class="material-symbols-outlined">sync</span>
        </button>
        <button class="icon-button" type="button" title="Thông báo" data-toast="Chưa có thông báo mới">
          <span class="material-symbols-outlined">notifications</span>
        </button>
        <% if (currentUser.role === 'User') { %>
          <button class="profile-chip profile-chip-button" type="button" title="Cập nhật thông tin cá nhân" aria-label="Cập nhật thông tin cá nhân" data-modal-open="profileModal">
            <span class="profile-avatar"><%= currentUser.name.charAt(0) %></span>
            <span class="profile-meta">
              <strong><%= currentUser.name %></strong>
              <span><%= currentUser.role %></span>
            </span>
          </button>
        <% } else { %>
          <div class="profile-chip">
            <span class="profile-avatar"><%= currentUser.name.charAt(0) %></span>
            <span class="profile-meta">
              <strong><%= currentUser.name %></strong>
              <span><%= currentUser.role %></span>
            </span>
          </div>
        <% } %>
        <form class="logout-form" method="post" action="/logout">
          <button class="icon-button" type="submit" title="Đăng xuất" aria-label="Đăng xuất">
            <span class="material-symbols-outlined">logout</span>
          </button>
        </form>
      </div>
    </header>

    <div id="mainContent" class="main-content">
