<!DOCTYPE html>
<html>
<head>
  <title>Ingredients Management</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 20px;
      background-color: #f8f9fa;
    }
    .container {
      max-width: 800px;
      margin: auto;
      background: #fff;
      padding: 20px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      border-radius: 8px;
    }
    h1 {
      text-align: center;
      color: #333;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin-bottom: 20px;
    }
    table, th, td {
      border: 1px solid #ddd;
    }
    th, td {
      padding: 8px;
      text-align: left;
    }
    th {
      background-color: #f2f2f2;
    }
    .form-group {
      margin-bottom: 20px;
    }
    .form-group label {
      display: block;
      margin-bottom: 5px;
    }
    .form-group input, .form-group select, .form-group button {
      width: 100%;
      padding: 10px;
      margin-bottom: 10px;
      border-radius: 4px;
      border: 1px solid #ccc;
    }
    .form-group button {
      background-color: #28a745;
      color: #fff;
      cursor: pointer;
    }
    .form-group button:hover {
      background-color: #218838;
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>Ingredients Management</h1>
    <table>
      <tr>
        <th>Ingredient</th>
        <th>Quantity</th>
      </tr>
      <% for (let ingredient in ingredients) { %>
        <tr>
          <td><%= ingredient %></td>
          <td><%= ingredients[ingredient] %></td>
        </tr>
      <% } %>
    </table>
    
    <h2>Modify Existing Ingredients</h2>
    <form action="/ingredients" method="POST">
      <div class="form-group">
        <label for="ingredient">Ingredient</label>
        <select name="ingredient" id="ingredient">
          <% for (let ingredient in ingredients) { %>
            <option value="<%= ingredient %>"><%= ingredient %></option>
          <% } %>
        </select>
      </div>
      <div class="form-group">
        <label for="action">Action</label>
        <select name="action" id="action">
          <option value="add">Add</option>
          <option value="subtract">Subtract</option>
        </select>
      </div>
      <div class="form-group">
        <label for="quantity">Quantity</label>
        <input type="number" name="quantity" id="quantity" required min="1">
      </div>
      <div class="form-group">
        <button type="submit">Submit</button>
      </div>
    </form>
    
    <h2>Add New Ingredient</h2>
    <form action="/ingredients" method="POST">
      <div class="form-group">
        <label for="newIngredient">New Ingredient</label>
        <input type="text" name="newIngredient" id="newIngredient" required>
      </div>
      <div class="form-group">
        <label for="newQuantity">Quantity</label>
        <input type="number" name="newQuantity" id="newQuantity" required min="1">
      </div>
      <div class="form-group">
        <button type="submit">Add Ingredient</button>
      </div>
    </form>
  </div>
</body>
</html>
