#!/bin/bash

read -p "PRICE [\$50] : " PRICE
[[ -z $PRICE ]] && PRICE="50"

read -p "CUSTOMER: " CUSTOMER 
[[ -z CUSTOMER ]] && exit 

DATE="$(date +%m/%d/%Y)"
DUEDATE="$(date -d "+14 days" +%m/%d/%Y)"

INVNUM="INV-$(date +%Y%m%d-%S)"
cat << EOF > output.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Invoice - Experienced Coaches</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background: #f0f2f5;
      color: #333;
      line-height: 1.6;
      padding: 40px 20px;
    }

    .invoice-container {
      max-width: 800px;
      margin: 0 auto;
      background: #fff;
      border-radius: 8px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.08);
      overflow: hidden;
    }

    .invoice-header {
      background: #2c3e50;
      color: #fff;
      padding: 40px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
    }

    .company-info h1 {
      font-size: 28px;
      margin-bottom: 8px;
      font-weight: 700;
    }

    .company-info p {
      font-size: 14px;
      opacity: 0.85;
      margin-bottom: 4px;
    }

    .invoice-meta {
      text-align: right;
    }

    .invoice-meta h2 {
      font-size: 32px;
      font-weight: 300;
      letter-spacing: 4px;
      margin-bottom: 12px;
    }

    .invoice-meta p {
      font-size: 14px;
      opacity: 0.85;
      margin-bottom: 4px;
    }

    .invoice-body {
      padding: 40px;
    }

    .invoice-parties {
      display: flex;
      justify-content: space-between;
      margin-bottom: 40px;
    }

    .party {
      flex: 1;
    }

    .party h3 {
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      color: #888;
      margin-bottom: 8px;
    }

    .party p {
      font-size: 14px;
      margin-bottom: 4px;
    }

    .party .name {
      font-size: 16px;
      font-weight: 600;
      color: #2c3e50;
    }

    .invoice-table {
      width: 100%;
      border-collapse: collapse;
      margin-bottom: 30px;
    }

    .invoice-table thead {
      background: #f8f9fa;
    }

    .invoice-table th {
      padding: 14px 16px;
      text-align: left;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: #666;
      border-bottom: 2px solid #e9ecef;
    }

    .invoice-table th:last-child,
    .invoice-table td:last-child {
      text-align: right;
    }

    .invoice-table td {
      padding: 16px;
      font-size: 14px;
      border-bottom: 1px solid #e9ecef;
    }

    .invoice-table .item-name {
      font-weight: 600;
      color: #2c3e50;
    }

    .invoice-table .item-desc {
      font-size: 13px;
      color: #888;
    }

    .totals {
      max-width: 300px;
      margin-left: auto;
    }

    .totals-row {
      display: flex;
      justify-content: space-between;
      padding: 10px 16px;
      font-size: 14px;
    }

    .totals-row.total {
      border-top: 2px solid #2c3e50;
      margin-top: 8px;
      padding-top: 14px;
      font-size: 18px;
      font-weight: 700;
      color: #2c3e50;
    }

    .invoice-footer {
      background: #f8f9fa;
      padding: 30px 40px;
      border-top: 1px solid #e9ecef;
    }

    .invoice-footer p {
      font-size: 13px;
      color: #666;
      margin-bottom: 4px;
    }

    .invoice-footer .thanks {
      font-size: 15px;
      font-weight: 600;
      color: #2c3e50;
      margin-bottom: 8px;
    }

    @media print {
      body {
        background: #fff;
        padding: 0;
      }
      .invoice-container {
        box-shadow: none;
        border-radius: 0;
      }
    }
  </style>
</head>
<body>
  <div class="invoice-container">

    <!-- Header -->
    <div class="invoice-header">
      <div class="company-info">
        <h1>My Company</h1>
        <p>1231 Oak Blvd</p>
        <p>Phone: (555) 555-5555</p>
      </div>
      <div class="invoice-meta">
        <h2>INVOICE</h2>
        <p>Invoice #: $INVNUM</p>
        <p>Date: $DATE</p>
        <p>Due: $DUEDATE</p>
      </div>
    </div>

    <!-- Body -->
    <div class="invoice-body">

      <!-- Parties -->
      <div class="invoice-parties">
        <div class="party">
          <h3>Bill To</h3>
          <p class="name">$CUSTOMER</p>
        </div>
        <div class="party">
          <h3>From</h3>
          <p class="name">Experienced Coaches</p>
          <p>123 Elm Street</p>
          <p>New York, NY</p>
          <p>(555) 555-1234</p>
        </div>
      </div>

      <!-- Line Items -->
      <table class="invoice-table">
        <thead>
          <tr>
            <th>Description</th>
            <th>Qty</th>
            <th>Rate</th>
            <th>Amount</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>
              <div class="item-name">1 Hour Session – Sports Lesson</div>
              <div class="item-desc">Private 1-hour sports coaching session</div>
            </td>
            <td>1</td>
            <td>\$$PRICE</td>
            <td>\$$PRICE</td>
          </tr>
        </tbody>
      </table>

      <!-- Totals -->
      <div class="totals">
        <div class="totals-row">
          <span>Subtotal</span>
          <span>\$$PRICE</span>
        </div>
        <div class="totals-row">
          <span>Tax (0%)</span>
          <span>\$0.00</span>
        </div>
        <div class="totals-row total">
          <span>Total Due</span>
          <span>\$$PRICE</span>
        </div>
      </div>

    </div>

    <!-- Footer -->
    <div class="invoice-footer">
      <p class="thanks">Thank you for your business!</p>
      <p>Payment due within 15 days. Please make checks payable to Experienced Coaches.</p>
      <p>Questions? Call us at (555) 555-1234.</p>
    </div>

  </div>
</body>
</html>  
EOF

brave-browser --headless --no-pdf-header-footer --print-to-pdf="invoice.pdf" "output.html"


