<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Receipt - Order <%= orderId %></title>
  <style>
    @media print {
      body {
        width: 58mm;
        font-family: 'Courier New', monospace;
        font-size: 12px;
        margin: 0;
        padding: 0;
      }
      .receipt {
        width: 58mm;
        padding: 5px;
      }
      button {
        display: none;
      }
    }
    body {
      font-family: 'Courier New', monospace;
      font-size: 12px;
      background: white;
      margin: 0;
      padding: 10px;
      width: 58mm;
    }
    .receipt {
      width: 58mm;
      margin: auto;
      padding: 5px;
      border: 1px solid #ccc;
    }
    .center {
      text-align: center;
    }
    .item {
      display: flex;
      justify-content: space-between;
      margin-bottom: 2px;
    }
    .bold {
      font-weight: bold;
    }
    button {
      display: block;
      margin: 10px auto;
      padding: 8px 16px;
      font-size: 14px;
      cursor: pointer;
    }
    hr {
      border: 0;
      border-top: 1px dashed #999;
      margin: 8px 0;
    }
  </style>
</head>
<body>
  <div class="receipt">
    <div class="center bold">My Shop</div>
    <div class="center">Table No: <%= tableNumber %></div>
    <div class="center"><%= new Date(created_at).toLocaleString() %></div>
    <hr />
    <% items.forEach(function(item){ %>
      <div class="item">
        <span><%= item.name %> - Qty: <%= item.quantity %>, ₹<%= item.price.toFixed(2) %></span>
        <span>₹<%= (item.price * item.quantity).toFixed(2) %></span>
      </div>
    <% }); %>
    <hr />
    <div class="item">
      <span>Subtotal</span>
      <span>₹<%= subtotal.toFixed(2) %></span>
    </div>
    <% if(discount > 0) { %>
      <div class="item">
        <span>Discount (<%= offerPercent %>%)</span>
        <span>-₹<%= discount.toFixed(2) %></span>
      </div>
    <% } %>
    <div class="item">
      <span>Tax</span>
      <span>₹<%= taxAmount.toFixed(2) %></span>
    </div>
    <hr />
    <div class="item bold">
      <span>Total</span>
      <span>₹<%= total.toFixed(2) %></span>
    </div>
    <hr />
    <div class="center">Thank you!</div>
  </div>
  <button onclick="window.print()">Print Receipt</button>
</body>
</html>
