<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><%= title %> | Ecofina Billing</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="<%= url('/public/css/app.css') %>">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark shadow-sm">
  <div class="container-fluid">
    <a class="navbar-brand brand-mark" href="<%= url('/dashboard') %>">ECOFINA</a>
    <% if (user) { %>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav"><span class="navbar-toggler-icon"></span></button>
    <div class="collapse navbar-collapse" id="nav">
      <ul class="navbar-nav me-auto">
        <li class="nav-item"><a class="nav-link <%= currentPath.startsWith('/dashboard') ? 'active' : '' %>" href="<%= url('/dashboard') %>">Dashboard</a></li>
        <li class="nav-item"><a class="nav-link <%= currentPath.startsWith('/invoices/create') ? 'active' : '' %>" href="<%= url('/invoices/create') %>">Create Bill</a></li>
        <li class="nav-item"><a class="nav-link <%= currentPath === '/invoices' ? 'active' : '' %>" href="<%= url('/invoices') %>">Bills</a></li>
        <li class="nav-item"><a class="nav-link <%= currentPath.startsWith('/reports') ? 'active' : '' %>" href="<%= url('/reports') %>">Reports</a></li>
        <li class="nav-item"><a class="nav-link <%= currentPath.startsWith('/settings') ? 'active' : '' %>" href="<%= url('/settings') %>">Settings</a></li>
      </ul>
      <div class="dropdown">
        <button class="btn btn-sm btn-outline-light dropdown-toggle" data-bs-toggle="dropdown"><%= user.name %></button>
        <ul class="dropdown-menu dropdown-menu-end">
          <li><a class="dropdown-item" href="<%= url('/change-password') %>">Change Password</a></li>
          <li><hr class="dropdown-divider"></li>
          <li><form method="post" action="<%= url('/logout') %>"><button class="dropdown-item">Logout</button></form></li>
        </ul>
      </div>
    </div>
    <% } %>
  </div>
</nav>
<main class="container-fluid py-4 px-lg-5">
  <% if (success && success.length) { %><div class="alert alert-success"><%= success[0] %></div><% } %>
  <% if (error && error.length) { %><div class="alert alert-danger"><%= error[0] %></div><% } %>
  <%- body %>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<%- script || '' %>
</body>
</html>
