<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Receipt Print</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>

<style>
body {
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  margin: 0;
  padding: 20px;
}

/* === INVOICE STYLE === */
.invoice-container {
  background: #fff;
  padding: 20px;
  max-width: 500px;
  margin: auto;
  border-radius: 10px;
  box-shadow: 0 0 5px rgba(0,0,0,0.1);
}

.invoice-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-area img {
  width: 50px;
  height: auto;
}

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

.invoice-title h4 {
  margin: 0;
  font-size: 18px;
  color: #261756;
}

.invoice-title small {
  color: #777;
  font-size: 12px;
}

.middle-icon {
  text-align: center;
  margin: 15px 0;
}

.middle-icon i {
  font-size: 40px;
  color: green;
}

.reciept-block p {
  display: flex;
  justify-content: space-between;
  margin: 5px 0;
  font-size: 13px;
}

.span-left { color: #888; }
.span-right { font-weight: bold; }

.items-list {
  margin-top: 15px;
}

.items-list ul {
  margin: 0;
  padding-left: 20px;
}

.total {
  text-align: right;
  font-weight: bold;
  font-size: 14px;
  margin-top: 10px;
}

.btns {
  text-align: center;
  margin-top: 20px;
}

.btns button {
  margin: 5px;
  padding: 8px 15px;
  font-size: 14px;
  border: none;
  border-radius: 5px;
  color: white;
  background: #1976d2;
  cursor: pointer;
}

.btns button:hover {
  background: #004ba0;
}

/* === PRINT AREA === */
@media print {
  @page {
    size: A4;
    margin: 10mm;
  }
  /* Hide or simplify sidebar */
  .sideNav {
    position: static !important;
    height: auto !important;
    transform: none !important;
    background: none !important;
    color: #000 !important;
  }

  /* Adjust main content area */
  .page-overall {
    padding-left: 0 !important;
    width: 100% !important;
  }

  /* Optional: hide mobile toggle buttons and other nav */
  .mobile-btn, .bar-status {
    display: none !important;
  }
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body * {
    visibility: hidden !important;
  }

  #invoiceArea, #invoiceArea * {
    visibility: visible !important;
  }

  #invoiceArea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  .btns {
    display: none !important;
  }

  .invoice-container {
    box-shadow: none !important;
    page-break-inside: avoid !important;
  }

  /* ✅ Ensure long receipts can continue */
  .invoice-container * {
    page-break-inside: avoid !important;
  }
}
</style>
</head>
<body>

<div class="invoice-container" id="invoiceArea">
  <div class="invoice-top">
    <div class="logo-area"><img src="logo/goodness.jpg" alt="Logo"></div>
    <div class="invoice-title">
      <h4>DE-GOODNESS ACADEMY</h4>
      <small>Official Payment Receipt</small>
    </div>
  </div>

  <div class="middle-icon">
    <i class="fa fa-check-circle"></i>
    <h4>Payment Successful!</h4>
  </div>

  <hr style="border:1px dashed black">
  <div class="reciept-block">
    <p><span class="span-left">Name</span><span class="span-right">Taiwo Tosin Amos</span></p>
    <p><span class="span-left">Admission No</span><span class="span-right">000713</span></p>
    <p><span class="span-left">Class</span><span class="span-right">JSS3</span></p>
    <p><span class="span-left">Session</span><span class="span-right">2025/2026</span></p>
    <p><span class="span-left">Payment Method</span><span class="span-right">Bank Transfer</span></p>
    <p><span class="span-left">Date</span><span class="span-right">27 Aug 2025</span></p>
  </div>

  <div class="items-list">
    <h5>Items Paid For</h5>
    <ul>
      <li>Tuition</li>
      <li>Uniform</li>
      <li>Sportwears</li>
      <li>Report Card</li>
      <li>Library Fee</li>
      <li>Books</li>
      <li>Exam Fee</li>
      <li>ICT Fee</li>
      <li>PTA Dues</li>
    </ul>
  </div>

  <hr style="border:1px dashed black">
  <div class="total">
    TOTAL AMOUNT: ₦800
  </div>
</div>

<div class="btns">
  <button onclick="printInvoice()">🖨 Print Receipt</button>
  <button onclick="downloadPDF()">⬇ Download PDF</button>
</div>

<script>
function printInvoice() {
  const invoice = document.getElementById('invoiceArea');
  invoice.scrollIntoView({ behavior: 'instant', block: 'start' });
  setTimeout(() => window.print(), 200);
}

function downloadPDF() {
  const element = document.getElementById('invoiceArea');
  const opt = {
    margin: 0.2,
    filename: 'receipt.pdf',
    image: { type: 'jpeg', quality: 0.98 },
    html2canvas: { scale: 2 },
    jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' },
    pagebreak: { mode: ['css', 'legacy'] }
  };
  html2pdf().set(opt).from(element).save();
}
</script>

</body>
</html>