

<style>

#payment-form { display: none; margin-top: 20px;}
        label { display: block; margin-bottom: 5px; }
        input, select { width: 100%; padding: 8px; margin-bottom: 10px; box-sizing: border-box; }
        button { padding: 10px 20px; cursor: pointer; }
        .error { color: red; }
        #customer-dropdown {
            width: 100%;
            box-sizing: border-box;
        }
        #customer-list {
            position: absolute;
            z-index: 10;
            background-color: white;
            border: 1px solid #ccc;
            max-height: 200px;
            overflow-y: auto;
            display: none; /* Initially hidden */
            width: 100%;
            box-sizing: border-box;
        }
        #customer-list li {
            padding: 5px;
            cursor: pointer;
        }
        #customer-list li:hover {
            background-color: #f0f0f0;
        }






    




/* Style the table */
#customerTable {
  width:90%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
  margin-left: 20px !important;
  margin-right: 20px !important;
}


#customerTable th, #customerTable td {
    font-size: 14px;
  padding: 2px 3px;
  border: none;
  padding-left: 15px;
  border-bottom: 1px solid #ddd;
}

#customerTable tr:hover {
  background-color: #f1f1f1;
}

/* Style the buttons */
.add-payment-btn, .view-history-btn {
  padding: 8px 12px;
  margin-right: 5px;
  font-size: 12px;
  width: 110px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

.add-payment-btn {
  background-color: #28a745;
  color: white;
}

.view-history-btn {
  background-color: #007bff;
  color: white;
}

.add-payment-btn:hover, .view-history-btn:hover {
  background-color: #0056b3;
  transform: scale(1.05);
}

.add-payment-btn:focus, .view-history-btn:focus {
  outline: none;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

.edit-btn, .delete-btn {
  padding: 8px 12px;
  margin-right: 5px;
  font-size: 12px;
  width: 110px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

.edit-btn {
  background-color: #28a745;
  color: white;
}

.delete-btn {
  background-color: #f84a2b;
  color: white;
}


.oneRow {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start; /* align-items instead of justify-items */
}




/* Container Styling */
.closeModalContainer {
    position: relative; /* Ensure button stays within the container */
    display: flex;
    justify-content: flex-end; /* Align button to the right */
    padding: 10px;
}

/* Close Button Styling */
.closeModal {
    background: none; /* Remove default button background */
    border: none; /* Remove border */
    font-size: 20px; /* Adjust size */
    font-weight: bold;
    color: #333; /* Dark gray text */
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%; /* Make it circular */
    transition: all 0.3s ease-in-out;
}

/* Hover & Focus Effect */
.closeModal:hover,
.closeModal:focus {
    background-color: #f8d7da; /* Light red background */
    color: #d9534f; /* Red close icon */
    transform: scale(1.1); /* Slight zoom effect */
}

/* Active Click Effect */
.closeModal:active {
    transform: scale(0.9);
}


.flex-table {
  display: flex; /* Make the container a flexbox */
  flex-direction: column; /* Arrange elements vertically */
  width: 100%; /* Set full width */
  font-size: 12px;
}

#historyTable {
  border-collapse: collapse; /* Remove border gaps between cells */
  width: 100%; /* Set table width to 100% */
}

#historyTable th
{ margin: 0;
  padding: 0;
  background-color: #14d347; /* Add a light grey background for headers */
  font-weight: bold; /* Make headers bold */
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  border-left: none;
  border-right: none;
  padding-left: 10px !important; /* Ensure left padding applies */
  text-align: left;
  font-size: 12px;
}







#historyTableBody td {
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  border-left: none;
  border-right: none;
  padding-left: 20px !important; /* Ensure left padding applies */
  text-align: left;
}




#historyTable tbody tr:nth-child(even) {
  background-color: #f9f9f9; /* Alternate row background colors */
}

#historyTable button {
  border: none; /* Remove default button border */
  padding: 5px 10px; /* Set button padding */
  background-color: #3184f8; /* Set button background color */
  cursor: pointer; /* Make it look clickable */
}

#historyTable button:hover {
  background-color: #ccc; /* Change background on hover */
}

</style>

<div class="main-content1">
    <h3 style="justify-content: center;">Customers Balance </h3>

<diV class="customer-Table">
<table id="customerTable">
  
</table>
</diV>


<diV id="historyTableDiv" class="modal"  >
<div class="modal-content2">
  
  <div class="closeModalContainer">
    <button id="closeHistoryModal" class="closeModal">x</button>
</div>



   <div class="row">
      <div>


    
Name:
<span  style="color: #28a745;" id="customerName"> </span>
</div>

<div>
Balance:
<span  style="margin-right: 30px;"  id="customerBalance"> </span>
</div>

</div>
<div class="flex-table">
    <table id="historyTable">
     
        <tr>
            <th>Date</th>
            <th>Credit</th>
          <th>Paid</th>
       
          <th>Desc</th>
          <th>Action</th>
        </tr>
   
      <tbody id="historyTableBody">
        <!-- Table rows will be dynamically inserted here -->
      </tbody>
    </table>
  </div>
  
    </diV>
</diV>

   


    <diV id="paymentFormDiv" class="modal" >
        <div class="modal-content">

  
            <div class="closeModalContainer"><div>
                <button id="closeEditModal" class="closeModal">X</button>
              </div>
              </div>


            <div id="payment-form">
        
        <form id="payment-form-element">
            <input type="hidden" id="payment-id">
            <label for="customer-dropdown">Customer:</label>
            <input type="text" id="customer-dropdown" autocomplete="off">
            <ul id="customer-list"></ul>
            <div class="error" id="form-error"></div>
            <label for="paid">Paid Amount:</label>
            <input type="number" id="paid" value="0">
            <label for="credit">Credit Amount:</label>
            <input type="number" id="credit" value="0">
            <label for="description">Description:</label>
            <input type="text" id="description">
            <button type="submit">Save</button>
            <button type="button" id="cancel-btn">Cancel</button>
        </form>
    </div>

    <ul id="payment-list"></ul>
    <div class="error" id="list-error"></div>
    
</div>
</diV>


    <script src="./js/paymentHistory.js"></script>
</div>
