<div class="modal" id="addMultipleAssetInterfacesModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header bg-dark">
                <h5 class="modal-title"><i class="fa fa-fw fa-ethernet me-2"></i>Creating Multiple Interfaces: <strong><?= $asset_name ?></strong></h5>
                <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
            </div>

            <form action="post.php" method="post" autocomplete="off">
                <input type="hidden" name="asset_id" value="<?= $asset_id ?>">
                <input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">

                <div class="modal-body">

                    <!-- Starting Interface Number -->
                    <div class="mb-3">
                        <label for="interface_start">Starting Interface Number</label>
                        <div class="input-group">
                                <span class="input-group-text"><i class="fa fa-fw fa-ethernet"></i></span>
                            <input type="number" id="interface_start" class="form-control" name="interface_start" placeholder="e.g., 1" min="0" required>
                        </div>
                    </div>

                    <!-- Number of Interfaces -->
                    <div class="mb-3">
                        <label for="interfaces">Number of Interfaces / Ports</label>
                        <div class="input-group">
                                <span class="input-group-text"><i class="fa fa-fw fa-ethernet"></i></span>
                            <input type="number" id="interfaces" class="form-control" name="interfaces" placeholder="How many interfaces to create?" min="1" required>
                        </div>
                    </div>

                    <!-- Type -->
                    <div class="mb-3">
                        <label for="network">Interface Type</label>
                        <div class="input-group">
                                <span class="input-group-text"><i class="fa fa-fw fa-plug"></i></span>
                            <select class="form-select select2" name="type">
                                <option value="">- Select Type -</option>
                                <?php
                                $sql_interface_types_select = mysqli_query($mysqli, "
                                    SELECT category_name FROM categories
                                    WHERE category_type = 'network_interface'
                                    AND category_archived_at IS NULL
                                    ORDER BY category_order ASC, category_name ASC
                                ");
                                while ($row = mysqli_fetch_assoc($sql_interface_types_select)) {
                                    $interface_type_select = escapeHtml($row['category_name']);
                                    ?>
                                    <option><?= $interface_type_select ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>

                    <!-- Interface Name -->
                    <div class="mb-3">
                        <label for="name_prefix">Interface Name / Port Prefix (Optional)</label>
                        <div class="input-group">
                                <span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
                            <input type="text" id="name_prefix" class="form-control" name="name_prefix" placeholder="e.g., eth-" maxlength="200">
                        </div>
                    </div>

                    <!-- Network -->
                    <div class="mb-3">
                        <label for="network">Network Assignment</label>
                        <div class="input-group">
                                <span class="input-group-text"><i class="fa fa-fw fa-network-wired"></i></span>
                            <select id="network" class="form-select select2" name="network">
                                <option value="">- Select Network -</option>
                                <?php
                                $sql_network_select = mysqli_query($mysqli, "SELECT network_id, network_name, network FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
                                while ($row = mysqli_fetch_assoc($sql_network_select)) {
                                    $network_id = $row['network_id'];
                                    $network_name = escapeHtml($row['network_name']);
                                    $network = escapeHtml($row['network']);
                                    ?>
                                    <option value="<?= $network_id ?>">
                                        <?= "$network_name - $network" ?>
                                    </option>
                                <?php } ?>
                            </select>
                        </div>
                        <small class="form-text text-muted">Choose the network for these interfaces or leave as None.</small>
                    </div>

                    <!-- Notes -->
                    <div class="mb-3">
                        <label for="notes">Additional Notes</label>
                        <textarea id="notes" class="form-control" rows="5" placeholder="Enter any additional details or notes" name="notes"></textarea>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="submit" name="add_asset_multiple_interfaces" class="btn btn-primary text-bold">
                        <i class="fas fa-check me-2"></i>Create Interfaces
                    </button>
                    <button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
                </div>
            </form>
        </div>
    </div>
</div>
