<!-- M-Pesa Settings Modal -->
<div class="modal fade" id="mpesaSettingsModal" tabindex="-1" aria-labelledby="mpesaSettingsModalLabel" aria-hidden="true">
    <form class="mpesa" action="/settings/api/mpesa/create" method="post" enctype="multipart/form-data">
        <div class="modal-dialog modal-xl modal-dialog-scrollable">
            <div class="modal-content">
                <!-- Modal Header -->
                <div class="modal-header bg-primary text-white">
                    <h5 class="modal-title" id="mpesaSettingsModalLabel">
                        <i class="bi bi-phone me-2"></i> M-Pesa Daraja API Settings
                    </h5>
                    <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>

                <!-- Modal Body -->
                <div class="modal-body">
                    <div class="container-fluid">
                        <!-- Warning Alert -->
                        <div class="alert alert-warning mb-4">
                            <i class="bi bi-exclamation-triangle-fill me-2"></i>
                            <strong>Important:</strong> Please use below Mpesa Developer Settings only if you know what it does...
                        </div>

                        <!-- Information Card -->
                        <div class="card mb-4">
                            <div class="card-body">
                                <h6 class="card-title"><i class="bi bi-info-circle me-2"></i>Configure Mpesa Endpoints Settings</h6>
                                <p class="card-text mb-0">Configure your M-Pesa Daraja API credentials and endpoints for payment processing.</p>
                            </div>
                        </div>

                        <!-- Settings Form -->
                        <form id="mpesaApiSettingsForm">
                            <div class="row g-3">
                                <!-- Basic Settings -->
                                <div class="col-12">
                                    <h6 class="border-bottom pb-2 mb-3">Basic Settings</h6>
                                </div>

                                <!-- Shortcode Type -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="shortcodeType" class="form-label">Mpesa Shortcode Type *</label>
                                    <select class="form-select" id="shortcodeType" name="shortcodeType" required>
                                        <option value="1">Till Number</option>
                                        <option value="2">Paybill Number</option>
                                    </select>
                                </div>

                                <!-- Environment -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="apiEnvironment" class="form-label">Environment *</label>
                                    <select class="form-select" id="apiEnvironment" name="apiEnvironment" required>
                                        <option value="1">Live</option>
                                        <option value="2">Sandbox</option>
                                    </select>
                                </div>

                                <!-- Status -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="apiStatus" class="form-label">Status *</label>
                                    <select class="form-select" id="apiStatus" name="apiStatus" required>
                                        <option value="1">Active</option>
                                        <option value="2">Inactive</option>
                                    </select>
                                </div>

                                <!-- API Credentials -->
                                <div class="col-12 mt-3">
                                    <h6 class="border-bottom pb-2 mb-3">API Credentials</h6>
                                </div>

                                <!-- Consumer Key -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="consumerKey" class="form-label">Consumer Key *</label>
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="consumerKey" name="consumerKey" placeholder="Enter Consumer Key" required>
                                        <button class="btn btn-outline-secondary toggle-password" type="button" data-target="consumerKey">
                                            <i class="bi bi-eye"></i>
                                        </button>
                                    </div>
                                </div>

                                <!-- Consumer Secret -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="consumerSecret" class="form-label">Consumer Secret *</label>
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="consumerSecret" name="consumerSecret" placeholder="Enter Consumer Secret" required>
                                        <button class="btn btn-outline-secondary toggle-password" type="button" data-target="consumerSecret">
                                            <i class="bi bi-eye"></i>
                                        </button>
                                    </div>
                                </div>

                                <!-- Pass Key -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="passKey" class="form-label">Pass Key *</label>
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="passKey" name="passKey" placeholder="Enter Pass Key" required>
                                        <button class="btn btn-outline-secondary toggle-password" type="button" data-target="passKey">
                                            <i class="bi bi-eye"></i>
                                        </button>
                                    </div>
                                    <div class="form-text">
                                        <small>IT administrator should request the Pass Key from Safaricom Daraja API.</small>
                                    </div>
                                </div>

                                <!-- Business Information -->
                                <div class="col-12 mt-3">
                                    <h6 class="border-bottom pb-2 mb-3">Business Information</h6>
                                </div>

                                <!-- Business Shortcode -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="businessShortcode" class="form-label">Business Shortcode *</label>
                                    <input type="text" class="form-control" id="businessShortcode" name="businessShortcode" placeholder="Enter Business Shortcode" required>
                                </div>

                                <!-- Business MSISDN -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="businessMsisdn" class="form-label">Business MSISDN *</label>
                                    <input type="text" class="form-control" id="businessMsisdn" name="businessMsisdn" placeholder="2547XXXXXXXX" required>
                                    <div class="form-text">
                                        <small>Format: 2547XXXXXXXX</small>
                                    </div>
                                </div>

                                <!-- Party A -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="partyA" class="form-label">Party A *</label>
                                    <input type="text" class="form-control" id="partyA" name="partyA" placeholder="Enter Party A" required>
                                </div>

                                <!-- Party B -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="partyB" class="form-label">Party B *</label>
                                    <input type="text" class="form-control" id="partyB" name="partyB" placeholder="Enter Party B" required>
                                </div>

                                <!-- Initiator Name -->
                                <div class="col-md-6 col-lg-4">
                                    <label for="initiatorName" class="form-label">Initiator Name *</label>
                                    <input type="text" class="form-control" id="initiatorName" name="initiatorName" placeholder="Enter Initiator Name" required>
                                </div>

                                <!-- Webhook Endpoints -->
                                <div class="col-12 mt-3">
                                    <h6 class="border-bottom pb-2 mb-3">Webhook Endpoints</h6>
                                </div>

                                <!-- Confirmation URL -->
                                <div class="col-md-6">
                                    <label for="confirmationUrl" class="form-label">Confirmation URL Endpoint *</label>
                                    <input type="url" class="form-control" id="confirmationUrl" name="confirmationUrl"
                                        placeholder="https://yourdomain.com/api/mpesa/confirmation" required>
                                    <div class="form-text">
                                        <small>URL where M-Pesa sends payment confirmation notifications</small>
                                    </div>
                                </div>

                                <!-- Validation URL -->
                                <div class="col-md-6">
                                    <label for="validationUrl" class="form-label">Validation URL Endpoint *</label>
                                    <input type="url" class="form-control" id="validationUrl" name="validationUrl"
                                        placeholder="https://yourdomain.com/api/mpesa/validation" required>
                                    <div class="form-text">
                                        <small>URL where M-Pesa sends payment validation requests</small>
                                    </div>
                                </div>

                                <!-- Validation Settings -->
                                <div class="col-12 mt-3">
                                    <h6 class="border-bottom pb-2 mb-3">Validation Settings</h6>
                                </div>

                                <!-- Validation Parameter -->
                                <div class="col-md-6">
                                    <label for="validationParameter" class="form-label">Validation Parameter *</label>
                                    <select class="form-select" id="validationParameter" name="validationParameter" required>
                                        <option value="1">Accepted</option>
                                        <option value="2">Rejected</option>
                                    </select>
                                    <div class="form-text">
                                        <small>
                                            <strong>Accepted:</strong> Prompts the API to accept transactions with no validation<br>
                                            <strong>Rejected:</strong> Prompts the API to reject transactions if no validation done
                                        </small>
                                    </div>
                                </div>

                                <!-- Result Code Parameter -->
                                <div class="col-md-6">
                                    <label for="resultCodeParameter" class="form-label">Validation Result Code Parameter *</label>
                                    <select class="form-select" id="resultCodeParameter" name="resultCodeParameter" required>
                                        <option value="1">Success Code</option>
                                        <option value="2">Rejected</option>
                                    </select>
                                    <div class="form-text">
                                        <small>
                                            <strong>Success Code:</strong> Shows transaction success status<br>
                                            <strong>Rejected:</strong> Shows transaction rejection status
                                        </small>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

                <!-- Modal Footer -->
                <div class="modal-footer">
                    <div class="d-flex justify-content-between w-100">
                        <div>
                            <button type="button" class="btn btn-outline-secondary" id="resetMpesaForm">
                                <i class="bi bi-arrow-clockwise me-2"></i> Reset
                            </button>
                            <button type="button" class="btn btn-outline-danger" id="clearMpesaForm">
                                <i class="bi bi-trash me-2"></i> Clear All
                            </button>
                        </div>
                        <div>
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
                                <i class="bi bi-x-circle me-2"></i> Cancel
                            </button>
                            <button type="submit" class="btn btn-primary create-api-setting-btn">
                                <i class="bi bi-save me-2"></i> Save Settings
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
