<?php  
// Include sidebar
include('../../../dripend/statpages/sidebar.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NHIA Claims Listing | DripDental</title>

<!-- FONT AWESOME -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">

<style>
:root {
  --primary-blue: #004aad;
  --secondary-blue: #0066cc;
  --hover-blue: #0052a3;
  --white: #ffffff;
  --gray-light: #f8f9fa;
  --text-dark: #1f2937;
  --border-color: #d1d5db;
  --danger-red: #d9534f;
  --success-green: #28a745;
  --gold-yellow: #ffda6a;
  --green-light: #e8f5e9;
  --transition: all 0.3s ease;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--gray-light);
  color: var(--text-dark);
  margin: 0;
  padding: 0;
}

.container {
  margin: 40px auto;
  background-color: var(--white);
  max-width: 1300px;
  padding: 25px 30px;
  border-radius: 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.08);
  animation: fadeIn 0.8s ease-in-out;
}

@keyframes fadeIn {
  from {opacity: 0; transform: translateY(10px);}
  to {opacity: 1; transform: translateY(0);}
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 1.8rem;
  color: var(--primary-blue);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.header .actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.header .actions a {
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--white);
  transition: var(--transition);
}

.btn-blue { background-color: var(--primary-blue); }
.btn-blue:hover { background-color: var(--hover-blue); }

.btn-red { background-color: var(--danger-red); }
.btn-red:hover { background-color: #b02a37; }

.btn-export-file {
  background-color: var(--success-green);
}
.btn-export-file:hover {
  background-color: #218838;
}

/* Filter Card */
.filter-card {
  background-color: #f3f7ff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-top: 20px;
  padding: 20px;
}

.filter-card h2 {
  color: var(--primary-blue);
  text-transform: uppercase;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 15px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 15px;
}

.filter-grid label {
  font-weight: 600;
  font-size: 0.9rem;
}

.filter-grid input, .filter-grid select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--white);
  transition: var(--transition);
}

.filter-grid input:focus, .filter-grid select:focus {
  border-color: var(--secondary-blue);
  box-shadow: 0 0 5px rgba(0, 64, 255, 0.15);
  outline: none;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.filter-actions button {
  border: none;
  padding: 9px 18px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--white);
}

.btn-search { background-color: var(--primary-blue); }
.btn-search:hover { background-color: var(--hover-blue); }
.btn-export { background-color: var(--success-green); }
.btn-export:hover { background-color: #218838; }

/* Table Styles */
.claims-card {
  background-color: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  margin-top: 30px;
}

.claims-card h2 {
  font-size: 1rem;
  color: var(--primary-blue);
  text-transform: uppercase;
  margin-bottom: 15px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead {
  background-color: var(--primary-blue);
  color: var(--white);
}

th, td {
  padding: 12px 15px;
  border-bottom: 1px solid #dee2e6;
  text-align: left;
}

tr:hover { background-color: #f5f9ff; }

tr.draft { background-color: var(--gold-yellow); }
tr.finalized { background-color: var(--green-light); }

.action-icons {
  display: flex;
  gap: 8px;
}

.action-icons button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.action-icons button:hover {
  transform: scale(1.15);
}

.fa-plus-circle { color: var(--success-green); }
.fa-eye { color: var(--primary-blue); }
.fa-pen { color: #ffb300; }
.fa-ban { color: var(--danger-red); }

/* Modal Styling */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: var(--white);
  padding: 25px;
  border-radius: 10px;
  width: 500px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  animation: popup 0.35s ease;
}

@keyframes popup {
  from {transform: scale(0.9); opacity: 0;}
  to {transform: scale(1); opacity: 1;}
}

.modal-content h3 {
  margin-top: 0;
  color: var(--primary-blue);
  font-size: 1.2rem;
}

.modal-actions {
  text-align: right;
  margin-top: 15px;
}

.modal-actions button {
  padding: 8px 15px;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

.btn-close {
  background: var(--danger-red);
  color: var(--white);
}
.btn-save {
  background: var(--success-green);
  color: var(--white);
}
</style>
</head>

<body>
<div class="container">

  <div class="header">
    <h1>NHIA Claims Listing</h1>
    <div class="actions">
      <a href="../insurance_claims_dashboard.php" class="btn-blue"><i class="fa-solid fa-file-invoice"></i> Go to Insurance Claims</a>
      <a href="../../../../application/dashboard.php" class="btn-red"><i class="fa-solid fa-home"></i> Go to Main Dashboard</a>
      <a href="ExportNHIAClaimFormToXML.php" class="btn-export-file"><i class="fa-solid fa-file-export"></i> Export Claimit File</a>
    </div>
  </div>

  <!-- CLAIM TABLE -->
  <div class="claims-card">
    <h2>NHIA Claim Form Listing</h2>
    <div class="table-wrapper">
      <table>
        <thead>
          <tr>
            <th>#</th><th>Category</th><th>Patient</th><th>NHIA No.</th>
            <th>Visit No.</th><th>Bill No.</th><th>Usage Date</th>
            <th>Form No.</th><th>Status</th><th>Clinic</th><th>Actions</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>3</td><td>OPD</td><td>ALBERTA NARTEY</td><td>35251145</td><td>ADMT-6232</td>
            <td>IB-2510270007</td><td>27-10-2025</td><td>--</td><td>Not Generated</td><td>St. Andrew Catholic Hospital</td>
            <td class="action-icons">
              <button title="Generate Claim Form" onclick="openModal('confirmGenerateModal')"><i class="fa-solid fa-plus-circle"></i></button>
              <button title="Edit" onclick="openModal('editModal')"><i class="fa-solid fa-pen"></i></button>
              <button title="Deactivate" onclick="openModal('deactivateModal')"><i class="fa-solid fa-ban"></i></button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

<!-- GENERATE CONFIRMATION MODAL -->
<div id="confirmGenerateModal" class="modal">
  <div class="modal-content">
    <h3>Confirm Claim Generation</h3>
    <p>Are you sure you want to generate this NHIA claim form for this patient? This action will open the claim generation page.</p>
    <div class="modal-actions">
      <button class="btn-close" onclick="closeModal('confirmGenerateModal')">Cancel</button>
      <button class="btn-save" onclick="proceedToGenerate()">Proceed</button>
    </div>
  </div>
</div>

<script>
function openModal(id) {
  document.getElementById(id).style.display = "flex";
}
function closeModal(id) {
  document.getElementById(id).style.display = "none";
}
function proceedToGenerate() {
  closeModal('confirmGenerateModal');
  setTimeout(() => {
    window.location.href = "generateNhiaClaim.php";
  }, 500);
}
window.onclick = function(event) {
  const modals = document.querySelectorAll('.modal');
  modals.forEach(m => {
    if (event.target == m) m.style.display = "none";
  });
}
</script>
</body>
</html>
